mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-29 15:40:55 +08:00
Fix some more E2EE tests
This commit is contained in:
parent
c1961d1fda
commit
705788394b
@ -35,4 +35,11 @@ data class CryptoTestData(val roomId: String,
|
||||
testHelper.signOutAndClose(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun initializeCrossSigning(testHelper: CryptoTestHelper){
|
||||
sessions.forEach {
|
||||
testHelper.initializeCrossSigning(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -264,7 +264,8 @@ class E2eeSanityTests : InstrumentedTest {
|
||||
}
|
||||
}
|
||||
// after initial sync events are not decrypted, so we have to try manually
|
||||
cryptoTestHelper.ensureCannotDecrypt(sentEventIds, newBobSession, e2eRoomID, MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID)
|
||||
// TODO CHANGE WHEN AVAILABLE FROM RUST
|
||||
cryptoTestHelper.ensureCannotDecrypt(sentEventIds, newBobSession, e2eRoomID, MXCryptoError.ErrorType.UNABLE_TO_DECRYPT)//MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID)
|
||||
|
||||
// Let's now import keys from backup
|
||||
|
||||
|
@ -123,7 +123,7 @@ class XSigningTest : InstrumentedTest {
|
||||
}
|
||||
|
||||
// Check that alice can see bob keys
|
||||
testHelper.runBlockingTest { aliceSession.cryptoService().downloadKeys(listOf(bobSession.myUserId), true) }
|
||||
testHelper.runBlockingTest { aliceSession.cryptoService().downloadKeysIfNeeded(listOf(bobSession.myUserId), true) }
|
||||
|
||||
val bobKeysFromAlicePOV = testHelper.runBlockingTest {
|
||||
aliceSession.cryptoService().crossSigningService().getUserCrossSigningKeys(bobSession.myUserId)
|
||||
@ -178,7 +178,7 @@ class XSigningTest : InstrumentedTest {
|
||||
|
||||
// Check that alice can see bob keys
|
||||
val bobUserId = bobSession.myUserId
|
||||
testHelper.runBlockingTest { aliceSession.cryptoService().downloadKeys(listOf(bobUserId), true) }
|
||||
testHelper.runBlockingTest { aliceSession.cryptoService().downloadKeysIfNeeded(listOf(bobUserId), true) }
|
||||
|
||||
val bobKeysFromAlicePOV = testHelper.runBlockingTest {
|
||||
aliceSession.cryptoService().crossSigningService().getUserCrossSigningKeys(bobUserId)
|
||||
@ -197,7 +197,7 @@ class XSigningTest : InstrumentedTest {
|
||||
|
||||
// Check that bob first session sees the new login
|
||||
val data = testHelper.runBlockingTest {
|
||||
bobSession.cryptoService().downloadKeys(listOf(bobUserId), true)
|
||||
bobSession.cryptoService().downloadKeysIfNeeded(listOf(bobUserId), true)
|
||||
}
|
||||
|
||||
if (data.getUserDeviceIds(bobUserId)?.contains(bobSecondDeviceId) == false) {
|
||||
@ -216,7 +216,7 @@ class XSigningTest : InstrumentedTest {
|
||||
|
||||
// Now alice should cross trust bob's second device
|
||||
val data2 = testHelper.runBlockingTest {
|
||||
aliceSession.cryptoService().downloadKeys(listOf(bobUserId), true)
|
||||
aliceSession.cryptoService().downloadKeysIfNeeded(listOf(bobUserId), true)
|
||||
}
|
||||
|
||||
// check that the device is seen
|
||||
|
@ -243,10 +243,10 @@ class KeyShareTests : InstrumentedTest {
|
||||
|
||||
// force keys download
|
||||
commonTestHelper.runBlockingTest {
|
||||
aliceSession1.cryptoService().downloadKeys(listOf(aliceSession1.myUserId), true)
|
||||
aliceSession1.cryptoService().downloadKeysIfNeeded(listOf(aliceSession1.myUserId), true)
|
||||
}
|
||||
commonTestHelper.runBlockingTest {
|
||||
aliceSession2.cryptoService().downloadKeys(listOf(aliceSession2.myUserId), true)
|
||||
aliceSession2.cryptoService().downloadKeysIfNeeded(listOf(aliceSession2.myUserId), true)
|
||||
}
|
||||
|
||||
var session1ShortCode: String? = null
|
||||
|
@ -55,7 +55,7 @@ class SASTest : InstrumentedTest {
|
||||
val testHelper = CommonTestHelper(context())
|
||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||
|
||||
cryptoTestData.initializeCrossSigning(cryptoTestHelper)
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
val bobSession = cryptoTestData.secondSession
|
||||
|
||||
@ -74,7 +74,7 @@ class SASTest : InstrumentedTest {
|
||||
bobSession.cryptoService().getMyCryptoDevice()
|
||||
}
|
||||
val txID = testHelper.runBlockingTest {
|
||||
aliceSession.cryptoService().downloadKeys(listOf(bobSession.myUserId), forceDownload = true)
|
||||
aliceSession.cryptoService().downloadKeysIfNeeded(listOf(bobSession.myUserId), forceDownload = true)
|
||||
aliceVerificationService.beginDeviceVerification(bobSession.myUserId, bobDevice.deviceId)
|
||||
}
|
||||
assertNotNull("Alice should have a started transaction", txID)
|
||||
@ -357,7 +357,7 @@ class SASTest : InstrumentedTest {
|
||||
bobSession.cryptoService().getMyCryptoDevice().deviceId
|
||||
}
|
||||
testHelper.runBlockingTest {
|
||||
aliceSession.cryptoService().downloadKeys(listOf(bobUserId), forceDownload = true)
|
||||
aliceSession.cryptoService().downloadKeysIfNeeded(listOf(bobUserId), forceDownload = true)
|
||||
aliceVerificationService.beginDeviceVerification(bobUserId, bobDeviceId)
|
||||
aliceVerificationService.beginDeviceVerification(bobUserId, bobDeviceId)
|
||||
}
|
||||
@ -423,6 +423,7 @@ class SASTest : InstrumentedTest {
|
||||
val testHelper = CommonTestHelper(context())
|
||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||
cryptoTestData.initializeCrossSigning(cryptoTestHelper)
|
||||
val sasTestHelper = SasVerificationTestHelper(testHelper, cryptoTestHelper)
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
val bobSession = cryptoTestData.secondSession!!
|
||||
@ -461,6 +462,7 @@ class SASTest : InstrumentedTest {
|
||||
val testHelper = CommonTestHelper(context())
|
||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||
cryptoTestData.initializeCrossSigning(cryptoTestHelper)
|
||||
val sasVerificationTestHelper = SasVerificationTestHelper(testHelper, cryptoTestHelper)
|
||||
val transactionId = sasVerificationTestHelper.requestVerificationAndWaitForReadyState(cryptoTestData, listOf(VerificationMethod.SAS))
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
@ -566,12 +568,9 @@ class SASTest : InstrumentedTest {
|
||||
val testHelper = CommonTestHelper(context())
|
||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||
|
||||
cryptoTestData.initializeCrossSigning(cryptoTestHelper)
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
val bobSession = cryptoTestData.secondSession
|
||||
|
||||
cryptoTestHelper.initializeCrossSigning(aliceSession)
|
||||
cryptoTestHelper.initializeCrossSigning(bobSession!!)
|
||||
val bobSession = cryptoTestData.secondSession!!
|
||||
|
||||
val aliceVerificationService = aliceSession.cryptoService().verificationService()
|
||||
val bobVerificationService = bobSession.cryptoService().verificationService()
|
||||
|
@ -30,8 +30,6 @@ class SasVerificationTestHelper(private val testHelper: CommonTestHelper, privat
|
||||
fun requestVerificationAndWaitForReadyState(cryptoTestData: CryptoTestData, supportedMethods: List<VerificationMethod>): String {
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
val bobSession = cryptoTestData.secondSession!!
|
||||
cryptoTestHelper.initializeCrossSigning(aliceSession)
|
||||
cryptoTestHelper.initializeCrossSigning(bobSession)
|
||||
|
||||
val aliceVerificationService = aliceSession.cryptoService().verificationService()
|
||||
val bobVerificationService = bobSession.cryptoService().verificationService()
|
||||
|
Loading…
Reference in New Issue
Block a user