diff --git a/test/java/foundation/pEp/jniadapter/test/jni114/Makefile b/test/java/foundation/pEp/jniadapter/test/jni114/Makefile new file mode 100644 index 0000000..5180dc1 --- /dev/null +++ b/test/java/foundation/pEp/jniadapter/test/jni114/Makefile @@ -0,0 +1,37 @@ +include ../../../../../../../Makefile.conf +include ../Makefile.conf + +TEST_UNIT_NAME=jni114 + +JAVA_CLASSES = \ + TestAlice.class \ + ../utils/AdapterBaseTestContext.class \ + ../utils/AdapterTestUtils.class \ + ../utils/TestCallbacks.class + +.PHONY: pitytest compile alice test clean + +all: alice compile + +pitytest: + $(MAKE) -C $(PITYTEST_DIR) + +alice: compile clean-pep-home-alice + cd $(JAVA_CWD);pwd;HOME=$(JAVA_PEP_HOME_DIR_ALICE) $(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestAlice + +compile: $(JAVA_CLASSES) pitytest + +%.class: %.java + cd $(JAVA_CWD);javac -cp $(CLASSPATH) $(JAVA_PKG_BASEPATH)/$(TEST_UNIT_NAME)/$< + +clean: + rm -f $(JAVA_CLASSES) + rm -f *.class + rm -f *.log + rm -Rf .gnupg + rm -Rf .lldb + +clean-pep-home: clean-pep-home-alice + +clean-pep-home-alice: + rm -rf $(PEP_HOME_DIR_ALICE)/.pEp diff --git a/test/java/foundation/pEp/jniadapter/test/jni114/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni114/TestAlice.java new file mode 100644 index 0000000..7ec8242 --- /dev/null +++ b/test/java/foundation/pEp/jniadapter/test/jni114/TestAlice.java @@ -0,0 +1,48 @@ +package foundation.pEp.jniadapter.test.jni114; + +import static foundation.pEp.pitytest.TestLogger.*; +import static foundation.pEp.pitytest.utils.TestUtils.readKey; + +import foundation.pEp.jniadapter.*; +import foundation.pEp.pitytest.*; +import foundation.pEp.pitytest.utils.TestUtils; +import foundation.pEp.jniadapter.test.utils.*; + +import java.util.Vector; + + +// https://pep.foundation/jira/browse/JNI-111 + +class JNI114TestContext extends AdapterBaseTestContext { + @Override + public void init() throws Throwable { + super.init(); + alice = null; + bob = null; + } +} + +class TestAlice { + public static void main(String[] args) throws Exception { +// readKey(); + TestSuite.getDefault().setVerbose(true); + TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN); + + AdapterBaseTestContext jni111Ctx = new JNI114TestContext(); + + new TestUnit("importKey()", jni111Ctx, ctx -> { + ctx.alice = ctx.engine.importKey(ctx.keyAliceSecPassphrase).get(0); + log(AdapterTestUtils.identityToString(ctx.alice, true)); + ctx.alice.user_id = "23"; + ctx.alice = ctx.engine.setOwnKey(ctx.alice, ctx.alice.fpr); + log(AdapterTestUtils.identityToString(ctx.alice, true)); + + Message enc = ctx.engine.encrypt_message(ctx.msgToSelf, new Vector<>(), Message.EncFormat.PEP); + log(AdapterTestUtils.msgToString(enc, false)); +// ctx.engine.startSync(); + + }); + + TestSuite.getDefault().run(); + } +} \ No newline at end of file