aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src/androidTest
diff options
context:
space:
mode:
authorpedroGitt <pedro.contreiras@amdocs.com>2016-10-18 19:02:18 +0200
committerpedroGitt <pedro.contreiras@amdocs.com>2016-10-18 19:02:18 +0200
commit26d9934fc84f3da742e4c38f37ee50a9ddb5237b (patch)
tree43266ade9567cbcda83867282f22256ef14144d3 /java/android/OlmLibSdk/olm-sdk/src/androidTest
parenta6913c49c26b54a4856f883daeb27970f9ab59a4 (diff)
Fix verifyEd25519Signature() API to properly return the error message in case signature verification failed
- update unit tests
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/androidTest')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java
index 5175424..b500cdf 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java
@@ -45,7 +45,7 @@ public class OlmUtilityTest {
@Test
public void test01VerifyEd25519Signing() {
String fingerPrintKey = null;
- String errorMsg = new String();
+ StringBuffer errorMsg = new StringBuffer();
String message = "{\"key1\":\"value1\",\"key2\":\"value2\"};";
// create account
@@ -67,10 +67,20 @@ public class OlmUtilityTest {
assertTrue("Exception MSg="+e.getMessage(), false);
}
- // instance utility
+ // instantiate utility object
OlmUtility utility = new OlmUtility();
+
+ // verify signature
+ errorMsg.append("init with anything");
boolean isVerified = utility.verifyEd25519Signature(messageSignature, fingerPrintKey, message, errorMsg);
assertTrue(isVerified);
+ assertTrue(String.valueOf(errorMsg).isEmpty());
+
+ // check a bad signature is detected and the error message is not empty
+ messageSignature = "Bad signature Bad signature Bad signature..";
+ isVerified = utility.verifyEd25519Signature(messageSignature, fingerPrintKey, message, errorMsg);
+ assertFalse(isVerified);
+ assertFalse(String.valueOf(errorMsg).isEmpty());
utility.releaseUtility();
}