diff --git a/src/codegen/pEp.yml2 b/src/codegen/pEp.yml2 index 14ef8b8..7ec2584 100644 --- a/src/codegen/pEp.yml2 +++ b/src/codegen/pEp.yml2 @@ -242,6 +242,8 @@ namespace pEp { in identity ident ); + method cached=true disable_all_sync_channels(); + method config_cipher_suite( in CipherSuite suite ); diff --git a/test/java/foundation/pEp/jniadapter/test/Makefile b/test/java/foundation/pEp/jniadapter/test/Makefile index 1bb02e6..240a5e8 100644 --- a/test/java/foundation/pEp/jniadapter/test/Makefile +++ b/test/java/foundation/pEp/jniadapter/test/Makefile @@ -24,6 +24,7 @@ run: compile $(MAKE) -C jni143 $(MAKE) -C jni147 $(MAKE) -C jni148 + $(MAKE) -C jni149 compile: @@ -52,6 +53,7 @@ compile: $(MAKE) -C jni143 compile $(MAKE) -C jni147 compile $(MAKE) -C jni148 compile + $(MAKE) -C jni149 compile clean: $(MAKE) -C templateAlice clean @@ -78,6 +80,7 @@ clean: $(MAKE) -C jni143 clean $(MAKE) -C jni147 clean $(MAKE) -C jni148 clean + $(MAKE) -C jni149 clean clean-pep-home: $(MAKE) -C basic clean-pep-home diff --git a/test/java/foundation/pEp/jniadapter/test/jni149/Makefile b/test/java/foundation/pEp/jniadapter/test/jni149/Makefile new file mode 100644 index 0000000..555e64b --- /dev/null +++ b/test/java/foundation/pEp/jniadapter/test/jni149/Makefile @@ -0,0 +1,34 @@ +include ../../../../../../../Makefile.conf +include ../Makefile.conf + +TEST_UNIT_NAME=jni149 + +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 diff --git a/test/java/foundation/pEp/jniadapter/test/jni149/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni149/TestAlice.java new file mode 100644 index 0000000..1786f3a --- /dev/null +++ b/test/java/foundation/pEp/jniadapter/test/jni149/TestAlice.java @@ -0,0 +1,58 @@ +package foundation.pEp.jniadapter.test.jni149; + +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-149 - Wrap disable_all_sync_channels into the adapter + +Test: +create 3 identities a,b,c as new own identities using myself() +assert a,b,c are enabled for sync (ident.flags == 0) +call disable_all_sync_channels(); +assert a,b,c, are disabled for sync (ident.flags == 1) +*/ + + +class TestAlice { + public static void main(String[] args) throws Exception { + TestSuite.getDefault().setVerbose(true); + TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN); + + new TestUnit("disable_all_sync_channels()", new CTXBase(), ctx -> { + ctx.alice = ctx.engine.myself(ctx.alice); + ctx.bob = ctx.engine.myself(ctx.bob); + ctx.carol = ctx.engine.myself(ctx.carol); + log(AdapterTestUtils.identityToString(ctx.alice, true)); + log(AdapterTestUtils.identityToString(ctx.bob, true)); + log(AdapterTestUtils.identityToString(ctx.carol, true)); + assert ctx.alice.flags == 0 : ctx.alice.address + ": flags are expected to be 0, but are: " + ctx.alice.flags; + assert ctx.bob.flags == 0 : ctx.bob.address + ": flags are expected to be 0, but are: " + ctx.bob.flags; + assert ctx.carol.flags == 0 : ctx.carol.address + ": flags are expected to be 0, but are: " + ctx.carol.flags; + + // disable_all_sync_channels + ctx.engine.disable_all_sync_channels(); + + ctx.alice = ctx.engine.myself(ctx.alice); + ctx.bob = ctx.engine.myself(ctx.bob); + ctx.carol = ctx.engine.myself(ctx.carol); + log("\n\n"); + log(AdapterTestUtils.identityToString(ctx.alice, true)); + log(AdapterTestUtils.identityToString(ctx.bob, true)); + log(AdapterTestUtils.identityToString(ctx.carol, true)); + assert ctx.alice.flags == 1 : ctx.alice.address + ": flags are expected to be 1, but are: " + ctx.alice.flags; + assert ctx.bob.flags == 1 : ctx.bob.address + ": flags are expected to be 1, but are: " + ctx.bob.flags; + assert ctx.carol.flags == 1 : ctx.carol.address + ": flags are expected to be 1, but are: " + ctx.carol.flags; + }); + + TestSuite.getDefault().run(); + } +} + + diff --git a/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java b/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java index 31f6c92..92b60c6 100644 --- a/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java +++ b/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java @@ -84,15 +84,21 @@ public class CTXBase extends AbstractTestContext { attachment1KB = AdapterTestUtils.makeNewTestBlob(1000, "att with size 1KB", null); alice = new Identity(); + alice.username = "Alice pEp Test"; alice.user_id = "23"; alice.address = "alice@peptest.org"; alice.me = true; bob = new Identity(); - bob.username = "pEp Test Bob"; + bob.username = "Bob pEp Test"; bob.user_id = "42"; bob.address = "bob@peptest.org"; + carol = new Identity(); + carol.username = "Carol pEp Test"; + carol.user_id = "65"; + carol.address = "carol@peptest.org"; + msgAliceToAlice = AdapterTestUtils.makeNewTestMessage(alice, alice, Message.Direction.Outgoing); msgAliceToBob = AdapterTestUtils.makeNewTestMessage(alice, bob, Message.Direction.Outgoing);