Skip to content

Commit

Permalink
Merge branch 'release/candidate' into fix/login-after-session-expire-…
Browse files Browse the repository at this point in the history
…cherry-pick
  • Loading branch information
MohamadJaara authored Sep 25, 2024
2 parents 2d5cf39 + e390227 commit 8183680
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class CheckCrlRevocationListUseCase internal constructor(
}
}
}
}
} ?: logger.w("No CRLs found.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.http.ContentType
import io.ktor.http.URLBuilder
import io.ktor.http.URLProtocol
import io.ktor.http.Url
import io.ktor.http.contentType
import io.ktor.http.isSuccess
Expand Down Expand Up @@ -269,8 +268,11 @@ class ACMEApiImpl internal constructor(
}

return wrapKaliumResponse {
val httpUrl = if (proxyUrl.isNullOrEmpty()) URLBuilder(url).apply { this.protocol = URLProtocol.HTTP }.build()
else URLBuilder(proxyUrl).apply { this.pathSegments = this.pathSegments.plus(url) }.build()
val crlUrlBuilder: URLBuilder = URLBuilder(url)
val proxyUrlBuilder: URLBuilder? = if (proxyUrl.isNullOrEmpty()) null else URLBuilder(proxyUrl)

val httpUrl = proxyUrlBuilder?.apply { this.pathSegments += crlUrlBuilder.host }?.build()
?: crlUrlBuilder.build()

clearTextTrafficHttpClient.get(httpUrl)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,49 @@ internal class ACMEApiTest : ApiTest() {
}
}

@Test
fun givenProxyAndCrl_whenGettingClientDomainCRL_thenUseProxyUrlWithCRLHostAddedToPath() = runTest {
val crlUrl = "https://crl.wire.com/crl"
val proxyUrl = "https://proxy.wire:9000/proxy"
val expected = "$proxyUrl/crl.wire.com"
val networkClient = mockUnboundNetworkClient(
"",
statusCode = HttpStatusCode.OK,
assertion = {
assertJson()
assertUrlEqual(expected)
assertGet()
assertNoQueryParams()
}
)
val acmeApi: ACMEApi = ACMEApiImpl(networkClient, networkClient)

acmeApi.getClientDomainCRL(url = crlUrl, proxyUrl = proxyUrl).also { actual ->
assertIs<NetworkResponse.Success<CertificateChain>>(actual)
}
}

@Test
fun givenCRLWithHttpsProtocol_whenGettingClientDomainCRL_thenItShouldNotBeChanged() = runTest {
val crlUrl = "https://crl.wire.com/crl"
val expected = crlUrl
val networkClient = mockUnboundNetworkClient(
"",
statusCode = HttpStatusCode.OK,
assertion = {
assertJson()
assertUrlEqual(expected)
assertGet()
assertNoQueryParams()
}
)
val acmeApi: ACMEApi = ACMEApiImpl(networkClient, networkClient)

acmeApi.getClientDomainCRL(url = crlUrl, proxyUrl = null).also { actual ->
assertIs<NetworkResponse.Success<CertificateChain>>(actual)
}
}

companion object {
private const val ACME_DISCOVERY_URL = "https://balderdash.hogwash.work:9000/acme/google-android/directory"
private const val ACME_DIRECTORIES_PATH = "https://balderdash.hogwash.work:9000/acme/google-android/directory"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type = excluded.type,
team_id = excluded.team_id,
mls_group_id = excluded.mls_group_id,
mls_epoch = excluded.mls_epoch,
mls_group_state = excluded.mls_group_state,
protocol = excluded.protocol,
muted_status = excluded.muted_status,
muted_time = excluded.muted_time,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ class ConversationDAOTest : BaseDatabaseTest() {
assertNull(result)
}

@Test
fun givenExistingConversation_WhenReinserting_ThenGroupStateIsUpdated() = runTest {
conversationDAO.insertConversation(conversationEntity2)
conversationDAO.insertConversation(conversationEntity2.copy(
protocolInfo = mlsProtocolInfo1.copy(
groupState = ConversationEntity.GroupState.PENDING_JOIN
)
))
val result = conversationDAO.getConversationByQualifiedID(conversationEntity2.id)
assertEquals(ConversationEntity.GroupState.PENDING_JOIN, (result?.protocolInfo as ConversationEntity.ProtocolInfo.MLS).groupState)
}

@Test
fun givenExistingConversation_ThenConversationCanBeUpdated() = runTest {
conversationDAO.insertConversation(conversationEntity1)
Expand Down Expand Up @@ -2043,6 +2055,21 @@ class ConversationDAOTest : BaseDatabaseTest() {
isMLSCapable = false
)

val mlsProtocolInfo1 = ConversationEntity.ProtocolInfo.MLS(
"group2",
ConversationEntity.GroupState.ESTABLISHED,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
)
val mlsProtocolInfo2 = ConversationEntity.ProtocolInfo.MLS(
"group3",
ConversationEntity.GroupState.PENDING_JOIN,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
)

val team = TeamEntity(teamId, "teamName", "")

val conversationEntity1 = ConversationEntity(
Expand Down Expand Up @@ -2072,13 +2099,7 @@ class ConversationDAOTest : BaseDatabaseTest() {
"conversation2",
ConversationEntity.Type.ONE_ON_ONE,
null,
ConversationEntity.ProtocolInfo.MLS(
"group2",
ConversationEntity.GroupState.ESTABLISHED,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
),
protocolInfo = mlsProtocolInfo1,
creatorId = "someValue",
lastNotificationDate = null,
lastModifiedDate = "2021-03-30T15:36:00.000Z".toInstant(),
Expand All @@ -2101,13 +2122,7 @@ class ConversationDAOTest : BaseDatabaseTest() {
"conversation3",
ConversationEntity.Type.GROUP,
null,
ConversationEntity.ProtocolInfo.MLS(
"group3",
ConversationEntity.GroupState.PENDING_JOIN,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
),
protocolInfo = mlsProtocolInfo2,
creatorId = "someValue",
// This conversation was modified after the last time the user was notified about it
lastNotificationDate = "2021-03-30T15:30:00.000Z".toInstant(),
Expand Down

0 comments on commit 8183680

Please sign in to comment.