use withTestHelpers in sanity tests
This commit is contained in:
parent
e18402f834
commit
29ff4d1e84
44
matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeSanityTests.kt
44
matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeSanityTests.kt
@ -84,9 +84,8 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
* Alice sends a new message, then check that the new one can be decrypted
|
* Alice sends a new message, then check that the new one can be decrypted
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testSendingE2EEMessages() {
|
fun testSendingE2EEMessages() = withTestHelpers(context()) { cryptoTestHelper ->
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = cryptoTestHelper.testHelper
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
|
||||||
|
|
||||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
@ -200,13 +199,6 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
otherAccounts.forEach {
|
|
||||||
testHelper.signOutAndClose(it)
|
|
||||||
}
|
|
||||||
newAccount.forEach { testHelper.signOutAndClose(it) }
|
|
||||||
|
|
||||||
cryptoTestData.cleanUp(testHelper)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -232,9 +224,8 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
* 9. Check that new session can decrypt
|
* 9. Check that new session can decrypt
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testBasicBackupImport() {
|
fun testBasicBackupImport() = withTestHelpers(context()) { cryptoTestHelper ->
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = cryptoTestHelper.testHelper
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
|
||||||
|
|
||||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
@ -346,8 +337,6 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
|
|
||||||
// ensure bob can now decrypt
|
// ensure bob can now decrypt
|
||||||
cryptoTestHelper.ensureCanDecrypt(sentEventIds, newBobSession, e2eRoomID, messagesText)
|
cryptoTestHelper.ensureCanDecrypt(sentEventIds, newBobSession, e2eRoomID, messagesText)
|
||||||
|
|
||||||
testHelper.signOutAndClose(newBobSession)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -355,9 +344,8 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
* get them from an older one.
|
* get them from an older one.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testSimpleGossip() {
|
fun testSimpleGossip() = withTestHelpers(context()) { cryptoTestHelper ->
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = cryptoTestHelper.testHelper
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
|
||||||
|
|
||||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
@ -451,18 +439,14 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cryptoTestHelper.ensureCanDecrypt(sentEventIds, newBobSession, e2eRoomID, messagesText)
|
cryptoTestHelper.ensureCanDecrypt(sentEventIds, newBobSession, e2eRoomID, messagesText)
|
||||||
|
|
||||||
cryptoTestData.cleanUp(testHelper)
|
|
||||||
testHelper.signOutAndClose(newBobSession)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that if a better key is forwarded (lower index, it is then used)
|
* Test that if a better key is forwarded (lower index, it is then used)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testForwardBetterKey() {
|
fun testForwardBetterKey() = withTestHelpers(context()) { cryptoTestHelper ->
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = cryptoTestHelper.testHelper
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
|
||||||
|
|
||||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom(true)
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
@ -578,10 +562,6 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
canDecryptFirst && canDecryptSecond
|
canDecryptFirst && canDecryptSecond
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testHelper.signOutAndClose(aliceSession)
|
|
||||||
testHelper.signOutAndClose(bobSessionWithBetterKey)
|
|
||||||
testHelper.signOutAndClose(newBobSession)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendMessageInRoom(testHelper: CommonTestHelper, aliceRoomPOV: Room, text: String): String? {
|
private fun sendMessageInRoom(testHelper: CommonTestHelper, aliceRoomPOV: Room, text: String): String? {
|
||||||
@ -612,9 +592,8 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
* Test that if a better key is forwared (lower index, it is then used)
|
* Test that if a better key is forwared (lower index, it is then used)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun testSelfInteractiveVerificationAndGossip() {
|
fun testASelfInteractiveVerificationAndGossip() = withTestHelpers(context()) { cryptoTestHelper ->
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = cryptoTestHelper.testHelper
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
|
||||||
|
|
||||||
val aliceSession = testHelper.createAccount("alice", SessionTestParams(true))
|
val aliceSession = testHelper.createAccount("alice", SessionTestParams(true))
|
||||||
cryptoTestHelper.bootstrapSecurity(aliceSession)
|
cryptoTestHelper.bootstrapSecurity(aliceSession)
|
||||||
@ -753,9 +732,6 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
aliceSession.cryptoService().keysBackupService().getKeyBackupRecoveryKeyInfo()!!.version,
|
aliceSession.cryptoService().keysBackupService().getKeyBackupRecoveryKeyInfo()!!.version,
|
||||||
aliceNewSession.cryptoService().keysBackupService().getKeyBackupRecoveryKeyInfo()!!.version
|
aliceNewSession.cryptoService().keysBackupService().getKeyBackupRecoveryKeyInfo()!!.version
|
||||||
)
|
)
|
||||||
|
|
||||||
testHelper.signOutAndClose(aliceSession)
|
|
||||||
testHelper.signOutAndClose(aliceNewSession)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ensureMembersHaveJoined(testHelper: CommonTestHelper, aliceSession: Session, otherAccounts: List<Session>, e2eRoomID: String) {
|
private fun ensureMembersHaveJoined(testHelper: CommonTestHelper, aliceSession: Session, otherAccounts: List<Session>, e2eRoomID: String) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user