Browse Source

Merge branch 'JNI-150 - Test: Ident.user_id For Own Identities Is Constant' into Release_2.1

pull/6/head
heck 1 year ago
parent
commit
5b344d5679
2 changed files with 88 additions and 0 deletions
  1. +34
    -0
      test/java/foundation/pEp/jniadapter/test/jni150/Makefile
  2. +54
    -0
      test/java/foundation/pEp/jniadapter/test/jni150/TestAlice.java

+ 34
- 0
test/java/foundation/pEp/jniadapter/test/jni150/Makefile View File

@ -0,0 +1,34 @@
include ../../../../../../../Makefile.conf
include ../Makefile.conf
TEST_UNIT_NAME=jni150
JAVA_CLASSES+= \
TestAlice.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

+ 54
- 0
test/java/foundation/pEp/jniadapter/test/jni150/TestAlice.java View File

@ -0,0 +1,54 @@
package foundation.pEp.jniadapter.test.jni150;
import foundation.pEp.jniadapter.Identity;
import foundation.pEp.jniadapter.test.utils.AdapterTestUtils;
import foundation.pEp.jniadapter.test.utils.CTXBase;
import foundation.pEp.pitytest.TestSuite;
import foundation.pEp.pitytest.TestUnit;
import foundation.pEp.pitytest.utils.TestUtils;
import static foundation.pEp.pitytest.TestLogger.log;
/*
JNI-150 - Test: Ident.user_id For Own Identities
Expected Behaviour
after creating keypairs on new and first identity in a pEp-DB (alice) using myself()
alice.user_id has the user_id that has been provided to myself()
For every following ident created using myself():
ident.user_id has to be equal to alice.user_id
*/
class TestAlice {
public static void main(String[] args) throws Exception {
TestSuite.getDefault().setVerbose(true);
TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN);
CTXBase ctxBase = new CTXBase();
new TestUnit<CTXBase>("user_id after first myself() ever", ctxBase, ctx -> {
Identity result = ctx.engine.myself(ctx.alice);
log(AdapterTestUtils.identityToString(result, true));
assert result.user_id.equals(ctx.alice.user_id): result.address + ": user_id is expected to be "+ctx.alice.user_id+", but is: " + result.user_id;
});
new TestUnit<CTXBase>("user_id constant for all own_identities", ctxBase, ctx -> {
Identity result = ctx.engine.myself(ctx.bob);
log(AdapterTestUtils.identityToString(result, true));
assert result.user_id.equals(ctx.alice.user_id): result.address + ": user_id is expected to be "+ctx.alice.user_id+", but is: " + result.user_id;
});
new TestUnit<CTXBase>("user_id constant for all own_identities", ctxBase, ctx -> {
Identity result = ctx.engine.myself(ctx.carol);
log(AdapterTestUtils.identityToString(result, true));
assert result.user_id.equals(ctx.alice.user_id): result.address + ": user_id is expected to be "+ctx.alice.user_id+", but is: " + result.user_id;
});
TestSuite.getDefault().run();
}
}

Loading…
Cancel
Save