Fix test compilation
This commit is contained in:
parent
3db82e629b
commit
d0807b9239
|
@ -83,7 +83,7 @@ class XSigningTest : InstrumentedTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun test_CrossSigningCheckBobSeesTheKeys() = runCryptoTest(context()) { cryptoTestHelper, testHelper ->
|
||||
fun test_CrossSigningCheckBobSeesTheKeys() = runCryptoTest(context()) { cryptoTestHelper, _ ->
|
||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
|
|
|
@ -169,13 +169,13 @@ class KeyShareTests : InstrumentedTest {
|
|||
|
||||
aliceSession.cryptoService().setDeviceVerification(
|
||||
DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId,
|
||||
aliceSession2.sessionParams.deviceId ?: ""
|
||||
aliceSession2.sessionParams.deviceId
|
||||
)
|
||||
|
||||
// We only accept forwards from trusted session, so we need to trust on other side to
|
||||
aliceSession2.cryptoService().setDeviceVerification(
|
||||
DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId,
|
||||
aliceSession.sessionParams.deviceId ?: ""
|
||||
aliceSession.sessionParams.deviceId
|
||||
)
|
||||
|
||||
aliceSession.cryptoService().deviceWithIdentityKey(
|
||||
|
@ -335,10 +335,10 @@ class KeyShareTests : InstrumentedTest {
|
|||
// Mark the new session as verified
|
||||
aliceSession.cryptoService()
|
||||
.verificationService()
|
||||
.markedLocallyAsManuallyVerified(aliceNewSession.myUserId, aliceNewSession.sessionParams.deviceId!!)
|
||||
.markedLocallyAsManuallyVerified(aliceNewSession.myUserId, aliceNewSession.sessionParams.deviceId)
|
||||
aliceNewSession.cryptoService()
|
||||
.verificationService()
|
||||
.markedLocallyAsManuallyVerified(aliceSession.myUserId, aliceSession.sessionParams.deviceId!!)
|
||||
.markedLocallyAsManuallyVerified(aliceSession.myUserId, aliceSession.sessionParams.deviceId)
|
||||
|
||||
// Let's now try to request
|
||||
aliceNewSession.cryptoService().reRequestRoomKeyForEvent(sentEvents.first().root)
|
||||
|
@ -420,10 +420,10 @@ class KeyShareTests : InstrumentedTest {
|
|||
// Mark the new session as verified
|
||||
aliceSession.cryptoService()
|
||||
.verificationService()
|
||||
.markedLocallyAsManuallyVerified(aliceNewSession.myUserId, aliceNewSession.sessionParams.deviceId!!)
|
||||
.markedLocallyAsManuallyVerified(aliceNewSession.myUserId, aliceNewSession.sessionParams.deviceId)
|
||||
aliceNewSession.cryptoService()
|
||||
.verificationService()
|
||||
.markedLocallyAsManuallyVerified(aliceSession.myUserId, aliceSession.sessionParams.deviceId!!)
|
||||
.markedLocallyAsManuallyVerified(aliceSession.myUserId, aliceSession.sessionParams.deviceId)
|
||||
|
||||
// /!\ Stop initial alice session syncing so that it can't reply
|
||||
aliceSession.cryptoService().enableKeyGossiping(false)
|
||||
|
|
|
@ -16,19 +16,13 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.crypto.verification
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.EVerificationState
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificationRequest
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.common.CommonTestHelper
|
||||
import org.matrix.android.sdk.common.CryptoTestData
|
||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
class SasVerificationTestHelper(private val testHelper: CommonTestHelper, private val cryptoTestHelper: CryptoTestHelper) {
|
||||
class SasVerificationTestHelper(private val testHelper: CommonTestHelper) {
|
||||
suspend fun requestVerificationAndWaitForReadyState(cryptoTestData: CryptoTestData, supportedMethods: List<VerificationMethod>): String {
|
||||
val aliceSession = cryptoTestData.firstSession
|
||||
val bobSession = cryptoTestData.secondSession!!
|
||||
|
@ -36,93 +30,63 @@ class SasVerificationTestHelper(private val testHelper: CommonTestHelper, privat
|
|||
val aliceVerificationService = aliceSession.cryptoService().verificationService()
|
||||
val bobVerificationService = bobSession.cryptoService().verificationService()
|
||||
|
||||
var bobReadyPendingVerificationRequest: PendingVerificationRequest? = null
|
||||
|
||||
val latch = CountDownLatch(2)
|
||||
val aliceListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
// Step 4: Alice receive the ready request
|
||||
Timber.v("Alice request updated: $pr")
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
}
|
||||
// aliceVerificationService.addListener(aliceListener)
|
||||
|
||||
val bobListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestCreated(pr: PendingVerificationRequest) {
|
||||
// Step 2: Bob accepts the verification request
|
||||
Timber.v("Bob accepts the verification request")
|
||||
runBlocking {
|
||||
bobVerificationService.readyPendingVerification(
|
||||
supportedMethods,
|
||||
aliceSession.myUserId,
|
||||
pr.transactionId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
// Step 3: Bob is ready
|
||||
Timber.v("Bob request updated $pr")
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
bobReadyPendingVerificationRequest = pr
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
}
|
||||
// bobVerificationService.addListener(bobListener)
|
||||
|
||||
val bobUserId = bobSession.myUserId
|
||||
// Step 1: Alice starts a verification request
|
||||
aliceVerificationService.requestKeyVerificationInDMs(supportedMethods, bobUserId, cryptoTestData.roomId)
|
||||
testHelper.await(latch)
|
||||
// bobVerificationService.removeListener(bobListener)
|
||||
// aliceVerificationService.removeListener(aliceListener)
|
||||
return bobReadyPendingVerificationRequest?.transactionId!!
|
||||
val transactionId = aliceVerificationService.requestKeyVerificationInDMs(
|
||||
supportedMethods, bobUserId, cryptoTestData.roomId
|
||||
)
|
||||
.transactionId
|
||||
|
||||
testHelper.retryPeriodically {
|
||||
val incomingRequest = bobVerificationService.getExistingVerificationRequest(aliceSession.myUserId, transactionId)
|
||||
if (incomingRequest != null) {
|
||||
bobVerificationService.readyPendingVerification(
|
||||
supportedMethods,
|
||||
aliceSession.myUserId,
|
||||
incomingRequest.transactionId
|
||||
)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// wait for alice to see the ready
|
||||
testHelper.retryPeriodically {
|
||||
val pendingRequest = aliceVerificationService.getExistingVerificationRequest(bobUserId, transactionId)
|
||||
pendingRequest?.state == EVerificationState.Ready
|
||||
}
|
||||
|
||||
return transactionId
|
||||
}
|
||||
|
||||
suspend fun requestSelfKeyAndWaitForReadyState(session1: Session, session2: Session, supportedMethods: List<VerificationMethod>): String {
|
||||
val session1VerificationService = session1.cryptoService().verificationService()
|
||||
val session2VerificationService = session2.cryptoService().verificationService()
|
||||
var bobReadyPendingVerificationRequest: PendingVerificationRequest? = null
|
||||
|
||||
val latch = CountDownLatch(2)
|
||||
val aliceListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
latch.countDown()
|
||||
}
|
||||
val requestID = session1VerificationService.requestSelfKeyVerification(supportedMethods).transactionId
|
||||
|
||||
val myUserId = session1.myUserId
|
||||
testHelper.retryPeriodically {
|
||||
val incomingRequest = session2VerificationService.getExistingVerificationRequest(myUserId, requestID)
|
||||
if (incomingRequest != null) {
|
||||
session2VerificationService.readyPendingVerification(
|
||||
supportedMethods,
|
||||
myUserId,
|
||||
incomingRequest.transactionId
|
||||
)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// session1VerificationService.addListener(aliceListener)
|
||||
|
||||
val bobListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestCreated(pr: PendingVerificationRequest) {
|
||||
runBlocking {
|
||||
session2VerificationService.readyPendingVerification(
|
||||
supportedMethods,
|
||||
session1.myUserId,
|
||||
pr.transactionId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
Timber.v("Bob request updated $pr")
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
bobReadyPendingVerificationRequest = pr
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
// wait for alice to see the ready
|
||||
testHelper.retryPeriodically {
|
||||
val pendingRequest = session1VerificationService.getExistingVerificationRequest(myUserId, requestID)
|
||||
pendingRequest?.state == EVerificationState.Ready
|
||||
}
|
||||
// session2VerificationService.addListener(bobListener)
|
||||
session1VerificationService.requestSelfKeyVerification(supportedMethods)
|
||||
|
||||
testHelper.await(latch)
|
||||
// session2VerificationService.removeListener(bobListener)
|
||||
// session1VerificationService.removeListener(aliceListener)
|
||||
return bobReadyPendingVerificationRequest?.transactionId!!
|
||||
return requestID
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.matrix.android.sdk.internal.crypto.verification
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.amshove.kluent.shouldBe
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
|
@ -25,12 +24,8 @@ import org.junit.runner.RunWith
|
|||
import org.junit.runners.MethodSorters
|
||||
import org.matrix.android.sdk.InstrumentedTest
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.EVerificationState
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificationRequest
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.common.CommonTestHelper.Companion.runCryptoTest
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.JVM)
|
||||
|
@ -159,58 +154,41 @@ class VerificationTest : InstrumentedTest {
|
|||
val aliceVerificationService = aliceSession.cryptoService().verificationService()
|
||||
val bobVerificationService = bobSession.cryptoService().verificationService()
|
||||
|
||||
var aliceReadyPendingVerificationRequest: PendingVerificationRequest? = null
|
||||
var bobReadyPendingVerificationRequest: PendingVerificationRequest? = null
|
||||
val transactionId = aliceVerificationService.requestKeyVerificationInDMs(
|
||||
aliceSupportedMethods, bobSession.myUserId, cryptoTestData.roomId
|
||||
)
|
||||
.transactionId
|
||||
|
||||
val latch = CountDownLatch(2)
|
||||
val aliceListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
// Step 4: Alice receive the ready request
|
||||
Timber.v("Alice is ready: ${pr.state}")
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
aliceReadyPendingVerificationRequest = pr
|
||||
latch.countDown()
|
||||
}
|
||||
testHelper.retryPeriodically {
|
||||
val incomingRequest = bobVerificationService.getExistingVerificationRequest(aliceSession.myUserId, transactionId)
|
||||
if (incomingRequest != null) {
|
||||
bobVerificationService.readyPendingVerification(
|
||||
bobSupportedMethods,
|
||||
aliceSession.myUserId,
|
||||
incomingRequest.transactionId
|
||||
)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// aliceVerificationService.addListener(aliceListener)
|
||||
|
||||
val bobListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestCreated(pr: PendingVerificationRequest) {
|
||||
// Step 2: Bob accepts the verification request
|
||||
Timber.v("Bob accepts the verification request")
|
||||
runBlocking {
|
||||
bobVerificationService.readyPendingVerification(
|
||||
bobSupportedMethods,
|
||||
aliceSession.myUserId,
|
||||
pr.transactionId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
// Step 3: Bob is ready
|
||||
Timber.v("Bob is ready: ${pr.state}")
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
bobReadyPendingVerificationRequest = pr
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
// wait for alice to see the ready
|
||||
testHelper.retryPeriodically {
|
||||
val pendingRequest = aliceVerificationService.getExistingVerificationRequest(bobSession.myUserId, transactionId)
|
||||
pendingRequest?.state == EVerificationState.Ready
|
||||
}
|
||||
// bobVerificationService.addListener(bobListener)
|
||||
|
||||
val bobUserId = bobSession.myUserId
|
||||
// Step 1: Alice starts a verification request
|
||||
aliceVerificationService.requestKeyVerificationInDMs(aliceSupportedMethods, bobUserId, cryptoTestData.roomId)
|
||||
testHelper.await(latch)
|
||||
val aliceReadyPendingVerificationRequest = aliceVerificationService.getExistingVerificationRequest(bobSession.myUserId, transactionId)!!
|
||||
val bobReadyPendingVerificationRequest = bobVerificationService.getExistingVerificationRequest(aliceSession.myUserId, transactionId)!!
|
||||
|
||||
aliceReadyPendingVerificationRequest!!.let { pr ->
|
||||
aliceReadyPendingVerificationRequest.let { pr ->
|
||||
pr.isSasSupported shouldBe expectedResultForAlice.sasIsSupported
|
||||
pr.weShouldShowScanOption shouldBe expectedResultForAlice.otherCanShowQrCode
|
||||
pr.weShouldDisplayQRCode shouldBe expectedResultForAlice.otherCanScanQrCode
|
||||
}
|
||||
|
||||
bobReadyPendingVerificationRequest!!.let { pr ->
|
||||
bobReadyPendingVerificationRequest.let { pr ->
|
||||
pr.isSasSupported shouldBe expectedResultForBob.sasIsSupported
|
||||
pr.weShouldShowScanOption shouldBe expectedResultForBob.otherCanShowQrCode
|
||||
pr.weShouldDisplayQRCode shouldBe expectedResultForBob.otherCanScanQrCode
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto.verification.qrcode
|
|||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.amshove.kluent.shouldBe
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Ignore
|
||||
|
@ -33,15 +32,12 @@ import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
|||
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.EVerificationState
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificationRequest
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationEvent
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.common.CommonTestHelper.Companion.runCryptoTest
|
||||
import org.matrix.android.sdk.common.CommonTestHelper.Companion.runSessionTest
|
||||
import org.matrix.android.sdk.common.SessionTestParams
|
||||
import org.matrix.android.sdk.common.TestConstants
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
|
@ -202,55 +198,41 @@ class VerificationTest : InstrumentedTest {
|
|||
val aliceVerificationService = aliceSession.cryptoService().verificationService()
|
||||
val bobVerificationService = bobSession.cryptoService().verificationService()
|
||||
|
||||
var aliceReadyPendingVerificationRequest: PendingVerificationRequest? = null
|
||||
var bobReadyPendingVerificationRequest: PendingVerificationRequest? = null
|
||||
val transactionId = aliceVerificationService.requestKeyVerificationInDMs(
|
||||
aliceSupportedMethods, bobSession.myUserId, cryptoTestData.roomId
|
||||
)
|
||||
.transactionId
|
||||
|
||||
val latch = CountDownLatch(2)
|
||||
val aliceListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
// Step 4: Alice receive the ready request
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
aliceReadyPendingVerificationRequest = pr
|
||||
latch.countDown()
|
||||
}
|
||||
testHelper.retryPeriodically {
|
||||
val incomingRequest = bobVerificationService.getExistingVerificationRequest(aliceSession.myUserId, transactionId)
|
||||
if (incomingRequest != null) {
|
||||
bobVerificationService.readyPendingVerification(
|
||||
bobSupportedMethods,
|
||||
aliceSession.myUserId,
|
||||
incomingRequest.transactionId
|
||||
)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// aliceVerificationService.addListener(aliceListener)
|
||||
|
||||
val bobListener = object : VerificationService.Listener {
|
||||
override fun verificationRequestCreated(pr: PendingVerificationRequest) {
|
||||
// Step 2: Bob accepts the verification request
|
||||
runBlocking {
|
||||
bobVerificationService.readyPendingVerification(
|
||||
bobSupportedMethods,
|
||||
aliceSession.myUserId,
|
||||
pr.transactionId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
|
||||
// Step 3: Bob is ready
|
||||
if (pr.state == EVerificationState.Ready) {
|
||||
bobReadyPendingVerificationRequest = pr
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
// wait for alice to see the ready
|
||||
testHelper.retryPeriodically {
|
||||
val pendingRequest = aliceVerificationService.getExistingVerificationRequest(bobSession.myUserId, transactionId)
|
||||
pendingRequest?.state == EVerificationState.Ready
|
||||
}
|
||||
// bobVerificationService.addListener(bobListener)
|
||||
|
||||
val bobUserId = bobSession.myUserId
|
||||
// Step 1: Alice starts a verification request
|
||||
aliceVerificationService.requestKeyVerificationInDMs(aliceSupportedMethods, bobUserId, cryptoTestData.roomId)
|
||||
testHelper.await(latch)
|
||||
val aliceReadyPendingVerificationRequest = aliceVerificationService.getExistingVerificationRequest(bobSession.myUserId, transactionId)!!
|
||||
val bobReadyPendingVerificationRequest = bobVerificationService.getExistingVerificationRequest(aliceSession.myUserId, transactionId)!!
|
||||
|
||||
aliceReadyPendingVerificationRequest!!.let { pr ->
|
||||
aliceReadyPendingVerificationRequest.let { pr ->
|
||||
pr.isSasSupported shouldBe expectedResultForAlice.sasIsSupported
|
||||
pr.weShouldShowScanOption shouldBe expectedResultForAlice.otherCanShowQrCode
|
||||
pr.weShouldDisplayQRCode shouldBe expectedResultForAlice.otherCanScanQrCode
|
||||
}
|
||||
|
||||
bobReadyPendingVerificationRequest!!.let { pr ->
|
||||
bobReadyPendingVerificationRequest.let { pr ->
|
||||
pr.isSasSupported shouldBe expectedResultForBob.sasIsSupported
|
||||
pr.weShouldShowScanOption shouldBe expectedResultForBob.otherCanShowQrCode
|
||||
pr.weShouldDisplayQRCode shouldBe expectedResultForBob.otherCanScanQrCode
|
||||
|
@ -284,7 +266,7 @@ class VerificationTest : InstrumentedTest {
|
|||
serviceOfVerifier.readyPendingVerification(
|
||||
verificationMethods,
|
||||
pr.otherUserId,
|
||||
pr.transactionId!!,
|
||||
pr.transactionId,
|
||||
)
|
||||
job?.cancel()
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class PreShareKeysTest : InstrumentedTest {
|
|||
val aliceOutboundSessionInRoom = aliceCryptoStore.getCurrentOutboundGroupSessionForRoom(e2eRoomID)!!.outboundGroupSession.sessionIdentifier()
|
||||
|
||||
val bobCryptoStore = (bobSession.cryptoService() as DefaultCryptoService).cryptoStoreForTesting
|
||||
val aliceDeviceBobPov = bobCryptoStore.getUserDevice(aliceSession.myUserId, aliceSession.sessionParams.deviceId!!)!!
|
||||
val aliceDeviceBobPov = bobCryptoStore.getUserDevice(aliceSession.myUserId, aliceSession.sessionParams.deviceId)!!
|
||||
val bobInboundForAlice = bobCryptoStore.getInboundGroupSession(aliceOutboundSessionInRoom, aliceDeviceBobPov.identityKey()!!)
|
||||
assertNotNull("Bob should have received and decrypted a room key event from alice", bobInboundForAlice)
|
||||
assertEquals("Wrong room", e2eRoomID, bobInboundForAlice!!.roomId)
|
||||
|
|
|
@ -16,38 +16,12 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.crypto.verification
|
||||
|
||||
import android.util.Log
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
import org.matrix.android.sdk.InstrumentedTest
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.EVerificationState
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificationRequest
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.SasTransactionState
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.common.CommonTestHelper.Companion.runCryptoTest
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.toValue
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
|
|
|
@ -21,7 +21,6 @@ import kotlinx.coroutines.channels.Channel
|
|||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentation
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.SasMode
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.SasTransactionState
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction.Companion.KEY_AGREEMENT_V1
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
package org.matrix.android.sdk.internal.session
|
||||
|
||||
import io.realm.RealmConfiguration
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
|
||||
class MigrateEAtoEROperation {
|
||||
|
||||
fun execute(cryptoRealm: RealmConfiguration, sessionFilesDir: File): File {
|
||||
Timber.v("Not used in kotlin crypto $cryptoRealm")
|
||||
// no op in kotlinCrypto
|
||||
return sessionFilesDir
|
||||
}
|
||||
|
|
|
@ -35,10 +35,7 @@ import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_S
|
|||
import org.matrix.android.sdk.api.session.crypto.crosssigning.MASTER_KEY_SSSS_NAME
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.SELF_SIGNING_KEY_SSSS_NAME
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.USER_SIGNING_KEY_SSSS_NAME
|
||||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||
import org.matrix.android.sdk.api.util.awaitCallback
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
|
|
|
@ -157,8 +157,7 @@ internal class RealmCryptoStore @Inject constructor(
|
|||
// Check credentials
|
||||
// The device id may not have been provided in credentials.
|
||||
// Check it only if provided, else trust the stored one.
|
||||
if (currentMetadata.userId != userId ||
|
||||
(deviceId != null && deviceId != currentMetadata.deviceId)) {
|
||||
if (currentMetadata.userId != userId || deviceId != currentMetadata.deviceId) {
|
||||
Timber.w("## open() : Credentials do not match, close this store and delete data")
|
||||
deleteAll = true
|
||||
currentMetadata = null
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
package im.vector.app.features.home.room.list.home
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomSummaryRoomListDiffCallback @Inject constructor(
|
||||
vectorPreferences: VectorPreferences
|
||||
// vectorPreferences: VectorPreferences
|
||||
) : DiffUtil.ItemCallback<RoomSummary>() {
|
||||
|
||||
override fun areItemsTheSame(oldItem: RoomSummary, newItem: RoomSummary): Boolean {
|
||||
|
|
|
@ -29,7 +29,7 @@ class DeleteNotificationSettingsAccountDataUseCase @Inject constructor(
|
|||
) {
|
||||
|
||||
suspend fun execute(session: Session) {
|
||||
val deviceId = session.sessionParams.deviceId ?: return
|
||||
val deviceId = session.sessionParams.deviceId
|
||||
if (getNotificationSettingsAccountDataUseCase.execute(session, deviceId)?.isSilenced != null) {
|
||||
val emptyNotificationSettingsContent = LocalNotificationSettingsContent(
|
||||
isSilenced = null
|
||||
|
|
|
@ -43,7 +43,7 @@ class UpdateNotificationSettingsAccountDataUseCase @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun setCurrentNotificationStatus(session: Session) {
|
||||
val deviceId = session.sessionParams.deviceId ?: return
|
||||
val deviceId = session.sessionParams.deviceId
|
||||
val areNotificationsSilenced = !vectorPreferences.areNotificationEnabledForDevice()
|
||||
val isSilencedAccountData = getNotificationSettingsAccountDataUseCase.execute(session, deviceId)?.isSilenced
|
||||
if (areNotificationsSilenced != isSilencedAccountData) {
|
||||
|
|
|
@ -35,7 +35,7 @@ class ToggleNotificationsForCurrentSessionUseCase @Inject constructor(
|
|||
|
||||
suspend fun execute(enabled: Boolean) {
|
||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
val deviceId = session.sessionParams.deviceId ?: return
|
||||
val deviceId = session.sessionParams.deviceId
|
||||
|
||||
if (unifiedPushHelper.isBackgroundSync()) {
|
||||
Timber.d("background sync is enabled, setting account data event")
|
||||
|
|
Loading…
Reference in New Issue