From 03ae28e0873486649421b9428c4407851a89241c Mon Sep 17 00:00:00 2001 From: ylecollen Date: Tue, 10 Jan 2017 14:45:20 +0100 Subject: Update after a new review --- .../java/org/matrix/olm/OlmAccountTest.java | 7 +------ .../java/org/matrix/olm/OlmSessionTest.java | 20 +++++--------------- .../java/org/matrix/olm/OlmUtilityTest.java | 14 +++----------- 3 files changed, 9 insertions(+), 32 deletions(-) (limited to 'java/android/OlmLibSdk/olm-sdk/src/androidTest') diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java index d474f12..ffbbca1 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java +++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java @@ -389,17 +389,12 @@ public class OlmAccountTest { assertTrue(e.getMessage(),false); } - boolean sessionRetCode = true; - try { - sessionRetCode = olmAccount.removeOneTimeKeys(null); + olmAccount.removeOneTimeKeys(null); } catch (Exception e) { assertTrue(e.getMessage(), false); } - // test against no matching keys - assertFalse(sessionRetCode); - olmAccount.releaseAccount(); } diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java index bb24f7a..e08b151 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java +++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java @@ -174,13 +174,11 @@ public class OlmSessionTest { assertTrue(clearMsg.equals(decryptedMsg)); // clean objects.. - boolean res = false; try { - res = bobAccount.removeOneTimeKeys(bobSession); + bobAccount.removeOneTimeKeys(bobSession); } catch (Exception e) { assertTrue(e.getMessage(), false); } - assertTrue(res); // release accounts bobAccount.releaseAccount(); @@ -402,13 +400,11 @@ public class OlmSessionTest { assertTrue(clearMsg1.equals(decryptedMsg1)); // clean objects.. - boolean res = false; try { - res = bobAccount.removeOneTimeKeys(bobSession); + bobAccount.removeOneTimeKeys(bobSession); } catch (Exception e) { assertTrue(e.getMessage(), false); } - assertTrue(res); bobAccount.releaseAccount(); aliceAccount.releaseAccount(); @@ -585,13 +581,11 @@ public class OlmSessionTest { //assertTrue(false==bobSession.matchesInboundSessionFrom(bobIdentityKey, encryptedAliceToBobMsg1.mCipherText)); // release objects - boolean res = false; try { - res = bobAccount.removeOneTimeKeys(bobSession); + bobAccount.removeOneTimeKeys(bobSession); } catch (Exception e) { assertTrue(e.getMessage(), false); } - assertTrue(res); aliceAccount.releaseAccount(); bobAccount.releaseAccount(); @@ -782,13 +776,11 @@ public class OlmSessionTest { assertTrue(clearMsg3.equals(decryptedMsg3)); // clean objects.. - boolean res = false; try { - res = bobAccount.removeOneTimeKeys(bobSession); + bobAccount.removeOneTimeKeys(bobSession); } catch (Exception e) { assertTrue(e.getMessage(), false); } - assertTrue(res); bobAccount.releaseAccount(); aliceAccount.releaseAccount(); @@ -1002,13 +994,11 @@ public class OlmSessionTest { assertTrue(!aliceSession.matchesInboundSessionFrom(null,null)); // release objects - boolean res = false; try { - res = bobAccount.removeOneTimeKeys(bobSession); + bobAccount.removeOneTimeKeys(bobSession); } catch (Exception e) { assertTrue(e.getMessage(), false); } - assertTrue(res); aliceAccount.releaseAccount(); bobAccount.releaseAccount(); 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 cc14e7c..b560bff 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 @@ -104,42 +104,34 @@ public class OlmUtilityTest { } // verify signature - boolean isVerified; - - isVerified = false; errorMsg = null; try { - isVerified = utility.verifyEd25519Signature(messageSignature, fingerPrintKey, message); + utility.verifyEd25519Signature(messageSignature, fingerPrintKey, message); } catch (Exception e) { errorMsg = e.getMessage(); } - assertTrue(isVerified); assertTrue(TextUtils.isEmpty(errorMsg)); // check a bad signature is detected => errorMsg = BAD_MESSAGE_MAC String badSignature = "Bad signature Bad signature Bad signature.."; - isVerified = false; errorMsg = null; try { - isVerified = utility.verifyEd25519Signature(badSignature, fingerPrintKey, message); + utility.verifyEd25519Signature(badSignature, fingerPrintKey, message); } catch (Exception e) { errorMsg = e.getMessage(); } - assertFalse(isVerified); assertTrue(!TextUtils.isEmpty(errorMsg)); // check bad fingerprint size => errorMsg = INVALID_BASE64 String badSizeFingerPrintKey = fingerPrintKey.substring(fingerPrintKey.length()/2); - isVerified = false; errorMsg = null; try { - isVerified = utility.verifyEd25519Signature(messageSignature, badSizeFingerPrintKey, message); + utility.verifyEd25519Signature(messageSignature, badSizeFingerPrintKey, message); } catch (Exception e) { errorMsg = e.getMessage(); } - assertFalse(isVerified); assertTrue(!TextUtils.isEmpty(errorMsg)); utility.releaseUtility(); -- cgit v1.2.3