Skip to content

Commit ec3462b

Browse files
committed
post rebase fix & cleaning
1 parent 2382684 commit ec3462b

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed

matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeTestConfig.kt renamed to matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeConfigTest.kt

+14-14
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ import org.junit.runners.JUnit4
2525
import org.junit.runners.MethodSorters
2626
import org.matrix.android.sdk.InstrumentedTest
2727
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
28+
import org.matrix.android.sdk.api.session.getRoom
2829
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
2930
import org.matrix.android.sdk.common.CommonTestHelper.Companion.runCryptoTest
3031

3132
@RunWith(JUnit4::class)
3233
@FixMethodOrder(MethodSorters.JVM)
3334
@LargeTest
34-
class E2eeTestConfig : InstrumentedTest {
35+
class E2eeConfigTest : InstrumentedTest {
3536

3637
@Test
3738
fun testBlacklistUnverifiedDefault() = runCryptoTest(context()) { cryptoTestHelper, _ ->
@@ -55,10 +56,8 @@ class E2eeTestConfig : InstrumentedTest {
5556

5657
val roomBobPOV = cryptoTestData.secondSession!!.roomService().getRoom(cryptoTestData.roomId)!!
5758
// ensure other received
58-
testHelper.waitWithLatch { latch ->
59-
testHelper.retryPeriodicallyWithLatch(latch) {
60-
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
61-
}
59+
testHelper.retryPeriodically {
60+
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
6261
}
6362

6463
cryptoTestHelper.ensureCannotDecrypt(listOf(sentMessage.eventId), cryptoTestData.secondSession!!, cryptoTestData.roomId)
@@ -81,10 +80,8 @@ class E2eeTestConfig : InstrumentedTest {
8180

8281
val roomBobPOV = cryptoTestData.secondSession!!.roomService().getRoom(cryptoTestData.roomId)!!
8382
// ensure other received
84-
testHelper.waitWithLatch { latch ->
85-
testHelper.retryPeriodicallyWithLatch(latch) {
86-
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
87-
}
83+
testHelper.retryPeriodically {
84+
roomBobPOV.timelineService().getTimelineEvent(sentMessage.eventId) != null
8885
}
8986

9087
cryptoTestHelper.ensureCanDecrypt(
@@ -105,10 +102,8 @@ class E2eeTestConfig : InstrumentedTest {
105102

106103
val roomBobPOV = cryptoTestData.secondSession!!.roomService().getRoom(cryptoTestData.roomId)!!
107104
// ensure other received
108-
testHelper.waitWithLatch { latch ->
109-
testHelper.retryPeriodicallyWithLatch(latch) {
110-
roomBobPOV.timelineService().getTimelineEvent(beforeMessage.eventId) != null
111-
}
105+
testHelper.retryPeriodically {
106+
roomBobPOV.timelineService().getTimelineEvent(beforeMessage.eventId) != null
112107
}
113108

114109
cryptoTestHelper.ensureCanDecrypt(
@@ -118,10 +113,15 @@ class E2eeTestConfig : InstrumentedTest {
118113
listOf(beforeMessage.getLastMessageContent()!!.body)
119114
)
120115

121-
cryptoTestData.firstSession.cryptoService().setRoomBlacklistUnverifiedDevices(cryptoTestData.roomId, true)
116+
cryptoTestData.firstSession.cryptoService().setRoomBlockUnverifiedDevices(cryptoTestData.roomId, true)
122117

123118
val afterMessage = testHelper.sendTextMessage(roomAlicePOV, "you are blocked", 1).first()
124119

120+
// ensure received
121+
testHelper.retryPeriodically {
122+
cryptoTestData.secondSession?.getRoom(cryptoTestData.roomId)?.timelineService()?.getTimelineEvent(afterMessage.eventId)?.root != null
123+
}
124+
125125
cryptoTestHelper.ensureCannotDecrypt(
126126
listOf(afterMessage.eventId),
127127
cryptoTestData.secondSession!!,

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ interface CryptoService {
104104
*/
105105
fun isShareKeysOnInviteEnabled(): Boolean
106106

107-
fun setRoomUnBlacklistUnverifiedDevices(roomId: String)
107+
fun setRoomUnBlockUnverifiedDevices(roomId: String)
108108

109109
fun getDeviceTrackingStatus(userId: String): Int
110110

@@ -116,7 +116,7 @@ interface CryptoService {
116116

117117
suspend fun exportRoomKeys(password: String): ByteArray
118118

119-
fun setRoomBlacklistUnverifiedDevices(roomId: String, enable: Boolean)
119+
fun setRoomBlockUnverifiedDevices(roomId: String, block: Boolean)
120120

121121
fun getCryptoDeviceInfo(userId: String, deviceId: String?): CryptoDeviceInfo?
122122

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/GlobalCryptoConfig.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 New Vector Ltd
2+
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
package org.matrix.android.sdk.api.session.crypto
1818

1919
data class GlobalCryptoConfig(
20-
val globalBlacklistUnverifiedDevices: Boolean,
20+
val globalBlockUnverifiedDevices: Boolean,
2121
val globalEnableKeyGossiping: Boolean,
2222
val enableKeyForwardingOnInvite: Boolean,
2323
)

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1194,19 +1194,19 @@ internal class DefaultCryptoService @Inject constructor(
11941194
* Add this room to the ones which don't encrypt messages to unverified devices.
11951195
*
11961196
* @param roomId the room id
1197-
* @param if true will block sending keys to unverified devices
1197+
* @param block if true will block sending keys to unverified devices
11981198
*/
1199-
override fun setRoomBlacklistUnverifiedDevices(roomId: String, enable: Boolean) {
1200-
cryptoStore.blackListUnverifiedDevicesInRoom(roomId, enable)
1199+
override fun setRoomBlockUnverifiedDevices(roomId: String, block: Boolean) {
1200+
cryptoStore.blockUnverifiedDevicesInRoom(roomId, block)
12011201
}
12021202

12031203
/**
12041204
* Remove this room to the ones which don't encrypt messages to unverified devices.
12051205
*
12061206
* @param roomId the room id
12071207
*/
1208-
override fun setRoomUnBlacklistUnverifiedDevices(roomId: String) {
1209-
setRoomBlacklistUnverifiedDevices(roomId, false)
1208+
override fun setRoomUnBlockUnverifiedDevices(roomId: String) {
1209+
setRoomBlockUnverifiedDevices(roomId, false)
12101210
}
12111211

12121212
/**

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/IMXCryptoStore.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ internal interface IMXCryptoStore {
138138
* Define if encryption keys should be sent to unverified devices in this room.
139139
*
140140
* @param roomId the roomId
141-
* @param blacklist if true will not send keys to unverified devices
141+
* @param block if true will not send keys to unverified devices
142142
*/
143-
fun blackListUnverifiedDevicesInRoom(roomId: String, blacklist: Boolean)
143+
fun blockUnverifiedDevicesInRoom(roomId: String, block: Boolean)
144144

145145
/**
146146
* Get the current keys backup version.

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ internal class RealmCryptoStore @Inject constructor(
451451
realm.where<CryptoMetadataEntity>().findFirst()
452452
?.let {
453453
GlobalCryptoConfig(
454-
globalBlacklistUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
454+
globalBlockUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
455455
globalEnableKeyGossiping = it.globalEnableKeyGossiping,
456456
enableKeyForwardingOnInvite = it.enableKeyForwardingOnInvite
457457
)
@@ -467,7 +467,7 @@ internal class RealmCryptoStore @Inject constructor(
467467
},
468468
{
469469
GlobalCryptoConfig(
470-
globalBlacklistUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
470+
globalBlockUnverifiedDevices = it.globalBlacklistUnverifiedDevices,
471471
globalEnableKeyGossiping = it.globalEnableKeyGossiping,
472472
enableKeyForwardingOnInvite = it.enableKeyForwardingOnInvite
473473
)
@@ -1121,10 +1121,10 @@ internal class RealmCryptoStore @Inject constructor(
11211121
}
11221122
}
11231123

1124-
override fun blackListUnverifiedDevicesInRoom(roomId: String, blacklist: Boolean) {
1124+
override fun blockUnverifiedDevicesInRoom(roomId: String, block: Boolean) {
11251125
doRealmTransaction(realmConfiguration) { realm ->
11261126
CryptoRoomEntity.getById(realm, roomId)
1127-
?.blacklistUnverifiedDevices = blacklist
1127+
?.blacklistUnverifiedDevices = block
11281128
}
11291129
}
11301130

vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsAction.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sealed class RoomSettingsAction : VectorViewModelAction {
2828
data class SetRoomHistoryVisibility(val visibility: RoomHistoryVisibility) : RoomSettingsAction()
2929
data class SetRoomJoinRule(val roomJoinRule: RoomJoinRules) : RoomSettingsAction()
3030
data class SetRoomGuestAccess(val guestAccess: GuestAccess) : RoomSettingsAction()
31-
data class SetEncryptToVerifiedDeviceOnly(val enable: Boolean) : RoomSettingsAction()
31+
data class SetEncryptToVerifiedDeviceOnly(val enabled: Boolean) : RoomSettingsAction()
3232

3333
object Save : RoomSettingsAction()
3434
object Cancel : RoomSettingsAction()

vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class RoomSettingsController @Inject constructor(
154154
buildProfileSection(stringProvider.getString(R.string.room_profile_section_security))
155155

156156
data.globalCryptoConfig.invoke()?.let { globalConfig ->
157-
if (globalConfig.globalBlacklistUnverifiedDevices) {
157+
if (globalConfig.globalBlockUnverifiedDevices) {
158158
genericFooterItem {
159159
id("globalConfig")
160160
centered(false)

vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsViewModel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class RoomSettingsViewModel @AssistedInject constructor(
252252
is RoomSettingsAction.SetRoomGuestAccess -> handleSetGuestAccess(action)
253253
is RoomSettingsAction.Save -> saveSettings()
254254
is RoomSettingsAction.Cancel -> cancel()
255-
is RoomSettingsAction.SetEncryptToVerifiedDeviceOnly -> setEncryptToVerifiedDeviceOnly(action.enable)
255+
is RoomSettingsAction.SetEncryptToVerifiedDeviceOnly -> setEncryptToVerifiedDeviceOnly(action.enabled)
256256
}
257257
}
258258

@@ -276,7 +276,7 @@ class RoomSettingsViewModel @AssistedInject constructor(
276276

277277
private fun setEncryptToVerifiedDeviceOnly(enabled: Boolean) {
278278
session.coroutineScope.launch {
279-
session.cryptoService().setRoomBlacklistUnverifiedDevices(room.roomId, enabled)
279+
session.cryptoService().setRoomBlockUnverifiedDevices(room.roomId, enabled)
280280
}
281281
}
282282

0 commit comments

Comments
 (0)