Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
10683bb8cf | 3 years ago |
![]() |
cacb82e2b6 | 3 years ago |
![]() |
29ad20d23d | 3 years ago |
![]() |
cab760aec6 | 3 years ago |
5 changed files with 117 additions and 5 deletions
@ -0,0 +1,34 @@ |
|||||
|
include ../../../../../../../Makefile.conf |
||||
|
include ../Makefile.conf |
||||
|
|
||||
|
TEST_UNIT_NAME=jni171 |
||||
|
|
||||
|
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 |
@ -0,0 +1,66 @@ |
|||||
|
package foundation.pEp.jniadapter.test.jni171; |
||||
|
|
||||
|
import foundation.pEp.jniadapter.Message; |
||||
|
import foundation.pEp.jniadapter.Pair; |
||||
|
import foundation.pEp.jniadapter.decrypt_message_Return; |
||||
|
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 java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import static foundation.pEp.pitytest.TestLogger.log; |
||||
|
|
||||
|
|
||||
|
/* |
||||
|
JNI-171 - Test: Opt Fields does trimming after en/decryption |
||||
|
|
||||
|
Expected Behaviour: |
||||
|
Values of OptFields are NOT trimmed or otherwise altered in an encrypt/decrypt roundtrip |
||||
|
*/ |
||||
|
|
||||
|
class Jni171TestContext extends CTXBase { |
||||
|
@Override |
||||
|
public CTXBase init() throws Throwable { |
||||
|
super.init(); |
||||
|
alice = engine.myself(alice); |
||||
|
engine.importKey(keyBobPub); |
||||
|
return this; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class TestAlice { |
||||
|
|
||||
|
public static void main(String[] args) throws Exception { |
||||
|
TestSuite.getDefault().setVerbose(true); |
||||
|
TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN); |
||||
|
|
||||
|
Jni171TestContext ctx171 = new Jni171TestContext(); |
||||
|
|
||||
|
new TestUnit<CTXBase>("OptField values DONT get leading/trailing whitespace removed", ctx171, ctx -> { |
||||
|
ArrayList<Pair<String, String>> optsIn = new ArrayList<>(); |
||||
|
optsIn.add(new Pair<>("six-spaces", " ")); |
||||
|
optsIn.add(new Pair<>("pEp-surrounded-by-ws", " pEp ")); |
||||
|
ctx.msgAliceToBob.setOptFields(optsIn); |
||||
|
log("ORIG: " + AdapterTestUtils.OptFieldsToString(ctx.msgAliceToBob.getOptFields())); |
||||
|
// encrypt
|
||||
|
Message msgEnc = ctx.engine.encrypt_message(ctx.msgAliceToBob, null, Message.EncFormat.PEP); |
||||
|
log("ENC: " + AdapterTestUtils.OptFieldsToString(msgEnc.getOptFields())); |
||||
|
|
||||
|
// decrypt
|
||||
|
decrypt_message_Return decRet = ctx.engine.decrypt_message(msgEnc, null, 0); |
||||
|
log("DEC: " + AdapterTestUtils.OptFieldsToString(decRet.dst.getOptFields())); |
||||
|
|
||||
|
ArrayList<Pair<String, String>> optsOut = decRet.dst.getOptFields(); |
||||
|
assert AdapterTestUtils.optFieldValuesOfKey(optsOut, "six-spaces").get(0).equals(" "); |
||||
|
assert AdapterTestUtils.optFieldValuesOfKey(optsOut, "pEp-surrounded-by-ws").get(0).equals(" pEp "); |
||||
|
}); |
||||
|
|
||||
|
TestSuite.getDefault().run(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
Loading…
Reference in new issue