Update UtdTracker tests
This commit is contained in:
parent
65abdb656b
commit
4f024c1fd9
2 changed files with 107 additions and 7 deletions
|
|
@ -25,6 +25,7 @@ class UtdTrackerTest {
|
||||||
eventId = AN_EVENT_ID.value,
|
eventId = AN_EVENT_ID.value,
|
||||||
timeToDecryptMs = null,
|
timeToDecryptMs = null,
|
||||||
cause = UtdCause.UNKNOWN,
|
cause = UtdCause.UNKNOWN,
|
||||||
|
eventLocalAgeMillis = 100L,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assertThat(fakeAnalyticsService.capturedEvents).containsExactly(
|
assertThat(fakeAnalyticsService.capturedEvents).containsExactly(
|
||||||
|
|
@ -34,7 +35,11 @@ class UtdTrackerTest {
|
||||||
cryptoSDK = Error.CryptoSDK.Rust,
|
cryptoSDK = Error.CryptoSDK.Rust,
|
||||||
timeToDecryptMillis = -1,
|
timeToDecryptMillis = -1,
|
||||||
domain = Error.Domain.E2EE,
|
domain = Error.Domain.E2EE,
|
||||||
name = Error.Name.OlmKeysNotSentError
|
name = Error.Name.OlmKeysNotSentError,
|
||||||
|
isFederated = false,
|
||||||
|
isMatrixDotOrg = false,
|
||||||
|
userTrustsOwnIdentity = false,
|
||||||
|
eventLocalAgeMillis = 100,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
||||||
|
|
@ -59,7 +64,11 @@ class UtdTrackerTest {
|
||||||
cryptoSDK = Error.CryptoSDK.Rust,
|
cryptoSDK = Error.CryptoSDK.Rust,
|
||||||
timeToDecryptMillis = 123,
|
timeToDecryptMillis = 123,
|
||||||
domain = Error.Domain.E2EE,
|
domain = Error.Domain.E2EE,
|
||||||
name = Error.Name.OlmKeysNotSentError
|
name = Error.Name.OlmKeysNotSentError,
|
||||||
|
isFederated = false,
|
||||||
|
isMatrixDotOrg = false,
|
||||||
|
userTrustsOwnIdentity = false,
|
||||||
|
eventLocalAgeMillis = 0,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
||||||
|
|
@ -84,7 +93,11 @@ class UtdTrackerTest {
|
||||||
cryptoSDK = Error.CryptoSDK.Rust,
|
cryptoSDK = Error.CryptoSDK.Rust,
|
||||||
timeToDecryptMillis = 123,
|
timeToDecryptMillis = 123,
|
||||||
domain = Error.Domain.E2EE,
|
domain = Error.Domain.E2EE,
|
||||||
name = Error.Name.ExpectedDueToMembership
|
name = Error.Name.ExpectedDueToMembership,
|
||||||
|
isFederated = false,
|
||||||
|
isMatrixDotOrg = false,
|
||||||
|
userTrustsOwnIdentity = false,
|
||||||
|
eventLocalAgeMillis = 0,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
assertThat(fakeAnalyticsService.screenEvents).isEmpty()
|
||||||
|
|
@ -109,7 +122,11 @@ class UtdTrackerTest {
|
||||||
cryptoSDK = Error.CryptoSDK.Rust,
|
cryptoSDK = Error.CryptoSDK.Rust,
|
||||||
timeToDecryptMillis = 123,
|
timeToDecryptMillis = 123,
|
||||||
domain = Error.Domain.E2EE,
|
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,
|
cryptoSDK = Error.CryptoSDK.Rust,
|
||||||
timeToDecryptMillis = 123,
|
timeToDecryptMillis = 123,
|
||||||
domain = Error.Domain.E2EE,
|
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(
|
internal fun aRustUnableToDecryptInfo(
|
||||||
eventId: String,
|
eventId: String,
|
||||||
timeToDecryptMs: ULong?,
|
timeToDecryptMs: ULong? = null,
|
||||||
cause: UtdCause,
|
cause: UtdCause = UtdCause.UNKNOWN,
|
||||||
eventLocalAgeMillis: Long = 0L,
|
eventLocalAgeMillis: Long = 0L,
|
||||||
userTrustsOwnIdentity: Boolean = false,
|
userTrustsOwnIdentity: Boolean = false,
|
||||||
senderHomeserver: String = "",
|
senderHomeserver: String = "",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue