From aff8b0347b0751fac474b928ce7fbf7de33c02e0 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 3 Feb 2026 15:54:42 -0600 Subject: [PATCH] Update test tools (#6468) --- .../vault/repository/VaultRepositoryTest.kt | 38 ++++++------------- gradle/libs.versions.toml | 4 +- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt b/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt index 38f2f01adc..c339ccb1b0 100644 --- a/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt +++ b/app/src/test/kotlin/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt @@ -201,8 +201,9 @@ class VaultRepositoryTest { val biometricsKey = "asdf1234" fakeAuthDiskSource.userState = MOCK_USER_STATE val initVector = byteArrayOf(2, 2) + val error = BadPaddingException() val cipher = mockk { - every { doFinal(any()) } throws BadPaddingException() + every { doFinal(any()) } throws error } fakeAuthDiskSource.apply { storeUserBiometricInitVector(userId = userId, iv = initVector) @@ -213,9 +214,7 @@ class VaultRepositoryTest { val result = vaultRepository.unlockVaultWithBiometrics(cipher = cipher) assertEquals( - VaultUnlockResult.BiometricDecodingError( - error = MissingPropertyException("Foo"), - ), + VaultUnlockResult.BiometricDecodingError(error = error), result, ) } @@ -499,30 +498,10 @@ class VaultRepositoryTest { ) } - @Test - fun `unlockVaultWithMasterPassword with missing user key should return InvalidStateError`() = - runTest { - val result = vaultRepository.unlockVaultWithMasterPassword(masterPassword = "") - fakeAuthDiskSource.storeUserKey( - userId = "mockId-1", - userKey = null, - ) - fakeAuthDiskSource.storePrivateKey( - userId = "mockId-1", - privateKey = "mockPrivateKey-1", - ) - fakeAuthDiskSource.userState = MOCK_USER_STATE - assertEquals( - VaultUnlockResult.InvalidStateError(error = MissingPropertyException("Foo")), - result, - ) - } - @Suppress("MaxLineLength") @Test fun `unlockVaultWithMasterPassword with missing private key should return InvalidStateError`() = runTest { - val result = vaultRepository.unlockVaultWithMasterPassword(masterPassword = "") fakeAuthDiskSource.storeUserKey( userId = "mockId-1", userKey = "mockKey-1", @@ -532,6 +511,9 @@ class VaultRepositoryTest { privateKey = null, ) fakeAuthDiskSource.userState = MOCK_USER_STATE + + val result = vaultRepository.unlockVaultWithMasterPassword(masterPassword = "") + assertEquals( VaultUnlockResult.InvalidStateError(error = MissingPropertyException("Foo")), result, @@ -741,7 +723,6 @@ class VaultRepositoryTest { @Test fun `unlockVaultWithPin with missing pin-protected user key should return InvalidStateError`() = runTest { - val result = vaultRepository.unlockVaultWithPin(pin = "1234") fakeAuthDiskSource.storePinProtectedUserKey( userId = "mockId-1", pinProtectedUserKey = null, @@ -755,6 +736,9 @@ class VaultRepositoryTest { privateKey = "mockPrivateKey-1", ) fakeAuthDiskSource.userState = MOCK_USER_STATE + + val result = vaultRepository.unlockVaultWithPin(pin = "1234") + assertEquals( VaultUnlockResult.InvalidStateError(error = MissingPropertyException("Foo")), result, @@ -763,7 +747,6 @@ class VaultRepositoryTest { @Test fun `unlockVaultWithPin with missing private key should return InvalidStateError`() = runTest { - val result = vaultRepository.unlockVaultWithPin(pin = "1234") fakeAuthDiskSource.storePinProtectedUserKey( userId = "mockId-1", pinProtectedUserKey = "mockKey-1", @@ -777,6 +760,9 @@ class VaultRepositoryTest { privateKey = null, ) fakeAuthDiskSource.userState = MOCK_USER_STATE + + val result = vaultRepository.unlockVaultWithPin(pin = "1234") + assertEquals( VaultUnlockResult.InvalidStateError(error = MissingPropertyException("Foo")), result, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 732d1abd95..34698b8682 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,9 +48,9 @@ kotlin = "2.3.0" kotlinxCollectionsImmutable = "0.4.0" kotlinxCoroutines = "1.10.2" kotlinxSerialization = "1.10.0" -kotlinxKover = "0.9.4" +kotlinxKover = "0.9.5" ksp = "2.3.4" -mockk = "1.14.7" +mockk = "1.14.9" okhttp = "5.3.2" retrofitBom = "3.0.0" robolectric = "4.16.1"