Browse Source

Test case added, importKey(), setOwnKey(), NO config_passphrase(), THEN encryptMessage(). (No callback yet)

JNI-114
heck 5 years ago
parent
commit
9b949e7f28
  1. 37
      test/java/foundation/pEp/jniadapter/test/jni114/Makefile
  2. 48
      test/java/foundation/pEp/jniadapter/test/jni114/TestAlice.java

37
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

48
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<AdapterBaseTestContext>("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();
}
}
Loading…
Cancel
Save