From 7ec817ab3846dd007fb5f1a8a5b329fd5480196a Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 13 Jan 2021 18:45:26 +0100 Subject: [PATCH] JNI-117 - "export_key", Improve test --- .../pEp/jniadapter/test/jni117/TestAlice.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java index a2f856d..597eb74 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java +++ b/test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java @@ -6,6 +6,13 @@ import foundation.pEp.pitytest.utils.TestUtils; import static foundation.pEp.pitytest.TestLogger.log; +// Test for JNI-117 - Key Export + +// Tests: For an ad-hoc generated identity "alice" using myself()" +// - export_key is not throwing +// - keydata returned is longer than 100 bytes +// - keydata contains header: "-----BEGIN PGP PBLIC KEY BLOCK-----" + class TestAlice { public static void main(String[] args) throws Exception { TestSuite.getDefault().setVerbose(true); @@ -13,7 +20,11 @@ class TestAlice { new TestUnit("Test Alice",new AdapterBaseTestContext() , ctx -> { ctx.alice = ctx.engine.myself(ctx.alice); - log(new String(ctx.engine.export_key(ctx.alice.fpr))); + byte[] keydata = ctx.engine.export_key(ctx.alice.fpr); + String keydataStr = new String(keydata); + log(keydataStr); + assert keydata.length > 100: "returned keydata is too short"; + assert keydataStr.contains("-----BEGIN PGP PUBLIC KEY BLOCK-----") : "Keydata doesnt contain: -----BEGIN PGP PBLIC KEY BLOCK-----"; }); TestSuite.getDefault().run();