JNI-117 - "export_key", Improve test Release_2.2.0-RC3
authorheck <heck@pep.foundation>
Wed, 13 Jan 2021 18:45:26 +0100
changeset 985cf9c4b574a61
parent 984 99502f7225a8
child 986 6a01fb9919d3
JNI-117 - "export_key", Improve test
test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java
     1.1 --- a/test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java	Wed Jan 13 18:35:59 2021 +0100
     1.2 +++ b/test/java/foundation/pEp/jniadapter/test/jni117/TestAlice.java	Wed Jan 13 18:45:26 2021 +0100
     1.3 @@ -6,6 +6,13 @@
     1.4  
     1.5  import static foundation.pEp.pitytest.TestLogger.log;
     1.6  
     1.7 +// Test for JNI-117 - Key Export
     1.8 +
     1.9 +// Tests: For an ad-hoc generated identity "alice" using myself()"
    1.10 +// - export_key is not throwing
    1.11 +// - keydata returned is longer than 100 bytes
    1.12 +// - keydata contains header: "-----BEGIN PGP PBLIC KEY BLOCK-----"
    1.13 +
    1.14  class TestAlice {
    1.15      public static void main(String[] args) throws Exception {
    1.16          TestSuite.getDefault().setVerbose(true);
    1.17 @@ -13,7 +20,11 @@
    1.18  
    1.19          new TestUnit<AdapterBaseTestContext>("Test Alice",new AdapterBaseTestContext() , ctx  -> {
    1.20              ctx.alice = ctx.engine.myself(ctx.alice);
    1.21 -            log(new String(ctx.engine.export_key(ctx.alice.fpr)));
    1.22 +            byte[] keydata = ctx.engine.export_key(ctx.alice.fpr);
    1.23 +            String keydataStr = new String(keydata);
    1.24 +            log(keydataStr);
    1.25 +            assert keydata.length > 100: "returned keydata is too short";
    1.26 +            assert keydataStr.contains("-----BEGIN PGP PUBLIC KEY BLOCK-----") : "Keydata doesnt contain: -----BEGIN PGP PBLIC KEY BLOCK-----";
    1.27          });
    1.28  
    1.29          TestSuite.getDefault().run();