From d0807b923993f57acf0701a9439960059167ff7f Mon Sep 17 00:00:00 2001 From: valere Date: Tue, 13 Dec 2022 11:50:06 +0100 Subject: [PATCH] Fix test compilation --- .../crypto/crosssigning/XSigningTest.kt | 2 +- .../crypto/gossiping/KeyShareTests.kt | 12 +- .../verification/SasVerificationTestHelper.kt | 128 +++++++----------- .../crypto/verification/VerificationTest.kt | 68 ++++------ .../verification/qrcode/VerificationTest.kt | 66 ++++----- .../sdk/internal/crypto/PreShareKeysTest.kt | 2 +- .../internal/crypto/verification/SASTest.kt | 26 ---- .../verification/KotlinSasTransaction.kt | 1 - .../session/MigrateEAtoEROperation.kt | 2 + .../android/sdk/api/rendezvous/Rendezvous.kt | 3 - .../crypto/store/db/RealmCryptoStore.kt | 3 +- .../home/RoomSummaryRoomListDiffCallback.kt | 3 +- ...eNotificationSettingsAccountDataUseCase.kt | 2 +- ...eNotificationSettingsAccountDataUseCase.kt | 2 +- ...leNotificationsForCurrentSessionUseCase.kt | 2 +- 15 files changed, 108 insertions(+), 214 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/crosssigning/XSigningTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/crosssigning/XSigningTest.kt index 304752f587..aafecc9a62 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/crosssigning/XSigningTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/crosssigning/XSigningTest.kt @@ -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 diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt index 1baff220d2..314dbf811d 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt @@ -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) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SasVerificationTestHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SasVerificationTestHelper.kt index af65361bcc..eea2ed35a9 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SasVerificationTestHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SasVerificationTestHelper.kt @@ -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): 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): 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 } } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/VerificationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/VerificationTest.kt index 4c80808073..19219d5cd0 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/VerificationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/VerificationTest.kt @@ -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 diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt index ffb16ab080..50b6678b2b 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt @@ -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() } diff --git a/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt b/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt index e3053f489e..6a24de07ae 100644 --- a/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt +++ b/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt @@ -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) diff --git a/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt index 1b51886735..7fbce118c6 100644 --- a/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt +++ b/matrix-sdk-android/src/androidTestKotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt @@ -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) diff --git a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/KotlinSasTransaction.kt b/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/KotlinSasTransaction.kt index 4bbe2f3e40..fe6d895a93 100644 --- a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/KotlinSasTransaction.kt +++ b/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/verification/KotlinSasTransaction.kt @@ -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 diff --git a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/session/MigrateEAtoEROperation.kt b/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/session/MigrateEAtoEROperation.kt index 0b76b2518a..c17f2e8dca 100644 --- a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/session/MigrateEAtoEROperation.kt +++ b/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/session/MigrateEAtoEROperation.kt @@ -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 } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/Rendezvous.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/Rendezvous.kt index 7a13758150..851b75e44d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/Rendezvous.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/Rendezvous.kt @@ -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 /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt index a047e70839..9a9d3c9d35 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt @@ -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 diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/RoomSummaryRoomListDiffCallback.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/RoomSummaryRoomListDiffCallback.kt index 0d61e930d3..b31728ecd8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/RoomSummaryRoomListDiffCallback.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/RoomSummaryRoomListDiffCallback.kt @@ -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() { override fun areItemsTheSame(oldItem: RoomSummary, newItem: RoomSummary): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/DeleteNotificationSettingsAccountDataUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/DeleteNotificationSettingsAccountDataUseCase.kt index 3c086fe111..1babe2936d 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/DeleteNotificationSettingsAccountDataUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/DeleteNotificationSettingsAccountDataUseCase.kt @@ -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 diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/UpdateNotificationSettingsAccountDataUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/UpdateNotificationSettingsAccountDataUseCase.kt index 9296bcd912..2ff3f335c9 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/UpdateNotificationSettingsAccountDataUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/notification/UpdateNotificationSettingsAccountDataUseCase.kt @@ -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) { diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/ToggleNotificationsForCurrentSessionUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/ToggleNotificationsForCurrentSessionUseCase.kt index 3dc73f0a31..d89414f37a 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/ToggleNotificationsForCurrentSessionUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/ToggleNotificationsForCurrentSessionUseCase.kt @@ -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")