Fix test compilation and run test with success
Using command `./gradlew connectedAndroidTest` on an API 21 emulator
This commit is contained in:
parent
4d2522a65c
commit
1694f15ffb
8 changed files with 119 additions and 120 deletions
|
@ -19,4 +19,5 @@
|
||||||
#systemProp.https.proxyHost=batproxy
|
#systemProp.https.proxyHost=batproxy
|
||||||
#systemProp.http.proxyPort=8080
|
#systemProp.http.proxyPort=8080
|
||||||
|
|
||||||
|
android.useAndroidX=true
|
||||||
org.gradle.configureondemand=false
|
org.gradle.configureondemand=false
|
||||||
|
|
|
@ -6,9 +6,14 @@ android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 30
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 11
|
minSdkVersion 14
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
// The following argument makes the Android Test Orchestrator run its
|
||||||
|
// "pm clear" command after each test invocation. This command ensures
|
||||||
|
// that the app's state is completely cleared between tests.
|
||||||
|
testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
|
@ -118,6 +123,8 @@ dependencies {
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'junit:junit:4.13.2'
|
androidTestImplementation 'junit:junit:4.13.2'
|
||||||
|
|
||||||
|
androidTestImplementation 'androidx.test:core:1.3.0'
|
||||||
androidTestImplementation 'androidx.test:runner:1.3.0'
|
androidTestImplementation 'androidx.test:runner:1.3.0'
|
||||||
androidTestImplementation 'androidx.test:rules:1.3.0'
|
androidTestImplementation 'androidx.test:rules:1.3.0'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import org.json.JSONObject;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -41,7 +41,6 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -59,15 +58,15 @@ public class OlmAccountTest {
|
||||||
private final String FILE_NAME = "SerialTestFile";
|
private final String FILE_NAME = "SerialTestFile";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass(){
|
public static void setUpClass() {
|
||||||
// load native lib
|
// load native lib
|
||||||
mOlmManager = new OlmManager();
|
mOlmManager = new OlmManager();
|
||||||
|
|
||||||
String olmLibVersion = mOlmManager.getOlmLibVersion();
|
String olmLibVersion = mOlmManager.getOlmLibVersion();
|
||||||
assertNotNull(olmLibVersion);
|
assertNotNull(olmLibVersion);
|
||||||
String olmSdkVersion = mOlmManager.getDetailedVersion(getInstrumentation().getContext());
|
String olmSdkVersion = mOlmManager.getDetailedVersion(ApplicationProvider.getApplicationContext());
|
||||||
assertNotNull(olmLibVersion);
|
assertNotNull(olmLibVersion);
|
||||||
Log.d(LOG_TAG, "## setUpClass(): Versions - Android Olm SDK = "+olmSdkVersion+" Olm lib ="+olmLibVersion);
|
Log.d(LOG_TAG, "## setUpClass(): Versions - Android Olm SDK = " + olmSdkVersion + " Olm lib =" + olmLibVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -77,7 +76,7 @@ public class OlmAccountTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
if(mIsAccountCreated) {
|
if (mIsAccountCreated) {
|
||||||
assertNotNull(mOlmAccount);
|
assertNotNull(mOlmAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,8 +118,8 @@ public class OlmAccountTest {
|
||||||
@Test
|
@Test
|
||||||
public void test04GetOlmAccountId() {
|
public void test04GetOlmAccountId() {
|
||||||
long olmNativeInstance = mOlmAccount.getOlmAccountId();
|
long olmNativeInstance = mOlmAccount.getOlmAccountId();
|
||||||
Log.d(LOG_TAG,"## testGetOlmAccountId olmNativeInstance="+olmNativeInstance);
|
Log.d(LOG_TAG, "## testGetOlmAccountId olmNativeInstance=" + olmNativeInstance);
|
||||||
assertTrue(0!=olmNativeInstance);
|
assertTrue(0 != olmNativeInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,15 +136,15 @@ public class OlmAccountTest {
|
||||||
assertTrue("identityKeys failed " + e.getMessage(), false);
|
assertTrue("identityKeys failed " + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertNotNull(identityKeys);
|
assertNotNull(identityKeys);
|
||||||
Log.d(LOG_TAG,"## testIdentityKeys Keys="+identityKeys);
|
Log.d(LOG_TAG, "## testIdentityKeys Keys=" + identityKeys);
|
||||||
|
|
||||||
// is JSON_KEY_FINGER_PRINT_KEY present?
|
// is JSON_KEY_FINGER_PRINT_KEY present?
|
||||||
String fingerPrintKey = TestHelper.getFingerprintKey(identityKeys);
|
String fingerPrintKey = TestHelper.getFingerprintKey(identityKeys);
|
||||||
assertTrue("fingerprint key missing",!TextUtils.isEmpty(fingerPrintKey));
|
assertTrue("fingerprint key missing", !TextUtils.isEmpty(fingerPrintKey));
|
||||||
|
|
||||||
// is JSON_KEY_IDENTITY_KEY present?
|
// is JSON_KEY_IDENTITY_KEY present?
|
||||||
String identityKey = TestHelper.getIdentityKey(identityKeys);
|
String identityKey = TestHelper.getIdentityKey(identityKeys);
|
||||||
assertTrue("identity key missing",!TextUtils.isEmpty(identityKey));
|
assertTrue("identity key missing", !TextUtils.isEmpty(identityKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
//****************************************************
|
//****************************************************
|
||||||
|
@ -154,9 +153,9 @@ public class OlmAccountTest {
|
||||||
@Test
|
@Test
|
||||||
public void test06MaxOneTimeKeys() {
|
public void test06MaxOneTimeKeys() {
|
||||||
long maxOneTimeKeys = mOlmAccount.maxOneTimeKeys();
|
long maxOneTimeKeys = mOlmAccount.maxOneTimeKeys();
|
||||||
Log.d(LOG_TAG,"## testMaxOneTimeKeys(): maxOneTimeKeys="+maxOneTimeKeys);
|
Log.d(LOG_TAG, "## testMaxOneTimeKeys(): maxOneTimeKeys=" + maxOneTimeKeys);
|
||||||
|
|
||||||
assertTrue(maxOneTimeKeys>0);
|
assertTrue(maxOneTimeKeys > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,15 +191,15 @@ public class OlmAccountTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, String> map = oneTimeKeysJson.get(OlmAccount.JSON_KEY_ONE_TIME_KEY);
|
Map<String, String> map = oneTimeKeysJson.get(OlmAccount.JSON_KEY_ONE_TIME_KEY);
|
||||||
assertTrue(OlmAccount.JSON_KEY_ONE_TIME_KEY +" object is missing", null!=map);
|
assertTrue(OlmAccount.JSON_KEY_ONE_TIME_KEY + " object is missing", null != map);
|
||||||
|
|
||||||
// test the count of the generated one time keys:
|
// test the count of the generated one time keys:
|
||||||
oneTimeKeysCount = map.size();
|
oneTimeKeysCount = map.size();
|
||||||
|
|
||||||
assertTrue("Expected count="+GENERATION_ONE_TIME_KEYS_NUMBER+" found="+oneTimeKeysCount,GENERATION_ONE_TIME_KEYS_NUMBER==oneTimeKeysCount);
|
assertTrue("Expected count=" + GENERATION_ONE_TIME_KEYS_NUMBER + " found=" + oneTimeKeysCount, GENERATION_ONE_TIME_KEYS_NUMBER == oneTimeKeysCount);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertTrue("Exception MSg="+e.getMessage(), false);
|
assertTrue("Exception MSg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +209,7 @@ public class OlmAccountTest {
|
||||||
try {
|
try {
|
||||||
olmSession = new OlmSession();
|
olmSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
long sessionId = olmSession.getOlmSessionId();
|
long sessionId = olmSession.getOlmSessionId();
|
||||||
assertTrue(0 != sessionId);
|
assertTrue(0 != sessionId);
|
||||||
|
@ -241,7 +240,7 @@ public class OlmAccountTest {
|
||||||
@Test
|
@Test
|
||||||
public void test12SignMessage() {
|
public void test12SignMessage() {
|
||||||
String clearMsg = "String to be signed by olm";
|
String clearMsg = "String to be signed by olm";
|
||||||
String signedMsg = null;
|
String signedMsg = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
signedMsg = mOlmAccount.signMessage(clearMsg);
|
signedMsg = mOlmAccount.signMessage(clearMsg);
|
||||||
|
@ -268,13 +267,13 @@ public class OlmAccountTest {
|
||||||
try {
|
try {
|
||||||
accountRef = new OlmAccount();
|
accountRef = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
accountRef.generateOneTimeKeys(GENERATION_ONE_TIME_KEYS_NUMBER);
|
accountRef.generateOneTimeKeys(GENERATION_ONE_TIME_KEYS_NUMBER);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get keys references
|
// get keys references
|
||||||
|
@ -298,7 +297,7 @@ public class OlmAccountTest {
|
||||||
assertNotNull(oneTimeKeysRef);
|
assertNotNull(oneTimeKeysRef);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
//context.getFilesDir();
|
//context.getFilesDir();
|
||||||
fileOutput = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
|
fileOutput = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
@ -316,7 +315,7 @@ public class OlmAccountTest {
|
||||||
assertNotNull(accountDeserial);
|
assertNotNull(accountDeserial);
|
||||||
|
|
||||||
// get de-serialized keys
|
// get de-serialized keys
|
||||||
Map<String, String> identityKeysDeserial = accountDeserial.identityKeys();
|
Map<String, String> identityKeysDeserial = accountDeserial.identityKeys();
|
||||||
Map<String, Map<String, String>> oneTimeKeysDeserial = accountDeserial.oneTimeKeys();
|
Map<String, Map<String, String>> oneTimeKeysDeserial = accountDeserial.oneTimeKeys();
|
||||||
assertNotNull(identityKeysDeserial);
|
assertNotNull(identityKeysDeserial);
|
||||||
assertNotNull(oneTimeKeysDeserial);
|
assertNotNull(oneTimeKeysDeserial);
|
||||||
|
@ -329,23 +328,19 @@ public class OlmAccountTest {
|
||||||
|
|
||||||
accountRef.releaseAccount();
|
accountRef.releaseAccount();
|
||||||
accountDeserial.releaseAccount();
|
accountDeserial.releaseAccount();
|
||||||
}
|
} catch (FileNotFoundException e) {
|
||||||
catch (FileNotFoundException e) {
|
Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg==" + e.getMessage());
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg=="+e.getMessage());
|
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
} catch (ClassNotFoundException e) {
|
||||||
catch (ClassNotFoundException e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception IOException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception IOException Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
/*catch (OlmException e) {
|
/*catch (OlmException e) {
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception OlmException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception OlmException Msg==" + e.getMessage());
|
||||||
}*/
|
}*/ catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
@ -386,7 +381,7 @@ public class OlmAccountTest {
|
||||||
try {
|
try {
|
||||||
olmAccount = new OlmAccount();
|
olmAccount = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -404,7 +399,7 @@ public class OlmAccountTest {
|
||||||
try {
|
try {
|
||||||
olmAccount = new OlmAccount();
|
olmAccount = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
String signedMsg = null;
|
String signedMsg = null;
|
||||||
|
|
||||||
|
@ -487,7 +482,7 @@ public class OlmAccountTest {
|
||||||
account10.releaseAccount();
|
account10.releaseAccount();
|
||||||
|
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,12 @@
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -36,7 +38,6 @@ import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -223,7 +224,7 @@ public class OlmGroupSessionTest {
|
||||||
|
|
||||||
|
|
||||||
// serialize alice session
|
// serialize alice session
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_OUT_SESSION, Context.MODE_PRIVATE);
|
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_OUT_SESSION, Context.MODE_PRIVATE);
|
||||||
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
||||||
|
@ -312,7 +313,7 @@ public class OlmGroupSessionTest {
|
||||||
assertNotNull(bobInboundGroupSessionRef);
|
assertNotNull(bobInboundGroupSessionRef);
|
||||||
|
|
||||||
// serialize alice session
|
// serialize alice session
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_IN_SESSION, Context.MODE_PRIVATE);
|
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_IN_SESSION, Context.MODE_PRIVATE);
|
||||||
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
||||||
|
|
|
@ -16,20 +16,18 @@
|
||||||
|
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@ -107,14 +105,14 @@ public class OlmPkTest {
|
||||||
assertNotNull(mOlmPkDecryption);
|
assertNotNull(mOlmPkDecryption);
|
||||||
|
|
||||||
byte[] privateKey = {
|
byte[] privateKey = {
|
||||||
(byte)0x77, (byte)0x07, (byte)0x6D, (byte)0x0A,
|
(byte) 0x77, (byte) 0x07, (byte) 0x6D, (byte) 0x0A,
|
||||||
(byte)0x73, (byte)0x18, (byte)0xA5, (byte)0x7D,
|
(byte) 0x73, (byte) 0x18, (byte) 0xA5, (byte) 0x7D,
|
||||||
(byte)0x3C, (byte)0x16, (byte)0xC1, (byte)0x72,
|
(byte) 0x3C, (byte) 0x16, (byte) 0xC1, (byte) 0x72,
|
||||||
(byte)0x51, (byte)0xB2, (byte)0x66, (byte)0x45,
|
(byte) 0x51, (byte) 0xB2, (byte) 0x66, (byte) 0x45,
|
||||||
(byte)0xDF, (byte)0x4C, (byte)0x2F, (byte)0x87,
|
(byte) 0xDF, (byte) 0x4C, (byte) 0x2F, (byte) 0x87,
|
||||||
(byte)0xEB, (byte)0xC0, (byte)0x99, (byte)0x2A,
|
(byte) 0xEB, (byte) 0xC0, (byte) 0x99, (byte) 0x2A,
|
||||||
(byte)0xB1, (byte)0x77, (byte)0xFB, (byte)0xA5,
|
(byte) 0xB1, (byte) 0x77, (byte) 0xFB, (byte) 0xA5,
|
||||||
(byte)0x1D, (byte)0xB9, (byte)0x2C, (byte)0x2A
|
(byte) 0x1D, (byte) 0xB9, (byte) 0x2C, (byte) 0x2A
|
||||||
};
|
};
|
||||||
|
|
||||||
assertTrue(privateKey.length == OlmPkDecryption.privateKeyLength());
|
assertTrue(privateKey.length == OlmPkDecryption.privateKeyLength());
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -18,11 +18,12 @@
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -37,7 +38,6 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -53,13 +53,13 @@ public class OlmSessionTest {
|
||||||
private static OlmManager mOlmManager;
|
private static OlmManager mOlmManager;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass(){
|
public static void setUpClass() {
|
||||||
// load native lib
|
// load native lib
|
||||||
mOlmManager = new OlmManager();
|
mOlmManager = new OlmManager();
|
||||||
|
|
||||||
String version = mOlmManager.getOlmLibVersion();
|
String version = mOlmManager.getOlmLibVersion();
|
||||||
assertNotNull(version);
|
assertNotNull(version);
|
||||||
Log.d(LOG_TAG, "## setUpClass(): lib version="+version);
|
Log.d(LOG_TAG, "## setUpClass(): lib version=" + version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +75,7 @@ public class OlmSessionTest {
|
||||||
public void test01AliceToBob() {
|
public void test01AliceToBob() {
|
||||||
final int ONE_TIME_KEYS_NUMBER = 5;
|
final int ONE_TIME_KEYS_NUMBER = 5;
|
||||||
String bobIdentityKey = null;
|
String bobIdentityKey = null;
|
||||||
String bobOneTimeKey=null;
|
String bobOneTimeKey = null;
|
||||||
OlmAccount bobAccount = null;
|
OlmAccount bobAccount = null;
|
||||||
OlmAccount aliceAccount = null;
|
OlmAccount aliceAccount = null;
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ public class OlmSessionTest {
|
||||||
aliceAccount = new OlmAccount();
|
aliceAccount = new OlmAccount();
|
||||||
bobAccount = new OlmAccount();
|
bobAccount = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test accounts creation
|
// test accounts creation
|
||||||
assertTrue(0!=bobAccount.getOlmAccountId());
|
assertTrue(0 != bobAccount.getOlmAccountId());
|
||||||
assertTrue(0!=aliceAccount.getOlmAccountId());
|
assertTrue(0 != aliceAccount.getOlmAccountId());
|
||||||
|
|
||||||
// get bob identity key
|
// get bob identity key
|
||||||
Map<String, String> bobIdentityKeys = null;
|
Map<String, String> bobIdentityKeys = null;
|
||||||
|
@ -101,7 +101,7 @@ public class OlmSessionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
bobIdentityKey = TestHelper.getIdentityKey(bobIdentityKeys);
|
bobIdentityKey = TestHelper.getIdentityKey(bobIdentityKeys);
|
||||||
assertTrue(null!=bobIdentityKey);
|
assertTrue(null != bobIdentityKey);
|
||||||
|
|
||||||
// get bob one time keys
|
// get bob one time keys
|
||||||
try {
|
try {
|
||||||
|
@ -118,7 +118,7 @@ public class OlmSessionTest {
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys,1);
|
bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys, 1);
|
||||||
assertNotNull(bobOneTimeKey);
|
assertNotNull(bobOneTimeKey);
|
||||||
|
|
||||||
// CREATE ALICE SESSION
|
// CREATE ALICE SESSION
|
||||||
|
@ -126,9 +126,9 @@ public class OlmSessionTest {
|
||||||
try {
|
try {
|
||||||
aliceSession = new OlmSession();
|
aliceSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=aliceSession.getOlmSessionId());
|
assertTrue(0 != aliceSession.getOlmSessionId());
|
||||||
|
|
||||||
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
|
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
|
||||||
try {
|
try {
|
||||||
|
@ -145,16 +145,16 @@ public class OlmSessionTest {
|
||||||
}
|
}
|
||||||
assertNotNull(encryptedMsgToBob);
|
assertNotNull(encryptedMsgToBob);
|
||||||
assertNotNull(encryptedMsgToBob.mCipherText);
|
assertNotNull(encryptedMsgToBob.mCipherText);
|
||||||
Log.d(LOG_TAG,"## test01AliceToBob(): encryptedMsg="+encryptedMsgToBob.mCipherText);
|
Log.d(LOG_TAG, "## test01AliceToBob(): encryptedMsg=" + encryptedMsgToBob.mCipherText);
|
||||||
|
|
||||||
// CREATE BOB INBOUND SESSION and decrypt message from alice
|
// CREATE BOB INBOUND SESSION and decrypt message from alice
|
||||||
OlmSession bobSession = null;
|
OlmSession bobSession = null;
|
||||||
try {
|
try {
|
||||||
bobSession = new OlmSession();
|
bobSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=bobSession.getOlmSessionId());
|
assertTrue(0 != bobSession.getOlmSessionId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bobSession.initInboundSession(bobAccount, encryptedMsgToBob.mCipherText);
|
bobSession.initInboundSession(bobAccount, encryptedMsgToBob.mCipherText);
|
||||||
|
@ -220,12 +220,12 @@ public class OlmSessionTest {
|
||||||
aliceAccount = new OlmAccount();
|
aliceAccount = new OlmAccount();
|
||||||
bobAccount = new OlmAccount();
|
bobAccount = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test accounts creation
|
// test accounts creation
|
||||||
assertTrue(0!=bobAccount.getOlmAccountId());
|
assertTrue(0 != bobAccount.getOlmAccountId());
|
||||||
assertTrue(0!=aliceAccount.getOlmAccountId());
|
assertTrue(0 != aliceAccount.getOlmAccountId());
|
||||||
|
|
||||||
// get bob identity key
|
// get bob identity key
|
||||||
Map<String, String> bobIdentityKeys = null;
|
Map<String, String> bobIdentityKeys = null;
|
||||||
|
@ -237,7 +237,7 @@ public class OlmSessionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
bobIdentityKey = TestHelper.getIdentityKey(bobIdentityKeys);
|
bobIdentityKey = TestHelper.getIdentityKey(bobIdentityKeys);
|
||||||
assertTrue(null!=bobIdentityKey);
|
assertTrue(null != bobIdentityKey);
|
||||||
|
|
||||||
// get bob one time keys
|
// get bob one time keys
|
||||||
try {
|
try {
|
||||||
|
@ -254,7 +254,7 @@ public class OlmSessionTest {
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys,1);
|
bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys, 1);
|
||||||
assertNotNull(bobOneTimeKey);
|
assertNotNull(bobOneTimeKey);
|
||||||
|
|
||||||
// CREATE ALICE SESSION
|
// CREATE ALICE SESSION
|
||||||
|
@ -262,9 +262,9 @@ public class OlmSessionTest {
|
||||||
try {
|
try {
|
||||||
aliceSession = new OlmSession();
|
aliceSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=aliceSession.getOlmSessionId());
|
assertTrue(0 != aliceSession.getOlmSessionId());
|
||||||
|
|
||||||
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
|
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
|
||||||
try {
|
try {
|
||||||
|
@ -291,10 +291,10 @@ public class OlmSessionTest {
|
||||||
try {
|
try {
|
||||||
bobSession = new OlmSession();
|
bobSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(0!=bobSession.getOlmSessionId());
|
assertTrue(0 != bobSession.getOlmSessionId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bobSession.initInboundSession(bobAccount, encryptedAliceToBobMsg1.mCipherText);
|
bobSession.initInboundSession(bobAccount, encryptedAliceToBobMsg1.mCipherText);
|
||||||
|
@ -427,12 +427,12 @@ public class OlmSessionTest {
|
||||||
aliceAccount = new OlmAccount();
|
aliceAccount = new OlmAccount();
|
||||||
bobAccount = new OlmAccount();
|
bobAccount = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test accounts creation
|
// test accounts creation
|
||||||
assertTrue(0!=bobAccount.getOlmAccountId());
|
assertTrue(0 != bobAccount.getOlmAccountId());
|
||||||
assertTrue(0!=aliceAccount.getOlmAccountId());
|
assertTrue(0 != aliceAccount.getOlmAccountId());
|
||||||
|
|
||||||
// CREATE ALICE SESSION
|
// CREATE ALICE SESSION
|
||||||
|
|
||||||
|
@ -440,9 +440,9 @@ public class OlmSessionTest {
|
||||||
try {
|
try {
|
||||||
aliceSession = new OlmSession();
|
aliceSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=aliceSession.getOlmSessionId());
|
assertTrue(0 != aliceSession.getOlmSessionId());
|
||||||
|
|
||||||
// CREATE ALICE SESSION
|
// CREATE ALICE SESSION
|
||||||
OlmSession bobSession = null;
|
OlmSession bobSession = null;
|
||||||
|
@ -452,7 +452,7 @@ public class OlmSessionTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=bobSession.getOlmSessionId());
|
assertTrue(0 != bobSession.getOlmSessionId());
|
||||||
|
|
||||||
String aliceSessionId = null;
|
String aliceSessionId = null;
|
||||||
try {
|
try {
|
||||||
|
@ -487,7 +487,7 @@ public class OlmSessionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test04MatchInboundSession() {
|
public void test04MatchInboundSession() {
|
||||||
OlmAccount aliceAccount=null, bobAccount=null;
|
OlmAccount aliceAccount = null, bobAccount = null;
|
||||||
OlmSession aliceSession = null, bobSession = null;
|
OlmSession aliceSession = null, bobSession = null;
|
||||||
|
|
||||||
// ACCOUNTS CREATION
|
// ACCOUNTS CREATION
|
||||||
|
@ -601,6 +601,7 @@ public class OlmSessionTest {
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
// ************* SERIALIZATION TEST ***********************
|
// ************* SERIALIZATION TEST ***********************
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as {@link #test02AliceToBobBackAndForth()}, but alice's session
|
* Same as {@link #test02AliceToBobBackAndForth()}, but alice's session
|
||||||
* is serialized and de-serialized before performing the final
|
* is serialized and de-serialized before performing the final
|
||||||
|
@ -620,12 +621,12 @@ public class OlmSessionTest {
|
||||||
aliceAccount = new OlmAccount();
|
aliceAccount = new OlmAccount();
|
||||||
bobAccount = new OlmAccount();
|
bobAccount = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test accounts creation
|
// test accounts creation
|
||||||
assertTrue(0!=bobAccount.getOlmAccountId());
|
assertTrue(0 != bobAccount.getOlmAccountId());
|
||||||
assertTrue(0!=aliceAccount.getOlmAccountId());
|
assertTrue(0 != aliceAccount.getOlmAccountId());
|
||||||
|
|
||||||
// get bob identity key
|
// get bob identity key
|
||||||
Map<String, String> bobIdentityKeys = null;
|
Map<String, String> bobIdentityKeys = null;
|
||||||
|
@ -637,7 +638,7 @@ public class OlmSessionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
bobIdentityKey = TestHelper.getIdentityKey(bobIdentityKeys);
|
bobIdentityKey = TestHelper.getIdentityKey(bobIdentityKeys);
|
||||||
assertTrue(null!=bobIdentityKey);
|
assertTrue(null != bobIdentityKey);
|
||||||
|
|
||||||
// get bob one time keys
|
// get bob one time keys
|
||||||
try {
|
try {
|
||||||
|
@ -654,7 +655,7 @@ public class OlmSessionTest {
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys,1);
|
bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys, 1);
|
||||||
assertNotNull(bobOneTimeKey);
|
assertNotNull(bobOneTimeKey);
|
||||||
|
|
||||||
// CREATE ALICE SESSION
|
// CREATE ALICE SESSION
|
||||||
|
@ -662,9 +663,9 @@ public class OlmSessionTest {
|
||||||
try {
|
try {
|
||||||
aliceSession = new OlmSession();
|
aliceSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=aliceSession.getOlmSessionId());
|
assertTrue(0 != aliceSession.getOlmSessionId());
|
||||||
|
|
||||||
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
|
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
|
||||||
try {
|
try {
|
||||||
|
@ -689,9 +690,9 @@ public class OlmSessionTest {
|
||||||
try {
|
try {
|
||||||
bobSession = new OlmSession();
|
bobSession = new OlmSession();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(0!=bobSession.getOlmSessionId());
|
assertTrue(0 != bobSession.getOlmSessionId());
|
||||||
|
|
||||||
// init bob session with alice PRE KEY
|
// init bob session with alice PRE KEY
|
||||||
try {
|
try {
|
||||||
|
@ -745,7 +746,7 @@ public class OlmSessionTest {
|
||||||
assertNotNull(encryptedMsg3);
|
assertNotNull(encryptedMsg3);
|
||||||
|
|
||||||
// serialize alice session
|
// serialize alice session
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_SESSION, Context.MODE_PRIVATE);
|
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_SESSION, Context.MODE_PRIVATE);
|
||||||
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
||||||
|
@ -793,23 +794,19 @@ public class OlmSessionTest {
|
||||||
assertTrue(bobSession.isReleased());
|
assertTrue(bobSession.isReleased());
|
||||||
assertTrue(aliceSession.isReleased());
|
assertTrue(aliceSession.isReleased());
|
||||||
assertTrue(aliceSessionDeserial.isReleased());
|
assertTrue(aliceSessionDeserial.isReleased());
|
||||||
}
|
} catch (FileNotFoundException e) {
|
||||||
catch (FileNotFoundException e) {
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg==" + e.getMessage());
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg=="+e.getMessage());
|
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
} catch (ClassNotFoundException e) {
|
||||||
catch (ClassNotFoundException e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
/*catch (OlmException e) {
|
/*catch (OlmException e) {
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception OlmException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception OlmException Msg==" + e.getMessage());
|
||||||
}*/
|
}*/ catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
@ -862,7 +859,7 @@ public class OlmSessionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotNull(bobOneTimeKeys);
|
assertNotNull(bobOneTimeKeys);
|
||||||
String bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys,1);
|
String bobOneTimeKey = TestHelper.getOneTimeKey(bobOneTimeKeys, 1);
|
||||||
assertNotNull(bobOneTimeKey);
|
assertNotNull(bobOneTimeKey);
|
||||||
|
|
||||||
// CREATE ALICE SESSION
|
// CREATE ALICE SESSION
|
||||||
|
@ -922,7 +919,7 @@ public class OlmSessionTest {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertTrue(null==message);
|
assertTrue(null == message);
|
||||||
|
|
||||||
// encrypt properly
|
// encrypt properly
|
||||||
OlmMessage encryptedMsgToBob = null;
|
OlmMessage encryptedMsgToBob = null;
|
||||||
|
@ -974,7 +971,7 @@ public class OlmSessionTest {
|
||||||
|
|
||||||
assertTrue(TextUtils.isEmpty(errorMessage));
|
assertTrue(TextUtils.isEmpty(errorMessage));
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue("Exception Msg="+e.getMessage(), false);
|
assertTrue("Exception Msg=" + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SANITY CHECK TESTS FOR: decryptMessage()
|
// SANITY CHECK TESTS FOR: decryptMessage()
|
||||||
|
@ -985,13 +982,13 @@ public class OlmSessionTest {
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(null==decryptedMsg);
|
assertTrue(null == decryptedMsg);
|
||||||
|
|
||||||
// SANITY CHECK TESTS FOR: matchesInboundSession()
|
// SANITY CHECK TESTS FOR: matchesInboundSession()
|
||||||
assertTrue(!aliceSession.matchesInboundSession(null));
|
assertTrue(!aliceSession.matchesInboundSession(null));
|
||||||
|
|
||||||
// SANITY CHECK TESTS FOR: matchesInboundSessionFrom()
|
// SANITY CHECK TESTS FOR: matchesInboundSessionFrom()
|
||||||
assertTrue(!aliceSession.matchesInboundSessionFrom(null,null));
|
assertTrue(!aliceSession.matchesInboundSessionFrom(null, null));
|
||||||
|
|
||||||
// release objects
|
// release objects
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -43,13 +43,13 @@ public class OlmUtilityTest {
|
||||||
private static OlmManager mOlmManager;
|
private static OlmManager mOlmManager;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass(){
|
public static void setUpClass() {
|
||||||
// load native lib
|
// load native lib
|
||||||
mOlmManager = new OlmManager();
|
mOlmManager = new OlmManager();
|
||||||
|
|
||||||
String version = mOlmManager.getOlmLibVersion();
|
String version = mOlmManager.getOlmLibVersion();
|
||||||
assertNotNull(version);
|
assertNotNull(version);
|
||||||
Log.d(LOG_TAG, "## setUpClass(): lib version="+version);
|
Log.d(LOG_TAG, "## setUpClass(): lib version=" + version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,7 @@ public class OlmUtilityTest {
|
||||||
try {
|
try {
|
||||||
account = new OlmAccount();
|
account = new OlmAccount();
|
||||||
} catch (OlmException e) {
|
} catch (OlmException e) {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
assertNotNull(account);
|
assertNotNull(account);
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class OlmUtilityTest {
|
||||||
|
|
||||||
assertNotNull(identityKeys);
|
assertNotNull(identityKeys);
|
||||||
fingerPrintKey = TestHelper.getFingerprintKey(identityKeys);
|
fingerPrintKey = TestHelper.getFingerprintKey(identityKeys);
|
||||||
assertTrue("fingerprint key missing",!TextUtils.isEmpty(fingerPrintKey));
|
assertTrue("fingerprint key missing", !TextUtils.isEmpty(fingerPrintKey));
|
||||||
|
|
||||||
// instantiate utility object
|
// instantiate utility object
|
||||||
OlmUtility utility = null;
|
OlmUtility utility = null;
|
||||||
|
@ -124,7 +124,7 @@ public class OlmUtilityTest {
|
||||||
assertTrue(!TextUtils.isEmpty(errorMsg));
|
assertTrue(!TextUtils.isEmpty(errorMsg));
|
||||||
|
|
||||||
// check bad fingerprint size => errorMsg = INVALID_BASE64
|
// check bad fingerprint size => errorMsg = INVALID_BASE64
|
||||||
String badSizeFingerPrintKey = fingerPrintKey.substring(fingerPrintKey.length()/2);
|
String badSizeFingerPrintKey = fingerPrintKey.substring(fingerPrintKey.length() / 2);
|
||||||
|
|
||||||
errorMsg = null;
|
errorMsg = null;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue