Skip to content

Commit

Permalink
Merge branch 'develop' into feat/add_integrartion_tests_infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreferris committed Sep 20, 2023
2 parents 3ad0d81 + bf09e78 commit 5942ac1
Show file tree
Hide file tree
Showing 96 changed files with 2,002 additions and 445 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Alternatively the credentials are also read from your environment if `GITHUB_USE
### Dependencies

- JDK 11 (ex: openjdk-11-jdk on Ubuntu)
- JDK 17 (ex: openjdk-17-jdk on Ubuntu)
- [libsodium](https://github.com/jedisct1/libsodium)
- [cryptobox-c](https://github.com/wireapp/cryptobox-c)
- [cryptobox4j](https://github.com/wireapp/cryptobox4j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ interface Calling : Library {
arg: Pointer?
)

@Suppress("FunctionNaming")
fun wcall_process_notifications(
inst: Handle,
isStarted: Boolean,
)

companion object {
val INSTANCE by lazy { Native.load("avs", Calling::class.java)!! }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class MLSClientImpl(
return toByteArray(applicationMessage)
}

override suspend fun decryptMessage(groupId: MLSGroupId, message: ApplicationMessage): DecryptedMessageBundle {
return toDecryptedMessageBundle(coreCrypto.decryptMessage(toUByteList(groupId.decodeBase64Bytes()), toUByteList(message)))
override suspend fun decryptMessage(groupId: MLSGroupId, message: ApplicationMessage): List<DecryptedMessageBundle> {
return listOf(toDecryptedMessageBundle(coreCrypto.decryptMessage(toUByteList(groupId.decodeBase64Bytes()), toUByteList(message))))
}

override suspend fun members(groupId: MLSGroupId): List<CryptoQualifiedClientId> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.wire.kalium.cryptography

import com.wire.crypto.BufferedDecryptedMessage
import com.wire.crypto.ConversationConfiguration
import com.wire.crypto.CoreCrypto
import com.wire.crypto.CustomConfiguration
Expand Down Expand Up @@ -130,13 +131,20 @@ class MLSClientImpl(
return applicationMessage
}

override suspend fun decryptMessage(groupId: MLSGroupId, message: ApplicationMessage): DecryptedMessageBundle {
return toDecryptedMessageBundle(
coreCrypto.decryptMessage(
groupId.decodeBase64Bytes(),
message
)
override suspend fun decryptMessage(groupId: MLSGroupId, message: ApplicationMessage): List<DecryptedMessageBundle> {
val decryptedMessage = coreCrypto.decryptMessage(
groupId.decodeBase64Bytes(),
message
)

val messageBundle = listOf(toDecryptedMessageBundle(
decryptedMessage
))
val bufferedMessages = decryptedMessage.bufferedMessages?.map {
toDecryptedMessageBundle(it)
} ?: emptyList()

return messageBundle + bufferedMessages
}

override suspend fun commitAccepted(groupId: MLSGroupId) {
Expand Down Expand Up @@ -304,6 +312,16 @@ class MLSClientImpl(
E2EIdentity(it.clientId, it.handle, it.displayName, it.domain)
}
)

fun toDecryptedMessageBundle(value: BufferedDecryptedMessage) = DecryptedMessageBundle(
value.message,
value.commitDelay?.toLong(),
value.senderClientId?.let { CryptoQualifiedClientId.fromEncodedString(String(it)) },
value.hasEpochChanged,
value.identity?.let {
E2EIdentity(it.clientId, it.handle, it.displayName, it.domain)
}
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ interface MLSClient {
suspend fun decryptMessage(
groupId: MLSGroupId,
message: ApplicationMessage
): DecryptedMessageBundle
): List<DecryptedMessageBundle>

/**
* Current members of the group.
Expand Down Expand Up @@ -318,5 +318,3 @@ interface MLSClient {
*/
suspend fun isGroupVerified(groupId: MLSGroupId): Boolean
}

// expect class MLSClientImpl(rootDir: String, databaseKey: MlsDBSecret, clientId: CryptoQualifiedClientId) : MLSClient
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MLSClientTest : BaseMLSClientTest() {
val commit = bobClient.updateKeyingMaterial(MLS_CONVERSATION_ID).commit
val result = aliceClient.decryptMessage(conversationId, commit)

assertNull(result.message)
assertNull(result.first().message)
}

@Test
Expand Down Expand Up @@ -124,7 +124,7 @@ class MLSClientTest : BaseMLSClientTest() {
val conversationId = aliceClient.processWelcomeMessage(welcome)

val applicationMessage = aliceClient.encryptMessage(conversationId, PLAIN_TEXT.encodeToByteArray())
val plainMessage = bobClient.decryptMessage(conversationId, applicationMessage).message
val plainMessage = bobClient.decryptMessage(conversationId, applicationMessage).first().message

assertEquals(PLAIN_TEXT, plainMessage?.decodeToString())
}
Expand Down Expand Up @@ -165,7 +165,7 @@ class MLSClientTest : BaseMLSClientTest() {
listOf(Pair(CAROL1.qualifiedClientId, carolClient.generateKeyPackages(1).first()))
)?.commit!!

assertNull(aliceClient.decryptMessage(MLS_CONVERSATION_ID, commit).message)
assertNull(aliceClient.decryptMessage(MLS_CONVERSATION_ID, commit).first().message)
}

@Test
Expand All @@ -186,7 +186,7 @@ class MLSClientTest : BaseMLSClientTest() {
val clientRemovalList = listOf(CAROL1.qualifiedClientId)
val commit = bobClient.removeMember(conversationId, clientRemovalList).commit

assertNull(aliceClient.decryptMessage(conversationId, commit).message)
assertNull(aliceClient.decryptMessage(conversationId, commit).first().message)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MLSClientImpl : MLSClient {
TODO("Not yet implemented")
}

override suspend fun decryptMessage(groupId: MLSGroupId, message: ApplicationMessage): DecryptedMessageBundle {
override suspend fun decryptMessage(groupId: MLSGroupId, message: ApplicationMessage): List<DecryptedMessageBundle> {
TODO("Not yet implemented")
}

Expand Down
10 changes: 0 additions & 10 deletions docker-compose.yml

This file was deleted.

22 changes: 11 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ activity-compose = "1.3.1"
app-compat = "1.1.0"
android-paging3 = "3.1.1"
cli-kt = "3.5.0"
coroutines = "1.7.1"
coroutines = "1.7.3"
compose-compiler = "1.5.0"
compose-ui = "1.3.2"
compose-material = "1.3.1"
cryptobox4j = "1.3.0"
cryptobox-android = "1.1.5"
android-security = "1.1.0-alpha06"
ktor = "2.3.1"
okio = "3.2.0"
ok-http = "4.10.0"
ktor = "2.3.4"
okio = "3.4.0"
ok-http = "4.11.0"
mockative = "1.4.1"
android-work = "2.8.1"
android-test-runner = "1.5.0"
android-test-rules = "1.4.0"
android-test-core = "1.4.0"
androidx-arch = "2.1.0"
androidx-arch = "2.2.0"
androidx-test-orchestrator = "1.4.2"
androidx-sqlite = "2.3.0"
androidx-sqlite = "2.3.1"
benasher-uuid = "0.8.0"
ktx-datetime = { strictly = "0.4.0" }
ktx-serialization = "1.5.1"
ktx-atomicfu = "0.18.5"
ktx-atomicfu = "0.22.0"
kover = "0.7.1"
multiplatform-settings = "1.0.0"
# if you update sqlDelight check if https://github.com/cashapp/sqldelight/issues/4154 is fixed
# and delete the work around in the dev.mk file
sqldelight = "2.0.0-alpha05"
sqlcipher-android = "4.5.3"
sqldelight = "2.0.0"
sqlcipher-android = "4.5.5"
pbandk = "0.14.2"
turbine = "1.0.0"
avs = "9.4.10"
jna = "5.6.0"
jna = "5.13.0"
core-crypto = "1.0.0-rc.12"
core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1"
completeKotlin = "1.1.0"
Expand Down Expand Up @@ -157,7 +157,7 @@ sqldelight-androidDriver = { module = "app.cash.sqldelight:android-driver", vers
sqldelight-androidxPaging = { module = "app.cash.sqldelight:androidx-paging3-extensions", version.ref = "sqldelight" }
sqldelight-nativeDriver = { module = "app.cash.sqldelight:native-driver", version.ref = "sqldelight" }
sqldelight-jvmDriver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" }
sqldelight-jsDriver = { module = "app.cash.sqldelight:sqljs-driver", version.ref = "sqldelight" }
sqldelight-jsDriver = { module = "app.cash.sqldelight:web-worker-driver", version.ref = "sqldelight" }
sqldelight-primitiveAdapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sqldelight" }
sqldelight-dialect = { module = "app.cash.sqldelight:sqlite-3-33-dialect", version.ref = "sqldelight" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ class CallManagerImpl : CallManager {
override suspend fun updateConversationClients(conversationId: ConversationId, clients: String) {
TODO("Not yet implemented")
}

override suspend fun reportProcessNotifications(isStarted: Boolean) {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ class CallManagerImpl internal constructor(
}
}

override suspend fun reportProcessNotifications(isStarted: Boolean) {
withCalling {
wcall_process_notifications(it, isStarted)
}
}

companion object {
private const val DEFAULT_REQUEST_VIDEO_STREAMS_MODE = 0
const val TAG = "CallManager"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ interface UserConfigRepository {
fun isSecondFactorPasswordChallengeRequired(): Either<StorageFailure, Boolean>
fun isReadReceiptsEnabled(): Flow<Either<StorageFailure, Boolean>>
fun setReadReceiptsStatus(enabled: Boolean): Either<StorageFailure, Unit>
fun isTypingIndicatorEnabled(): Flow<Either<StorageFailure, Boolean>>
fun setTypingIndicatorStatus(enabled: Boolean): Either<StorageFailure, Unit>
fun setGuestRoomStatus(status: Boolean, isStatusChanged: Boolean?): Either<StorageFailure, Unit>
fun getGuestRoomLinkStatus(): Either<StorageFailure, GuestRoomLinkStatus>
fun observeGuestRoomLinkFeatureFlag(): Flow<Either<StorageFailure, GuestRoomLinkStatus>>
Expand Down Expand Up @@ -200,13 +202,20 @@ class UserConfigDataSource(
}

override fun isReadReceiptsEnabled(): Flow<Either<StorageFailure, Boolean>> =
userConfigStorage.isReadReceiptsEnabled().wrapStorageRequest()
userConfigStorage.areReadReceiptsEnabled().wrapStorageRequest()

override fun setReadReceiptsStatus(enabled: Boolean): Either<StorageFailure, Unit> =
wrapStorageRequest {
userConfigStorage.persistReadReceipts(enabled)
}

override fun isTypingIndicatorEnabled(): Flow<Either<StorageFailure, Boolean>> =
userConfigStorage.isTypingIndicatorEnabled().wrapStorageRequest()

override fun setTypingIndicatorStatus(enabled: Boolean): Either<StorageFailure, Unit> = wrapStorageRequest {
userConfigStorage.persistTypingIndicator(enabled)
}

override fun setGuestRoomStatus(status: Boolean, isStatusChanged: Boolean?): Either<StorageFailure, Unit> =
wrapStorageRequest {
userConfigStorage.persistGuestRoomLinkFeatureFlag(status, isStatusChanged)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ enum class AttachmentType {
}

fun isDisplayableImageMimeType(mimeType: String): Boolean = mimeType in setOf(
"image/jpg", "image/jpeg", "image/png", "image/heic", "image/gif", "image/webp"
"image/jpg", "image/jpeg", "image/png", "image/gif", "image/webp"
)

fun isAudioMimeType(mimeType: String): Boolean = mimeType in setOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ internal class ConnectionDataSource(
accessRole = emptyList(),
receiptMode = ConversationEntity.ReceiptMode.DISABLED,
messageTimer = null,
userMessageTimer = null
userMessageTimer = null,
archived = false,
archivedInstant = null
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ data class Conversation(
val creatorId: String?,
val receiptMode: ReceiptMode,
val messageTimer: Duration?,
val userMessageTimer: Duration?
val userMessageTimer: Duration?,
val archived: Boolean,
val archivedDateTime: Instant?
) {

companion object {
Expand Down Expand Up @@ -295,7 +297,9 @@ sealed class ConversationDetails(open val conversation: Conversation) {
creatorId = null,
receiptMode = Conversation.ReceiptMode.DISABLED,
messageTimer = null,
userMessageTimer = null
userMessageTimer = null,
archived = false,
archivedDateTime = null
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,17 @@ internal class ConversationGroupRepositoryImpl(
userIdList,
apiResult.value as NetworkFailure.FederatedBackendFailure.RetryableFailure
)
// edge case, in case backend goes 🍌 and returns non-matching domains
if (failedUsers.isEmpty()) Either.Left(apiResult.value)
tryAddMembersToCloudAndStorage(validUsers, conversationId, failedUsers.toSet())
when (failedUsers.isNotEmpty()) {
true -> tryAddMembersToCloudAndStorage(validUsers, conversationId, failedUsers.toSet())
false -> {
newGroupConversationSystemMessagesCreator.value.conversationFailedToAddMembers(
conversationId,
(validUsers + failedUsers).toSet()
).flatMap {
Either.Left(apiResult.value)
}
}
}
} else {
newGroupConversationSystemMessagesCreator.value.conversationFailedToAddMembers(
conversationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ internal class ConversationMapperImpl(
receiptMode = receiptModeMapper.fromApiToDaoModel(apiModel.receiptMode),
messageTimer = apiModel.messageTimer,
userMessageTimer = null, // user picked self deletion timer is only persisted locally
hasIncompleteMetadata = false
hasIncompleteMetadata = false,
archived = apiModel.members.self.otrArchived ?: false,
archivedInstant = apiModel.members.self.otrArchivedRef?.toInstant()
)

override fun fromApiModelToDaoModel(apiModel: ConvProtocol): Protocol = when (apiModel) {
Expand Down Expand Up @@ -157,7 +159,9 @@ internal class ConversationMapperImpl(
creatorId = creatorId,
receiptMode = receiptModeMapper.fromEntityToModel(receiptMode),
messageTimer = messageTimer?.toDuration(DurationUnit.MILLISECONDS),
userMessageTimer = userMessageTimer?.toDuration(DurationUnit.MILLISECONDS)
userMessageTimer = userMessageTimer?.toDuration(DurationUnit.MILLISECONDS),
archived = archived,
archivedDateTime = archivedDateTime
)
}

Expand All @@ -180,7 +184,9 @@ internal class ConversationMapperImpl(
creatorId = creatorId,
receiptMode = receiptModeMapper.fromEntityToModel(receiptMode),
messageTimer = messageTimer?.toDuration(DurationUnit.MILLISECONDS),
userMessageTimer = userMessageTimer?.toDuration(DurationUnit.MILLISECONDS)
userMessageTimer = userMessageTimer?.toDuration(DurationUnit.MILLISECONDS),
archived = archived,
archivedDateTime = archivedInstant
)
}

Expand Down Expand Up @@ -371,6 +377,8 @@ internal class ConversationMapperImpl(
receiptMode = receiptModeMapper.toDaoModel(conversation.receiptMode),
messageTimer = messageTimer?.inWholeMilliseconds,
userMessageTimer = userMessageTimer?.inWholeMilliseconds,
archived = archived,
archivedInstant = archivedDateTime
)
}

Expand All @@ -396,7 +404,9 @@ internal class ConversationMapperImpl(
receiptMode = ConversationEntity.ReceiptMode.DISABLED,
messageTimer = null,
userMessageTimer = null,
hasIncompleteMetadata = true
hasIncompleteMetadata = true,
archived = false,
archivedInstant = null
)

private fun ConversationResponse.getProtocolInfo(mlsGroupState: GroupState?): ProtocolInfo {
Expand Down
Loading

0 comments on commit 5942ac1

Please sign in to comment.