post rebase fix & cleaning

This commit is contained in:
Valere 2022-09-30 17:37:33 +02:00
parent 92a72cb1e9
commit f7d8356327
9 changed files with 33 additions and 33 deletions

View File

@ -25,13 +25,14 @@ import org.junit.runners.JUnit4
import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.getRoom
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
import org.matrix.android.sdk.common.CommonTestHelper.Companion.runCryptoTest
@RunWith(JUnit4::class)
@FixMethodOrder(MethodSorters.JVM)
@LargeTest
class E2eeTestConfig : InstrumentedTest {
class E2eeConfigTest : InstrumentedTest {
@Test
fun testBlacklistUnverifiedDefault() = runCryptoTest(context()) { cryptoTestHelper, _ ->
@ -55,10 +56,8 @@ class E2eeTestConfig : InstrumentedTest {
val roomBobPOV = cryptoTestData.secondSession!!.roomService().getRoom(cryptoTestData.roomId)!!
// ensure other received
testHelper.waitWithLatch { latch ->
testHelper.retryPeriodicallyWithLatch(latch) {
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
}
testHelper.retryPeriodically {
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
}
cryptoTestHelper.ensureCannotDecrypt(listOf(sentMessage.eventId), cryptoTestData.secondSession!!, cryptoTestData.roomId)
@ -81,10 +80,8 @@ class E2eeTestConfig : InstrumentedTest {
val roomBobPOV = cryptoTestData.secondSession!!.roomService().getRoom(cryptoTestData.roomId)!!
// ensure other received
testHelper.waitWithLatch { latch ->
testHelper.retryPeriodicallyWithLatch(latch) {
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
}
testHelper.retryPeriodically {
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
}
cryptoTestHelper.ensureCanDecrypt(
@ -105,10 +102,8 @@ class E2eeTestConfig : InstrumentedTest {
val roomBobPOV = cryptoTestData.secondSession!!.roomService().getRoom(cryptoTestData.roomId)!!
// ensure other received
testHelper.waitWithLatch { latch ->
testHelper.retryPeriodicallyWithLatch(latch) {
roomBobPOV.timelineService().getTimelineEvent(beforeMessage.eventId) != null
}
testHelper.retryPeriodically {
roomBobPOV.timelineService().getTimelineEvent(beforeMessage.eventId) != null
}
cryptoTestHelper.ensureCanDecrypt(
@ -118,10 +113,15 @@ class E2eeTestConfig : InstrumentedTest {
listOf(beforeMessage.getLastMessageContent()!!.body)
)
cryptoTestData.firstSession.cryptoService().setRoomBlacklistUnverifiedDevices(cryptoTestData.roomId, true)
cryptoTestData.firstSession.cryptoService().setRoomBlockUnverifiedDevices(cryptoTestData.roomId, true)
val afterMessage = testHelper.sendTextMessage(roomAlicePOV, "you are blocked", 1).first()
// ensure received
testHelper.retryPeriodically {
cryptoTestData.secondSession?.getRoom(cryptoTestData.roomId)?.timelineService()?.getTimelineEvent(afterMessage.eventId)?.root != null
}
cryptoTestHelper.ensureCannotDecrypt(
listOf(afterMessage.eventId),
cryptoTestData.secondSession!!,

View File

@ -104,7 +104,7 @@ interface CryptoService {
*/
fun isShareKeysOnInviteEnabled(): Boolean
fun setRoomUnBlacklistUnverifiedDevices(roomId: String)
fun setRoomUnBlockUnverifiedDevices(roomId: String)
fun getDeviceTrackingStatus(userId: String): Int
@ -116,7 +116,7 @@ interface CryptoService {
suspend fun exportRoomKeys(password: String): ByteArray
fun setRoomBlacklistUnverifiedDevices(roomId: String, enable: Boolean)
fun setRoomBlockUnverifiedDevices(roomId: String, block: Boolean)
fun getCryptoDeviceInfo(userId: String, deviceId: String?): CryptoDeviceInfo?

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 New Vector Ltd
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.matrix.android.sdk.api.session.crypto
data class GlobalCryptoConfig(
val globalBlacklistUnverifiedDevices: Boolean,
val globalBlockUnverifiedDevices: Boolean,
val globalEnableKeyGossiping: Boolean,
val enableKeyForwardingOnInvite: Boolean,
)

View File

@ -1194,10 +1194,10 @@ internal class DefaultCryptoService @Inject constructor(
* Add this room to the ones which don't encrypt messages to unverified devices.
*
* @param roomId the room id
* @param if true will block sending keys to unverified devices
* @param block if true will block sending keys to unverified devices
*/
override fun setRoomBlacklistUnverifiedDevices(roomId: String, enable: Boolean) {
cryptoStore.blackListUnverifiedDevicesInRoom(roomId, enable)
override fun setRoomBlockUnverifiedDevices(roomId: String, block: Boolean) {
cryptoStore.blockUnverifiedDevicesInRoom(roomId, block)
}
/**
@ -1205,8 +1205,8 @@ internal class DefaultCryptoService @Inject constructor(
*
* @param roomId the room id
*/
override fun setRoomUnBlacklistUnverifiedDevices(roomId: String) {
setRoomBlacklistUnverifiedDevices(roomId, false)
override fun setRoomUnBlockUnverifiedDevices(roomId: String) {
setRoomBlockUnverifiedDevices(roomId, false)
}
/**

View File

@ -138,9 +138,9 @@ internal interface IMXCryptoStore {
* Define if encryption keys should be sent to unverified devices in this room.
*
* @param roomId the roomId
* @param blacklist if true will not send keys to unverified devices
* @param block if true will not send keys to unverified devices
*/
fun blackListUnverifiedDevicesInRoom(roomId: String, blacklist: Boolean)
fun blockUnverifiedDevicesInRoom(roomId: String, block: Boolean)
/**
* Get the current keys backup version.

View File

@ -451,7 +451,7 @@ internal class RealmCryptoStore @Inject constructor(
realm.where<CryptoMetadataEntity>().findFirst()
?.let {
GlobalCryptoConfig(
globalBlacklistUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
globalBlockUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
globalEnableKeyGossiping = it.globalEnableKeyGossiping,
enableKeyForwardingOnInvite = it.enableKeyForwardingOnInvite
)
@ -467,7 +467,7 @@ internal class RealmCryptoStore @Inject constructor(
},
{
GlobalCryptoConfig(
globalBlacklistUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
globalBlockUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
globalEnableKeyGossiping = it.globalEnableKeyGossiping,
enableKeyForwardingOnInvite = it.enableKeyForwardingOnInvite
)
@ -1121,10 +1121,10 @@ internal class RealmCryptoStore @Inject constructor(
}
}
override fun blackListUnverifiedDevicesInRoom(roomId: String, blacklist: Boolean) {
override fun blockUnverifiedDevicesInRoom(roomId: String, block: Boolean) {
doRealmTransaction(realmConfiguration) { realm ->
CryptoRoomEntity.getById(realm, roomId)
?.blacklistUnverifiedDevices = blacklist
?.blacklistUnverifiedDevices = block
}
}

View File

@ -28,7 +28,7 @@ sealed class RoomSettingsAction : VectorViewModelAction {
data class SetRoomHistoryVisibility(val visibility: RoomHistoryVisibility) : RoomSettingsAction()
data class SetRoomJoinRule(val roomJoinRule: RoomJoinRules) : RoomSettingsAction()
data class SetRoomGuestAccess(val guestAccess: GuestAccess) : RoomSettingsAction()
data class SetEncryptToVerifiedDeviceOnly(val enable: Boolean) : RoomSettingsAction()
data class SetEncryptToVerifiedDeviceOnly(val enabled: Boolean) : RoomSettingsAction()
object Save : RoomSettingsAction()
object Cancel : RoomSettingsAction()

View File

@ -154,7 +154,7 @@ class RoomSettingsController @Inject constructor(
buildProfileSection(stringProvider.getString(R.string.room_profile_section_security))
data.globalCryptoConfig.invoke()?.let { globalConfig ->
if (globalConfig.globalBlacklistUnverifiedDevices) {
if (globalConfig.globalBlockUnverifiedDevices) {
genericFooterItem {
id("globalConfig")
centered(false)

View File

@ -252,7 +252,7 @@ class RoomSettingsViewModel @AssistedInject constructor(
is RoomSettingsAction.SetRoomGuestAccess -> handleSetGuestAccess(action)
is RoomSettingsAction.Save -> saveSettings()
is RoomSettingsAction.Cancel -> cancel()
is RoomSettingsAction.SetEncryptToVerifiedDeviceOnly -> setEncryptToVerifiedDeviceOnly(action.enable)
is RoomSettingsAction.SetEncryptToVerifiedDeviceOnly -> setEncryptToVerifiedDeviceOnly(action.enabled)
}
}
@ -276,7 +276,7 @@ class RoomSettingsViewModel @AssistedInject constructor(
private fun setEncryptToVerifiedDeviceOnly(enabled: Boolean) {
session.coroutineScope.launch {
session.cryptoService().setRoomBlacklistUnverifiedDevices(room.roomId, enabled)
session.cryptoService().setRoomBlockUnverifiedDevices(room.roomId, enabled)
}
}