mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 03:49:04 +03:00
FIx unit test compilation
This commit is contained in:
parent
631ea50bde
commit
effbc47bd3
4 changed files with 89 additions and 83 deletions
|
@ -30,6 +30,7 @@ import org.junit.runners.MethodSorters
|
|||
import org.matrix.android.sdk.InstrumentedTest
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||
import org.matrix.android.sdk.api.session.crypto.RequestResult
|
||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersion
|
||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersionResult
|
||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.junit.runner.RunWith
|
|||
import org.junit.runners.MethodSorters
|
||||
import org.matrix.android.sdk.InstrumentedTest
|
||||
import org.matrix.android.sdk.api.session.crypto.OutgoingRoomKeyRequestState
|
||||
import org.matrix.android.sdk.api.session.crypto.RequestResult
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
|
||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||
|
@ -43,7 +44,6 @@ import org.matrix.android.sdk.common.CommonTestHelper
|
|||
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||
import org.matrix.android.sdk.common.SessionTestParams
|
||||
import org.matrix.android.sdk.common.TestConstants
|
||||
import org.matrix.android.sdk.internal.crypto.RequestResult
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.JVM)
|
||||
|
@ -172,8 +172,10 @@ class KeyShareTests : InstrumentedTest {
|
|||
}
|
||||
|
||||
// Mark the device as trusted
|
||||
aliceSession.cryptoService().setDeviceVerification(DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId,
|
||||
aliceSession2.sessionParams.deviceId ?: "")
|
||||
aliceSession.cryptoService().setDeviceVerification(
|
||||
DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId,
|
||||
aliceSession2.sessionParams.deviceId ?: ""
|
||||
)
|
||||
|
||||
// Re request
|
||||
aliceSession2.cryptoService().reRequestRoomKeyForEvent(receivedEvent.root)
|
||||
|
@ -252,7 +254,8 @@ class KeyShareTests : InstrumentedTest {
|
|||
commonTestHelper.waitWithLatch { latch ->
|
||||
commonTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||
val outgoing = aliceNewSession.cryptoService().getOutgoingRoomKeyRequests().firstOrNull { it.sessionId == sentEventMegolmSession }
|
||||
val ownDeviceReply = outgoing?.results?.firstOrNull { it.userId == aliceSession.myUserId && it.fromDevice == aliceSession.sessionParams.deviceId }
|
||||
val ownDeviceReply =
|
||||
outgoing?.results?.firstOrNull { it.userId == aliceSession.myUserId && it.fromDevice == aliceSession.sessionParams.deviceId }
|
||||
ownDeviceReply != null && ownDeviceReply.result is RequestResult.Success
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +353,8 @@ class KeyShareTests : InstrumentedTest {
|
|||
Log.v("TEST", "=========================")
|
||||
}
|
||||
val outgoing = aliceNewSession.cryptoService().getOutgoingRoomKeyRequests().firstOrNull { it.sessionId == sentEventMegolmSession }
|
||||
val ownDeviceReply = outgoing?.results?.firstOrNull { it.userId == aliceSession.myUserId && it.fromDevice == aliceSession.sessionParams.deviceId }
|
||||
val ownDeviceReply =
|
||||
outgoing?.results?.firstOrNull { it.userId == aliceSession.myUserId && it.fromDevice == aliceSession.sessionParams.deviceId }
|
||||
val result = ownDeviceReply?.result
|
||||
result != null && result is RequestResult.Success && result.chainIndex == 0
|
||||
}
|
||||
|
@ -455,7 +459,8 @@ class KeyShareTests : InstrumentedTest {
|
|||
commonTestHelper.waitWithLatch { latch ->
|
||||
commonTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||
val outgoing = aliceNewSession.cryptoService().getOutgoingRoomKeyRequests().firstOrNull { it.sessionId == sentEventMegolmSession }
|
||||
val ownDeviceReply = outgoing?.results?.firstOrNull { it.userId == aliceSession.myUserId && it.fromDevice == aliceSession.sessionParams.deviceId }
|
||||
val ownDeviceReply =
|
||||
outgoing?.results?.firstOrNull { it.userId == aliceSession.myUserId && it.fromDevice == aliceSession.sessionParams.deviceId }
|
||||
val result = ownDeviceReply?.result
|
||||
result != null && result is RequestResult.Success && result.chainIndex == 0
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.matrix.android.sdk.InstrumentedTest
|
|||
import org.matrix.android.sdk.api.NoOpMatrixCallback
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||
import org.matrix.android.sdk.api.session.crypto.RequestResult
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||
|
@ -38,7 +39,6 @@ import org.matrix.android.sdk.common.CryptoTestHelper
|
|||
import org.matrix.android.sdk.common.MockOkHttpInterceptor
|
||||
import org.matrix.android.sdk.common.SessionTestParams
|
||||
import org.matrix.android.sdk.common.TestConstants
|
||||
import org.matrix.android.sdk.internal.crypto.RequestResult
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@FixMethodOrder(MethodSorters.JVM)
|
||||
|
|
|
@ -1,76 +1,76 @@
|
|||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.api.session.crypto.model
|
||||
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||
|
||||
enum class TrailType {
|
||||
OutgoingKeyForward,
|
||||
IncomingKeyForward,
|
||||
OutgoingKeyWithheld,
|
||||
IncomingKeyRequest,
|
||||
Unknown
|
||||
}
|
||||
|
||||
interface AuditInfo {
|
||||
val roomId: String
|
||||
val sessionId: String
|
||||
val senderKey: String
|
||||
val alg: String
|
||||
val userId: String
|
||||
val deviceId: String
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ForwardInfo(
|
||||
override val roomId: String,
|
||||
override val sessionId: String,
|
||||
override val senderKey: String,
|
||||
override val alg: String,
|
||||
override val userId: String,
|
||||
override val deviceId: String,
|
||||
val chainIndex: Long?
|
||||
) : AuditInfo
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class WithheldInfo(
|
||||
override val roomId: String,
|
||||
override val sessionId: String,
|
||||
override val senderKey: String,
|
||||
override val alg: String,
|
||||
val code: WithHeldCode,
|
||||
override val userId: String,
|
||||
override val deviceId: String
|
||||
) : AuditInfo
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class IncomingKeyRequestInfo(
|
||||
override val roomId: String,
|
||||
override val sessionId: String,
|
||||
override val senderKey: String,
|
||||
override val alg: String,
|
||||
override val userId: String,
|
||||
override val deviceId: String,
|
||||
val requestId: String
|
||||
) : AuditInfo
|
||||
|
||||
data class AuditTrail(
|
||||
val ageLocalTs: Long,
|
||||
val type: TrailType,
|
||||
val info: AuditInfo
|
||||
)
|
||||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.api.session.crypto.model
|
||||
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||
|
||||
enum class TrailType {
|
||||
OutgoingKeyForward,
|
||||
IncomingKeyForward,
|
||||
OutgoingKeyWithheld,
|
||||
IncomingKeyRequest,
|
||||
Unknown
|
||||
}
|
||||
|
||||
interface AuditInfo {
|
||||
val roomId: String
|
||||
val sessionId: String
|
||||
val senderKey: String
|
||||
val alg: String
|
||||
val userId: String
|
||||
val deviceId: String
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ForwardInfo(
|
||||
override val roomId: String,
|
||||
override val sessionId: String,
|
||||
override val senderKey: String,
|
||||
override val alg: String,
|
||||
override val userId: String,
|
||||
override val deviceId: String,
|
||||
val chainIndex: Long?
|
||||
) : AuditInfo
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class WithheldInfo(
|
||||
override val roomId: String,
|
||||
override val sessionId: String,
|
||||
override val senderKey: String,
|
||||
override val alg: String,
|
||||
val code: WithHeldCode,
|
||||
override val userId: String,
|
||||
override val deviceId: String
|
||||
) : AuditInfo
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class IncomingKeyRequestInfo(
|
||||
override val roomId: String,
|
||||
override val sessionId: String,
|
||||
override val senderKey: String,
|
||||
override val alg: String,
|
||||
override val userId: String,
|
||||
override val deviceId: String,
|
||||
val requestId: String
|
||||
) : AuditInfo
|
||||
|
||||
data class AuditTrail(
|
||||
val ageLocalTs: Long,
|
||||
val type: TrailType,
|
||||
val info: AuditInfo
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue