Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cipher> {
every { doFinal(any()) } throws BadPaddingException()
every { doFinal(any()) } throws error
}
fakeAuthDiskSource.apply {
storeUserBiometricInitVector(userId = userId, iv = initVector)
Expand All @@ -213,9 +214,7 @@ class VaultRepositoryTest {
val result = vaultRepository.unlockVaultWithBiometrics(cipher = cipher)

assertEquals(
VaultUnlockResult.BiometricDecodingError(
error = MissingPropertyException("Foo"),
),
VaultUnlockResult.BiometricDecodingError(error = error),
result,
)
}
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading