From d119ee30d38654bcd170fad17c360a33440a5c85 Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 11 Mar 2024 19:05:05 +0200 Subject: [PATCH 1/5] Commit with unresolved merge conflicts outside of --- .../com/wire/kalium/cryptography/IDs.kt | 5 + .../logic/feature/e2ei/E2eiCertificate.kt | 16 +++ .../MLSConversationRepositoryTest.kt | 5 + ...rsationsVerificationStatusesHandlerTest.kt | 120 ++++++++++++++++++ .../e2ei/GetE2eiCertificateUseCaseTest.kt | 5 + ...mbersE2EICertificateStatusesUseCaseTest.kt | 5 + ...erE2eiAllCertificateStatusesUseCaseTest.kt | 5 + 7 files changed, 161 insertions(+) diff --git a/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt b/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt index 9b28596dcda..aa338fe557b 100644 --- a/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt +++ b/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt @@ -78,7 +78,12 @@ data class WireIdentity( val certificate: String, val status: CryptoCertificateStatus, val thumbprint: String, +<<<<<<< HEAD val serialNumber: String +======= + val serialNumber: String, + val endTimestampSeconds: Long +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) enum class CryptoCertificateStatus { diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt index 4c07c93a080..910a1b8fc81 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt @@ -20,5 +20,21 @@ package com.wire.kalium.logic.feature.e2ei data class E2eiCertificate( val status: CertificateStatus, val serialNumber: String, +<<<<<<< HEAD val certificateDetail: String ) +======= + val certificateDetail: String, + val endAt: Instant +) { + companion object { + fun fromWireIdentity(identity: WireIdentity, certificateStatusMapper: CertificateStatusMapper): E2eiCertificate = + E2eiCertificate( + status = certificateStatusMapper.toCertificateStatus(identity.status), + serialNumber = identity.serialNumber, + certificateDetail = identity.certificate, + endAt = Instant.fromEpochSeconds(identity.endTimestampSeconds) + ) + } +} +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt index 044f272f5e0..584cdff89e8 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt @@ -1761,7 +1761,12 @@ class MLSConversationRepositoryTest { "certificate", CryptoCertificateStatus.VALID, thumbprint = "thumbprint", +<<<<<<< HEAD serialNumber = "serialNumber" +======= + serialNumber = "serialNumber", + endTimestampSeconds = 1899105093 +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) val E2EI_CONVERSATION_CLIENT_INFO_ENTITY = E2EIConversationClientInfoEntity(UserIDEntity(uuid4().toString(), "domain.com"), "clientId", "groupId") diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt index 57dace9e397..e9a46d20892 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt @@ -167,9 +167,54 @@ class MLSConversationsVerificationStatusesHandlerTest { @Test fun givenDegradedConversation_whenVerifiedStatusComes_thenStatusUpdated() = runTest { +<<<<<<< HEAD val conversationDetails = TestConversationDetails.CONVERSATION_GROUP.copy( conversation = TestConversation.MLS_CONVERSATION.copy( mlsVerificationStatus = Conversation.VerificationStatus.DEGRADED +======= + + val user1 = UserIDEntity("user1", "domain1") to NameAndHandleEntity("name1", "device1") + val user2 = UserIDEntity("user2", "domain2") to NameAndHandleEntity("name2", "device2") + + val epochChangedData = EpochChangesDataEntity( + conversationId = TestConversation.CONVERSATION.id.toDao(), + members = mapOf(user1, user2), + mlsVerificationStatus = ConversationEntity.VerificationStatus.DEGRADED + ) + + val ccMembersIdentity: Map> = mapOf( + user1.first.toModel() to listOf( + WireIdentity( + CryptoQualifiedClientId( + value = "client_user_1", + userId = user1.first.toModel().toCrypto() + ), + handle = user1.second.handle!!, + displayName = user1.second.name!!, + certificate = "cert1", + domain = "domain1", + serialNumber = "serial1", + status = CryptoCertificateStatus.VALID, + thumbprint = "thumbprint1", + endTimestampSeconds = 0L + ) + ), + user2.first.toModel() to listOf( + WireIdentity( + CryptoQualifiedClientId( + value = "client_user_2", + userId = user2.first.toModel().toCrypto() + ), + handle = user2.second.handle!!, + displayName = user2.second.name!!, + certificate = "cert2", + domain = "domain2", + serialNumber = "serial2", + status = CryptoCertificateStatus.VALID, + thumbprint = "thumbprint2", + endTimestampSeconds = 0L + ) +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) ) val (arrangement, handler) = arrange { @@ -197,6 +242,81 @@ class MLSConversationsVerificationStatusesHandlerTest { .wasInvoked(once) } +<<<<<<< HEAD +======= + @Test + fun givenVerifiedConversation_whenVerifiedStatusComesAndUserNamesDivergeFromCC_thenStatusUpdatedToDegraded() = runTest { + + val user1 = UserIDEntity("user1", "domain1") to NameAndHandleEntity("name1", "device1") + val user2 = UserIDEntity("user2", "domain2") to NameAndHandleEntity("name2", "device2") + + val epochChangedData = EpochChangesDataEntity( + conversationId = TestConversation.CONVERSATION.id.toDao(), + members = mapOf(user1, user2), + mlsVerificationStatus = ConversationEntity.VerificationStatus.VERIFIED + ) + + val ccMembersIdentity: Map> = mapOf( + user1.first.toModel() to listOf( + WireIdentity( + CryptoQualifiedClientId( + value = "client_user_1", + userId = user1.first.toModel().toCrypto() + ), + handle = user1.second.handle!! + "1", // this user name changed + displayName = user1.second.name!! + "1", + certificate = "cert1", + domain = "domain1", + serialNumber = "serial1", + status = CryptoCertificateStatus.VALID, + thumbprint = "thumbprint1", + endTimestampSeconds = 0L + ) + ), + user2.first.toModel() to listOf( + WireIdentity( + CryptoQualifiedClientId( + value = "client_user_2", + userId = user2.first.toModel().toCrypto() + ), + handle = user2.second.handle!!, + displayName = user2.second.name!!, + certificate = "cert2", + domain = "domain2", + serialNumber = "serial2", + status = CryptoCertificateStatus.VALID, + thumbprint = "thumbprint2", + endTimestampSeconds = 0L + ) + ) + ) + val (arrangement, handler) = arrange { + withObserveEpochChanges(flowOf(TestConversation.GROUP_ID)) + withIsGroupVerified(E2EIConversationState.VERIFIED) + withSelectGroupStatusMembersNamesAndHandles(Either.Right(epochChangedData)) + withGetMembersIdentities(Either.Right(ccMembersIdentity)) + } + + handler() + advanceUntilIdle() + + verify(arrangement.conversationRepository) + .suspendFunction(arrangement.conversationRepository::updateMlsVerificationStatus) + .with(eq(Conversation.VerificationStatus.DEGRADED), eq(epochChangedData.conversationId.toModel())) + .wasInvoked(once) + + verify(arrangement.persistMessageUseCase) + .suspendFunction(arrangement.persistMessageUseCase::invoke) + .with(anyInstanceOf(Message.System::class)) + .wasInvoked(once) + + verify(arrangement.conversationRepository) + .suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag) + .with(any(), eq(false)) + .wasInvoked(once) + } + +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) private fun arrange(block: Arrangement.() -> Unit) = Arrangement(block).arrange() private class Arrangement( diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt index 3642561fea2..39eb6274c68 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt @@ -153,7 +153,12 @@ class GetE2eiCertificateUseCaseTest { certificate = "certificate", status = CryptoCertificateStatus.EXPIRED, thumbprint = "thumbprint", +<<<<<<< HEAD serialNumber = "serialNumber" +======= + serialNumber = "serialNumber", + endTimestampSeconds = 1899105093 +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt index b930a7cabe1..57372926483 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt @@ -149,6 +149,7 @@ class GetMembersE2EICertificateStatusesUseCaseTest { "certificate", CryptoCertificateStatus.VALID, "thumbprint", +<<<<<<< HEAD "serialNumber" ) private val E2EI_CERTIFICATE = @@ -156,6 +157,10 @@ class GetMembersE2EICertificateStatusesUseCaseTest { status = CertificateStatus.VALID, serialNumber = "number", certificateDetail = "details" +======= + "serialNumber", + endTimestampSeconds = 1899105093 +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt index 20c468b19a1..b1e9caca953 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt @@ -157,6 +157,7 @@ class GetUserE2eiAllCertificateStatusesUseCaseTest { "certificate", CryptoCertificateStatus.VALID, "thumbprint", +<<<<<<< HEAD "serialNumber" ) private val E2EI_CERTIFICATE = @@ -164,6 +165,10 @@ class GetUserE2eiAllCertificateStatusesUseCaseTest { status = CertificateStatus.VALID, serialNumber = "number", certificateDetail = "details" +======= + serialNumber = "serialNumber", + endTimestampSeconds = 1899105093 +>>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) } } From a4e8e644971a971be6e8ba809d417f33b11a4a0f Mon Sep 17 00:00:00 2001 From: Boris Safonov Date: Thu, 14 Mar 2024 17:04:38 +0200 Subject: [PATCH 2/5] Fix merge conflicts --- .../MLSClientImpl.kt | 3 +- .../com/wire/kalium/cryptography/IDs.kt | 4 - .../logic/feature/e2ei/E2eiCertificate.kt | 8 +- .../e2ei/usecase/GetE2EICertificateUseCase.kt | 10 +- ...etMembersE2EICertificateStatusesUseCase.kt | 6 +- .../GetUserE2EIAllCertificatesUseCase.kt | 6 +- .../MLSConversationRepositoryTest.kt | 59 +++++---- .../client/ObserveE2EIRequiredUseCaseTest.kt | 3 +- ...rsationsVerificationStatusesHandlerTest.kt | 120 ------------------ .../e2ei/GetE2eiCertificateUseCaseTest.kt | 7 +- ...mbersE2EICertificateStatusesUseCaseTest.kt | 10 -- ...erE2eiAllCertificateStatusesUseCaseTest.kt | 14 +- ...GetUserE2eiCertificateStatusUseCaseTest.kt | 9 +- 13 files changed, 46 insertions(+), 213 deletions(-) diff --git a/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/MLSClientImpl.kt b/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/MLSClientImpl.kt index 5a2ffe35eaf..0fda4427a25 100644 --- a/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/MLSClientImpl.kt +++ b/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/MLSClientImpl.kt @@ -332,7 +332,8 @@ class MLSClientImpl( value.certificate, toDeviceStatus(value.status), value.thumbprint, - value.serialNumber + value.serialNumber, + value.notAfter.toLong() ) } } diff --git a/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt b/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt index aa338fe557b..6cd88f9f7a1 100644 --- a/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt +++ b/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt @@ -78,12 +78,8 @@ data class WireIdentity( val certificate: String, val status: CryptoCertificateStatus, val thumbprint: String, -<<<<<<< HEAD - val serialNumber: String -======= val serialNumber: String, val endTimestampSeconds: Long ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) enum class CryptoCertificateStatus { diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt index 910a1b8fc81..233d11805bd 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/E2eiCertificate.kt @@ -17,13 +17,12 @@ */ package com.wire.kalium.logic.feature.e2ei +import com.wire.kalium.cryptography.WireIdentity +import kotlinx.datetime.Instant + data class E2eiCertificate( val status: CertificateStatus, val serialNumber: String, -<<<<<<< HEAD - val certificateDetail: String -) -======= val certificateDetail: String, val endAt: Instant ) { @@ -37,4 +36,3 @@ data class E2eiCertificate( ) } } ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetE2EICertificateUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetE2EICertificateUseCase.kt index c20a520f937..2ada0934127 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetE2EICertificateUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetE2EICertificateUseCase.kt @@ -36,16 +36,10 @@ class GetE2eiCertificateUseCaseImpl internal constructor( ) : GetE2eiCertificateUseCase { override suspend operator fun invoke(clientId: ClientId): GetE2EICertificateUseCaseResult = mlsConversationRepository.getClientIdentity(clientId).fold( - { - GetE2EICertificateUseCaseResult.Failure - }, + { GetE2EICertificateUseCaseResult.Failure }, { it?.let { - val certificate = E2eiCertificate( - status = certificateStatusMapper.toCertificateStatus(it.status), - serialNumber = it.serialNumber, - certificateDetail = it.certificate - ) + val certificate = E2eiCertificate.fromWireIdentity(it, certificateStatusMapper) GetE2EICertificateUseCaseResult.Success(certificate) } ?: GetE2EICertificateUseCaseResult.NotActivated } diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetMembersE2EICertificateStatusesUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetMembersE2EICertificateStatusesUseCase.kt index 6b52bae7fe5..cd1d2309a9c 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetMembersE2EICertificateStatusesUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetMembersE2EICertificateStatusesUseCase.kt @@ -57,11 +57,7 @@ class GetMembersE2EICertificateStatusesUseCaseImpl internal constructor( */ fun List.getUserCertificateStatus(certificateStatusMapper: CertificateStatusMapper): CertificateStatus? { val certificates = this.map { - E2eiCertificate( - status = certificateStatusMapper.toCertificateStatus(it.status), - serialNumber = it.serialNumber, - certificateDetail = it.certificate - ) + E2eiCertificate.fromWireIdentity(it, certificateStatusMapper) } return if (certificates.isEmpty()) { null diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetUserE2EIAllCertificatesUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetUserE2EIAllCertificatesUseCase.kt index bbfd86c84b5..879e0a95d6d 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetUserE2EIAllCertificatesUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/GetUserE2EIAllCertificatesUseCase.kt @@ -44,11 +44,7 @@ class GetUserE2eiCertificatesUseCaseImpl internal constructor( mlsConversationRepository.getUserIdentity(userId).map { identities -> val result = mutableMapOf() identities.forEach { - val certificate = E2eiCertificate( - status = certificateStatusMapper.toCertificateStatus(it.status), - serialNumber = it.serialNumber, - certificateDetail = it.certificate - ) + val certificate = E2eiCertificate.fromWireIdentity(it, certificateStatusMapper) result[it.clientId.value] = certificate } result diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt index 584cdff89e8..7635d8b2c6d 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt @@ -1399,36 +1399,37 @@ class MLSConversationRepositoryTest { } @Test - fun givenSuccessfulResponses_whenCallingEstablishMLSSubConversationGroup_thenGroupIsCreatedAndCommitBundleIsSentAndAccepted() = runTest { - val (arrangement, mlsConversationRepository) = Arrangement() - .withCommitPendingProposalsReturningNothing() - .withClaimKeyPackagesSuccessful() - .withGetMLSClientSuccessful() - .withGetMLSGroupIdByConversationIdReturns(Arrangement.GROUP_ID.value) - .withGetExternalSenderKeySuccessful() - .withGetPublicKeysSuccessful() - .withUpdateKeyingMaterialSuccessful() - .withSendCommitBundleSuccessful() - .arrange() + fun givenSuccessfulResponses_whenCallingEstablishMLSSubConversationGroup_thenGroupIsCreatedAndCommitBundleIsSentAndAccepted() = + runTest { + val (arrangement, mlsConversationRepository) = Arrangement() + .withCommitPendingProposalsReturningNothing() + .withClaimKeyPackagesSuccessful() + .withGetMLSClientSuccessful() + .withGetMLSGroupIdByConversationIdReturns(Arrangement.GROUP_ID.value) + .withGetExternalSenderKeySuccessful() + .withGetPublicKeysSuccessful() + .withUpdateKeyingMaterialSuccessful() + .withSendCommitBundleSuccessful() + .arrange() - val result = mlsConversationRepository.establishMLSSubConversationGroup(Arrangement.GROUP_ID, TestConversation.ID) - result.shouldSucceed() + val result = mlsConversationRepository.establishMLSSubConversationGroup(Arrangement.GROUP_ID, TestConversation.ID) + result.shouldSucceed() - verify(arrangement.mlsClient) - .function(arrangement.mlsClient::createConversation) - .with(eq(Arrangement.RAW_GROUP_ID), eq(listOf(Arrangement.CRYPTO_MLS_EXTERNAL_KEY))) - .wasInvoked(once) + verify(arrangement.mlsClient) + .function(arrangement.mlsClient::createConversation) + .with(eq(Arrangement.RAW_GROUP_ID), eq(listOf(Arrangement.CRYPTO_MLS_EXTERNAL_KEY))) + .wasInvoked(once) - verify(arrangement.mlsMessageApi) - .suspendFunction(arrangement.mlsMessageApi::sendCommitBundle) - .with(anyInstanceOf(MLSMessageApi.CommitBundle::class)) - .wasInvoked(once) + verify(arrangement.mlsMessageApi) + .suspendFunction(arrangement.mlsMessageApi::sendCommitBundle) + .with(anyInstanceOf(MLSMessageApi.CommitBundle::class)) + .wasInvoked(once) - verify(arrangement.mlsClient) - .function(arrangement.mlsClient::commitAccepted) - .with(eq(Arrangement.RAW_GROUP_ID)) - .wasInvoked(once) - } + verify(arrangement.mlsClient) + .function(arrangement.mlsClient::commitAccepted) + .with(eq(Arrangement.RAW_GROUP_ID)) + .wasInvoked(once) + } private class Arrangement { @@ -1546,12 +1547,14 @@ class MLSConversationRepositoryTest { .whenInvokedWith(anything()) .then { Either.Right(mlsClient) } } + fun withGetExternalSenderKeySuccessful() = apply { given(mlsClient) .suspendFunction(mlsClient::getExternalSenders) .whenInvokedWith(anything()) .thenReturn(EXTERNAL_SENDER_KEY) } + fun withRotateAllSuccessful(rotateBundle: RotateBundle = ROTATE_BUNDLE) = apply { given(mlsClient) .suspendFunction(mlsClient::e2eiRotateAll) @@ -1761,12 +1764,8 @@ class MLSConversationRepositoryTest { "certificate", CryptoCertificateStatus.VALID, thumbprint = "thumbprint", -<<<<<<< HEAD - serialNumber = "serialNumber" -======= serialNumber = "serialNumber", endTimestampSeconds = 1899105093 ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) val E2EI_CONVERSATION_CLIENT_INFO_ENTITY = E2EIConversationClientInfoEntity(UserIDEntity(uuid4().toString(), "domain.com"), "clientId", "groupId") diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt index 584a6a91ec7..73ac0a4f38f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt @@ -298,7 +298,8 @@ class ObserveE2EIRequiredUseCaseTest { private val VALID_CERTIFICATE = E2eiCertificate( serialNumber = "serialNumber", certificateDetail = "certificateDetail", - status = CertificateStatus.VALID + status = CertificateStatus.VALID, + endAt = Instant.DISTANT_FUTURE ) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt index e9a46d20892..57dace9e397 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt @@ -167,54 +167,9 @@ class MLSConversationsVerificationStatusesHandlerTest { @Test fun givenDegradedConversation_whenVerifiedStatusComes_thenStatusUpdated() = runTest { -<<<<<<< HEAD val conversationDetails = TestConversationDetails.CONVERSATION_GROUP.copy( conversation = TestConversation.MLS_CONVERSATION.copy( mlsVerificationStatus = Conversation.VerificationStatus.DEGRADED -======= - - val user1 = UserIDEntity("user1", "domain1") to NameAndHandleEntity("name1", "device1") - val user2 = UserIDEntity("user2", "domain2") to NameAndHandleEntity("name2", "device2") - - val epochChangedData = EpochChangesDataEntity( - conversationId = TestConversation.CONVERSATION.id.toDao(), - members = mapOf(user1, user2), - mlsVerificationStatus = ConversationEntity.VerificationStatus.DEGRADED - ) - - val ccMembersIdentity: Map> = mapOf( - user1.first.toModel() to listOf( - WireIdentity( - CryptoQualifiedClientId( - value = "client_user_1", - userId = user1.first.toModel().toCrypto() - ), - handle = user1.second.handle!!, - displayName = user1.second.name!!, - certificate = "cert1", - domain = "domain1", - serialNumber = "serial1", - status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint1", - endTimestampSeconds = 0L - ) - ), - user2.first.toModel() to listOf( - WireIdentity( - CryptoQualifiedClientId( - value = "client_user_2", - userId = user2.first.toModel().toCrypto() - ), - handle = user2.second.handle!!, - displayName = user2.second.name!!, - certificate = "cert2", - domain = "domain2", - serialNumber = "serial2", - status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint2", - endTimestampSeconds = 0L - ) ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) ) val (arrangement, handler) = arrange { @@ -242,81 +197,6 @@ class MLSConversationsVerificationStatusesHandlerTest { .wasInvoked(once) } -<<<<<<< HEAD -======= - @Test - fun givenVerifiedConversation_whenVerifiedStatusComesAndUserNamesDivergeFromCC_thenStatusUpdatedToDegraded() = runTest { - - val user1 = UserIDEntity("user1", "domain1") to NameAndHandleEntity("name1", "device1") - val user2 = UserIDEntity("user2", "domain2") to NameAndHandleEntity("name2", "device2") - - val epochChangedData = EpochChangesDataEntity( - conversationId = TestConversation.CONVERSATION.id.toDao(), - members = mapOf(user1, user2), - mlsVerificationStatus = ConversationEntity.VerificationStatus.VERIFIED - ) - - val ccMembersIdentity: Map> = mapOf( - user1.first.toModel() to listOf( - WireIdentity( - CryptoQualifiedClientId( - value = "client_user_1", - userId = user1.first.toModel().toCrypto() - ), - handle = user1.second.handle!! + "1", // this user name changed - displayName = user1.second.name!! + "1", - certificate = "cert1", - domain = "domain1", - serialNumber = "serial1", - status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint1", - endTimestampSeconds = 0L - ) - ), - user2.first.toModel() to listOf( - WireIdentity( - CryptoQualifiedClientId( - value = "client_user_2", - userId = user2.first.toModel().toCrypto() - ), - handle = user2.second.handle!!, - displayName = user2.second.name!!, - certificate = "cert2", - domain = "domain2", - serialNumber = "serial2", - status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint2", - endTimestampSeconds = 0L - ) - ) - ) - val (arrangement, handler) = arrange { - withObserveEpochChanges(flowOf(TestConversation.GROUP_ID)) - withIsGroupVerified(E2EIConversationState.VERIFIED) - withSelectGroupStatusMembersNamesAndHandles(Either.Right(epochChangedData)) - withGetMembersIdentities(Either.Right(ccMembersIdentity)) - } - - handler() - advanceUntilIdle() - - verify(arrangement.conversationRepository) - .suspendFunction(arrangement.conversationRepository::updateMlsVerificationStatus) - .with(eq(Conversation.VerificationStatus.DEGRADED), eq(epochChangedData.conversationId.toModel())) - .wasInvoked(once) - - verify(arrangement.persistMessageUseCase) - .suspendFunction(arrangement.persistMessageUseCase::invoke) - .with(anyInstanceOf(Message.System::class)) - .wasInvoked(once) - - verify(arrangement.conversationRepository) - .suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag) - .with(any(), eq(false)) - .wasInvoked(once) - } - ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) private fun arrange(block: Arrangement.() -> Unit) = Arrangement(block).arrange() private class Arrangement( diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt index 39eb6274c68..f27bdfe462f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetE2eiCertificateUseCaseTest.kt @@ -36,6 +36,7 @@ import io.mockative.mock import io.mockative.once import io.mockative.verify import kotlinx.coroutines.test.runTest +import kotlinx.datetime.Instant import kotlin.test.Test import kotlin.test.assertEquals @@ -144,7 +145,7 @@ class GetE2eiCertificateUseCaseTest { CryptoQualifiedClientId("clientId", USER_ID.toCrypto()) val e2eiCertificate = - E2eiCertificate(CertificateStatus.EXPIRED, "serialNumber", "certificateDetail") + E2eiCertificate(CertificateStatus.EXPIRED, "serialNumber", "certificateDetail", Instant.DISTANT_FUTURE) val IDENTITY = WireIdentity( CRYPTO_QUALIFIED_CLIENT_ID, handle = "alic_test", @@ -153,12 +154,8 @@ class GetE2eiCertificateUseCaseTest { certificate = "certificate", status = CryptoCertificateStatus.EXPIRED, thumbprint = "thumbprint", -<<<<<<< HEAD - serialNumber = "serialNumber" -======= serialNumber = "serialNumber", endTimestampSeconds = 1899105093 ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt index 57372926483..77ac0a901cf 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetMembersE2EICertificateStatusesUseCaseTest.kt @@ -149,18 +149,8 @@ class GetMembersE2EICertificateStatusesUseCaseTest { "certificate", CryptoCertificateStatus.VALID, "thumbprint", -<<<<<<< HEAD - "serialNumber" - ) - private val E2EI_CERTIFICATE = - E2eiCertificate( - status = CertificateStatus.VALID, - serialNumber = "number", - certificateDetail = "details" -======= "serialNumber", endTimestampSeconds = 1899105093 ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) ) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt index b1e9caca953..a76395b357d 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiAllCertificateStatusesUseCaseTest.kt @@ -157,18 +157,8 @@ class GetUserE2eiAllCertificateStatusesUseCaseTest { "certificate", CryptoCertificateStatus.VALID, "thumbprint", -<<<<<<< HEAD - "serialNumber" - ) - private val E2EI_CERTIFICATE = - E2eiCertificate( - status = CertificateStatus.VALID, - serialNumber = "number", - certificateDetail = "details" -======= - serialNumber = "serialNumber", - endTimestampSeconds = 1899105093 ->>>>>>> 6f2869df0c (fix: Request to update E2eI certificate when should not (#2620)) + "serialNumber", + 1899105093 ) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiCertificateStatusUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiCertificateStatusUseCaseTest.kt index 0cc287ee937..d8e05f29f20 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiCertificateStatusUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/GetUserE2eiCertificateStatusUseCaseTest.kt @@ -205,13 +205,8 @@ class GetUserE2eiCertificateStatusUseCaseTest { "certificate", CryptoCertificateStatus.VALID, "thumbprint", - "serialNumber" - ) - private val E2EI_CERTIFICATE = - E2eiCertificate( - status = CertificateStatus.VALID, - serialNumber = "number", - certificateDetail = "details" + "serialNumber", + 1899105093 ) } } From d2f1fab50853f1a9edfcd5b0d7fff696a358dc38 Mon Sep 17 00:00:00 2001 From: Boris Safonov Date: Fri, 15 Mar 2024 12:24:55 +0200 Subject: [PATCH 3/5] Fix tests --- ...LSConversationsVerificationStatusesHandlerTest.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt index a19321512cf..de09c995c34 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/MLSConversationsVerificationStatusesHandlerTest.kt @@ -183,7 +183,8 @@ class MLSConversationsVerificationStatusesHandlerTest { domain = "domain1", serialNumber = "serial1", status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint1" + thumbprint = "thumbprint1", + endTimestampSeconds = 1899105093 ) ), user2.first.toModel() to listOf( @@ -198,7 +199,8 @@ class MLSConversationsVerificationStatusesHandlerTest { domain = "domain2", serialNumber = "serial2", status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint2" + thumbprint = "thumbprint2", + endTimestampSeconds = 1899105093 ) ) ) @@ -253,7 +255,8 @@ class MLSConversationsVerificationStatusesHandlerTest { domain = "domain1", serialNumber = "serial1", status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint1" + thumbprint = "thumbprint1", + endTimestampSeconds = 1899105093 ) ), user2.first.toModel() to listOf( @@ -268,7 +271,8 @@ class MLSConversationsVerificationStatusesHandlerTest { domain = "domain2", serialNumber = "serial2", status = CryptoCertificateStatus.VALID, - thumbprint = "thumbprint2" + thumbprint = "thumbprint2", + endTimestampSeconds = 1899105093 ) ) ) From 7200814a205c48f46148f843aaa4d79a22339f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Saleniuk?= Date: Fri, 15 Mar 2024 12:45:21 +0100 Subject: [PATCH 4/5] fix after resolving conflicts --- .../logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt index f0915c2f0b7..ae33bb1cb9f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt @@ -347,7 +347,7 @@ class ObserveE2EIRequiredUseCaseTest { serialNumber = "serialNumber", certificateDetail = "certificateDetail", status = CertificateStatus.VALID, - endAt = Instant.DISTANT_FUTURE + endAt = DateTimeUtil.currentInstant().plus(1.days) ) } } From 6ca5e2b39fc4ad4f074867bd39b62aee476a4b58 Mon Sep 17 00:00:00 2001 From: Boris Safonov Date: Fri, 15 Mar 2024 13:45:41 +0200 Subject: [PATCH 5/5] Fix test --- .../logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt index f0915c2f0b7..ae33bb1cb9f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/ObserveE2EIRequiredUseCaseTest.kt @@ -347,7 +347,7 @@ class ObserveE2EIRequiredUseCaseTest { serialNumber = "serialNumber", certificateDetail = "certificateDetail", status = CertificateStatus.VALID, - endAt = Instant.DISTANT_FUTURE + endAt = DateTimeUtil.currentInstant().plus(1.days) ) } }