Update UtdTracker tests
This commit is contained in:
parent
39a235a84e
commit
f29dd2961a
2 changed files with 107 additions and 7 deletions
|
|
@ -25,6 +25,7 @@ class UtdTrackerTest {
|
|||
eventId = AN_EVENT_ID.value,
|
||||
timeToDecryptMs = null,
|
||||
cause = UtdCause.UNKNOWN,
|
||||
eventLocalAgeMillis = 100L,
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.capturedEvents).containsExactly(
|
||||
|
|
@ -34,7 +35,11 @@ class UtdTrackerTest {
|
|||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = -1,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.OlmKeysNotSentError
|
||||
name = Error.Name.OlmKeysNotSentError,
|
||||
isFederated = false,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 100,
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
||||
|
|
@ -59,7 +64,11 @@ class UtdTrackerTest {
|
|||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = 123,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.OlmKeysNotSentError
|
||||
name = Error.Name.OlmKeysNotSentError,
|
||||
isFederated = false,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
||||
|
|
@ -84,7 +93,11 @@ class UtdTrackerTest {
|
|||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = 123,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.ExpectedDueToMembership
|
||||
name = Error.Name.ExpectedDueToMembership,
|
||||
isFederated = false,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
||||
|
|
@ -109,7 +122,11 @@ class UtdTrackerTest {
|
|||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = 123,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.ExpectedSentByInsecureDevice
|
||||
name = Error.Name.ExpectedSentByInsecureDevice,
|
||||
isFederated = false,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -132,7 +149,90 @@ class UtdTrackerTest {
|
|||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = 123,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.ExpectedVerificationViolation
|
||||
name = Error.Name.ExpectedVerificationViolation,
|
||||
isFederated = false,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when onUtd is called with different sender and receiver servers, the expected analytics Event is sent`() {
|
||||
val fakeAnalyticsService = FakeAnalyticsService()
|
||||
val sut = UtdTracker(fakeAnalyticsService)
|
||||
sut.onUtd(
|
||||
aRustUnableToDecryptInfo(
|
||||
eventId = AN_EVENT_ID.value,
|
||||
ownHomeserver = "example.com",
|
||||
senderHomeserver = "matrix.org",
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.capturedEvents).containsExactly(
|
||||
Error(
|
||||
context = null,
|
||||
cryptoModule = Error.CryptoModule.Rust,
|
||||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = -1,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.OlmKeysNotSentError,
|
||||
isFederated = true,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when onUtd is called from a matrix-org user, the expected analytics Event is sent`() {
|
||||
val fakeAnalyticsService = FakeAnalyticsService()
|
||||
val sut = UtdTracker(fakeAnalyticsService)
|
||||
sut.onUtd(
|
||||
aRustUnableToDecryptInfo(
|
||||
eventId = AN_EVENT_ID.value,
|
||||
ownHomeserver = "matrix.org",
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.capturedEvents).containsExactly(
|
||||
Error(
|
||||
context = null,
|
||||
cryptoModule = Error.CryptoModule.Rust,
|
||||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = -1,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.OlmKeysNotSentError,
|
||||
isFederated = true,
|
||||
isMatrixDotOrg = true,
|
||||
userTrustsOwnIdentity = false,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when onUtd is called from a verified device, the expected analytics Event is sent`() {
|
||||
val fakeAnalyticsService = FakeAnalyticsService()
|
||||
val sut = UtdTracker(fakeAnalyticsService)
|
||||
sut.onUtd(
|
||||
aRustUnableToDecryptInfo(
|
||||
eventId = AN_EVENT_ID.value,
|
||||
userTrustsOwnIdentity = true,
|
||||
)
|
||||
)
|
||||
assertThat(fakeAnalyticsService.capturedEvents).containsExactly(
|
||||
Error(
|
||||
context = null,
|
||||
cryptoModule = Error.CryptoModule.Rust,
|
||||
cryptoSDK = Error.CryptoSDK.Rust,
|
||||
timeToDecryptMillis = -1,
|
||||
domain = Error.Domain.E2EE,
|
||||
name = Error.Name.OlmKeysNotSentError,
|
||||
isFederated = false,
|
||||
isMatrixDotOrg = false,
|
||||
userTrustsOwnIdentity = true,
|
||||
eventLocalAgeMillis = 0,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import uniffi.matrix_sdk_crypto.UtdCause
|
|||
|
||||
internal fun aRustUnableToDecryptInfo(
|
||||
eventId: String,
|
||||
timeToDecryptMs: ULong?,
|
||||
cause: UtdCause,
|
||||
timeToDecryptMs: ULong? = null,
|
||||
cause: UtdCause = UtdCause.UNKNOWN,
|
||||
eventLocalAgeMillis: Long = 0L,
|
||||
userTrustsOwnIdentity: Boolean = false,
|
||||
senderHomeserver: String = "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue