Skip to content

Commit

Permalink
Tests for encrypted PEM key export
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Jan 29, 2024
1 parent a250b23 commit 41f60db
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions convex-cli/src/test/java/convex/cli/key/KeyExportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import convex.cli.CLTester;
import convex.cli.ExitCodes;
import convex.cli.Helpers;
import convex.core.crypto.AKeyPair;
import convex.core.crypto.PEMTools;
import convex.core.crypto.PFXTools;
import convex.core.data.AccountKey;
import convex.core.util.Utils;
Expand Down Expand Up @@ -61,27 +63,16 @@ public void testKeyGenerateAndExport() {
"key",
"export",
"--keystore-password", new String(KEYSTORE_PASSWORD),
"--p", new String(KEY_PASSWORD),
"--keystore", KEYSTORE_FILENAME,
"--key", publicKey,
"--export-password", new String(EXPORT_PASSWORD)
);
assertEquals(ExitCodes.SUCCESS,tester.getResult());
// TODO test generated output

// command key.export publicKey with leading 0x
tester = CLTester.run(
"key",
"export",
"--keystore-password", new String(KEYSTORE_PASSWORD),
"--password", new String(KEY_PASSWORD),
"--keystore", KEYSTORE_FILENAME,
"--key", "0x" + publicKey,
"--public-key", publicKey,
"--export-password", new String(EXPORT_PASSWORD)
);
String s=tester.getOutput();
System.out.println(s);
assertEquals(ExitCodes.SUCCESS,tester.getResult());
// TODO test generated output


AKeyPair kp=AKeyPair.create(PEMTools.decryptPrivateKeyFromPEM(s, EXPORT_PASSWORD));
assertEquals(ak,kp.getAccountKey());
}
}

0 comments on commit 41f60db

Please sign in to comment.