mirror of
https://github.com/bitwarden/android.git
synced 2026-02-03 18:17:54 -06:00
Update test tools (#6468)
This commit is contained in:
parent
f4d34e4649
commit
aff8b0347b
@ -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)
|
||||
@ -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,
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user