-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle with scheme and domain from corecrypto [WPB-7084]
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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://%[email protected]" | ||
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,6 @@ import kotlinx.coroutines.test.runTest | |
import kotlinx.coroutines.yield | ||
import kotlinx.datetime.Instant | ||
import kotlin.test.Test | ||
import kotlin.test.assertContentEquals | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertIs | ||
|
||
|
@@ -1522,6 +1521,50 @@ class MLSConversationRepositoryTest { | |
.wasInvoked(once) | ||
} | ||
|
||
@Test | ||
fun givenHandleWithSchemeAndDomain_whenGetUserIdentity_thenHandleWithoutSchemeAtSignAndDomainShouldReturnProperValue() = runTest { | ||
// given | ||
val handleWithSchemeAndDomain = "wireapp://%[email protected]" | ||
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://%[email protected]" | ||
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 | ||
|