From a4ab8c7ced9cddd9b5c978f594c02415bc16cf1d Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 20 May 2020 23:27:46 +0200 Subject: [PATCH] Fix test "jni98" to work from day-zero env --- .../foundation/pEp/jniadapter/test/Makefile.conf | 1 + .../pEp/jniadapter/test/jni98/Makefile | 2 +- .../pEp/jniadapter/test/jni98/TestMain.java | 16 +++++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/java/foundation/pEp/jniadapter/test/Makefile.conf b/test/java/foundation/pEp/jniadapter/test/Makefile.conf index bddc9d6..58dc32a 100644 --- a/test/java/foundation/pEp/jniadapter/test/Makefile.conf +++ b/test/java/foundation/pEp/jniadapter/test/Makefile.conf @@ -11,6 +11,7 @@ JAVA=java -Xcheck:jni -cp $(CLASSPATH) -Djava.library.path=$(CLASSPATH) JAVA_CLASSES_FRAMEWORK= \ ../framework/TestUnit.class \ + ../framework/TestContextInterface.class \ ../framework/AbstractTestContext.class \ ../framework/TestLogger.class \ ../framework/TestUtils.class diff --git a/test/java/foundation/pEp/jniadapter/test/jni98/Makefile b/test/java/foundation/pEp/jniadapter/test/jni98/Makefile index 6f1e518..20087bd 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni98/Makefile +++ b/test/java/foundation/pEp/jniadapter/test/jni98/Makefile @@ -14,7 +14,7 @@ JAVA_CLASSES += $(JAVA_CLASSES_FRAMEWORK) all: compile $(MAKE) run -run: compile +run: compile clean-pep-home cd $(JAVA_CWD);pwd;HOME=$(JAVA_PEP_HOME_DIR) $(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestMain compile: $(JAVA_CLASSES) diff --git a/test/java/foundation/pEp/jniadapter/test/jni98/TestMain.java b/test/java/foundation/pEp/jniadapter/test/jni98/TestMain.java index 8883a33..448fbed 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni98/TestMain.java +++ b/test/java/foundation/pEp/jniadapter/test/jni98/TestMain.java @@ -26,10 +26,11 @@ Please see https://pep.foundation/jira/browse/JNI-98 for further discussion class TestMain { public static void main(String[] args) throws Exception { - new TestUnit("JNI-98 - Message.EncFormat.PEP", new AdapterBaseTestContext(), env -> { + new TestUnit("JNI-98 - Message.EncFormat.PEP", new AdapterBaseTestContext(), ctx -> { + ctx.engine.importKey(ctx.keyBobPub); // Make msg1 by encrypting msgToBob logH2("Create target Message"); - Message msg1 = env.engine.encrypt_message(env.msgToBob, null, Message.EncFormat.PEP); + Message msg1 = ctx.engine.encrypt_message(ctx.msgToBob, null, Message.EncFormat.PEP); log("\n" + msgToString(msg1, false)); // Lets get the pgpText of the msg1, and the EncFormat @@ -39,19 +40,20 @@ class TestMain { // Create msg2 by using incomingMessageFromPGPText with the pgpText and EncFormat from msg1 logH2("incomingMessageFromPGPText()"); - Message msg2 = env.engine.incomingMessageFromPGPText(pgpText, Message.EncFormat.PEP); + Message msg2 = ctx.engine.incomingMessageFromPGPText(pgpText, Message.EncFormat.PEP); log("\n" + msgToString(msg2, false)); logH2("Verify msg2"); Engine.decrypt_message_Return result = null; - result = env.engine.decrypt_message(msg2, env.vStr, 0); + result = ctx.engine.decrypt_message(msg2, ctx.vStr, 0); log("\n" + msgToString(result.dst, false)); }).run(); - new TestUnit("JNI-98 - Message.EncFormat.PEP_enc_inline_EA", new AdapterBaseTestContext(), env -> { + new TestUnit("JNI-98 - Message.EncFormat.PEP_enc_inline_EA", new AdapterBaseTestContext(), ctx -> { + ctx.engine.importKey(ctx.keyBobPub); // Make msg1 by encrypting msgToBob logH2("Create target Message"); - Message msg1 = env.engine.encrypt_message(env.msgToBob, null, Message.EncFormat.PEPEncInlineEA); + Message msg1 = ctx.engine.encrypt_message(ctx.msgToBob, null, Message.EncFormat.PEPEncInlineEA); log("\n" + msgToString(msg1, false)); // Lets get the pgpText of the msg1, and the EncFormat @@ -60,7 +62,7 @@ class TestMain { // Create msg2 by using incomingMessageFromPGPText with the pgpText and EncFormat from msg1 logH2("incomingMessageFromPGPText()"); - Message msg2 = env.engine.incomingMessageFromPGPText(pgpText, ef); + Message msg2 = ctx.engine.incomingMessageFromPGPText(pgpText, ef); log("\n" + msgToString(msg2, false)); // Cant be just simply decrypted again