Skip to content

Commit

Permalink
fix: handle with scheme and domain from corecrypto [WPB-7084] (#2626)
Browse files Browse the repository at this point in the history
* Commit with unresolved merge conflicts outside of

* resolve conflicts

* resolve conflicts

---------

Co-authored-by: Michał Saleniuk <30429749+saleniuk@users.noreply.github.com>
Co-authored-by: Michał Saleniuk <saleniuk@gmail.com>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent d69118a commit 824eb8b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,18 @@ data class CryptoQualifiedClientId(

data class WireIdentity(
val clientId: CryptoQualifiedClientId,
val handle: String,
val handle: String, // handle format is "{scheme}%40{handle}@{domain}", example: "wireapp://%40hans.wurst@elna.wire.link"
val displayName: String,
val domain: String,
val certificate: String,
val status: CryptoCertificateStatus,
val thumbprint: String,
val serialNumber: String,
val endTimestamp: Long
)
) {
val handleWithoutSchemeAtSignAndDomain: String
get() = handle.substringAfter("://%40").removeSuffix("@$domain")
}

enum class CryptoCertificateStatus {
VALID, EXPIRED, REVOKED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ internal class MLSConversationsVerificationStatusesHandlerImpl(
val isUserVerified = wireIdentity.firstOrNull {
it.status != CryptoCertificateStatus.VALID ||
it.displayName != persistedMemberInfo?.name ||
it.handle != persistedMemberInfo.handle
it.handleWithoutSchemeAtSignAndDomain != persistedMemberInfo.handle
} == null
if (!isUserVerified) {
newStatus = VerificationStatus.NOT_VERIFIED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,50 @@ class MLSConversationRepositoryTest {
.wasInvoked(once)
}

@Test
fun givenHandleWithSchemeAndDomain_whenGetUserIdentity_thenHandleWithoutSchemeAtSignAndDomainShouldReturnProperValue() = runTest {
// given
val handleWithSchemeAndDomain = "wireapp://%40handle@domain.com"
val handle = "handle"
val groupId = Arrangement.GROUP_ID.value
val (_, mlsConversationRepository) = Arrangement()
.withGetEstablishedSelfMLSGroupIdReturns(groupId)
.withGetMLSClientSuccessful()
.withGetUserIdentitiesReturn(mapOf(groupId to listOf(WIRE_IDENTITY.copy(handle = handleWithSchemeAndDomain))))
.arrange()
// when
val result = mlsConversationRepository.getUserIdentity(TestUser.USER_ID)
// then
result.shouldSucceed() {
it.forEach {
assertEquals(handle, it.handleWithoutSchemeAtSignAndDomain)
}
}
}

@Test
fun givenHandleWithSchemeAndDomain_whenGetMemberIdentities_thenHandleWithoutSchemeAtSignAndDomainShouldReturnProperValue() = runTest {
// given
val handleWithSchemeAndDomain = "wireapp://%40handle@domain.com"
val handle = "handle"
val groupId = Arrangement.GROUP_ID.value
val (_, mlsConversationRepository) = Arrangement()
.withGetMLSGroupIdByConversationIdReturns(groupId)
.withGetMLSClientSuccessful()
.withGetUserIdentitiesReturn(mapOf(groupId to listOf(WIRE_IDENTITY.copy(handle = handleWithSchemeAndDomain))))
.arrange()
// when
val result = mlsConversationRepository.getMembersIdentities(TestConversation.ID, listOf(TestUser.USER_ID))
// then
result.shouldSucceed() {
it.values.forEach {
it.forEach {
assertEquals(handle, it.handleWithoutSchemeAtSignAndDomain)
}
}
}
}

private class Arrangement {

@Mock
Expand Down

0 comments on commit 824eb8b

Please sign in to comment.