@@ -4,32 +4,91 @@ import android.security.keystore.UserNotAuthenticatedException
44import org.junit.jupiter.params.ParameterizedTest
55import org.junit.jupiter.params.provider.Arguments
66import org.junit.jupiter.params.provider.MethodSource
7- import kotlin.UnsupportedOperationException
7+ import java.lang.IllegalStateException
8+ import java.lang.IndexOutOfBoundsException
9+ import java.security.GeneralSecurityException
10+ import java.security.InvalidAlgorithmParameterException
11+ import java.security.InvalidKeyException
12+ import java.security.KeyStoreException
13+ import java.security.NoSuchAlgorithmException
14+ import java.security.UnrecoverableKeyException
15+ import javax.crypto.AEADBadTagException
16+ import javax.crypto.BadPaddingException
17+ import javax.crypto.NoSuchPaddingException
818import kotlin.test.assertEquals
919
1020class ErrorTypeHandlerV2Test {
1121 @ParameterizedTest
1222 @MethodSource(" getData" )
13- fun testHandler (error : SecureStorageError , expectedType : SecureStoreErrorType ) {
14- val actualType = ErrorTypeHandler .getErrorType(error)
23+ fun testHandler (error : SecureStorageErrorV2 , expectedType : SecureStoreErrorTypeV2 ) {
24+ val actualType = ErrorTypeHandlerV2 .getErrorType(error)
1525 assertEquals(expectedType, actualType)
1626 }
1727
1828 companion object {
29+ @Suppress(" LongMethod" )
1930 @JvmStatic
2031 fun getData (): List <Arguments > {
2132 return listOf (
2233 Arguments .of(
23- SecureStorageError ( UserNotAuthenticatedException ()),
24- SecureStoreErrorType . USER_CANCELED_BIO_PROMPT ,
34+ SecureStorageErrorV2 ( AEADBadTagException ()),
35+ SecureStoreErrorTypeV2 . UNRECOVERABLE ,
2536 ),
2637 Arguments .of(
27- SecureStorageError ( UnsupportedOperationException ()),
28- SecureStoreErrorType . USER_CANCELED_BIO_PROMPT ,
38+ SecureStorageErrorV2 ( UnrecoverableKeyException ()),
39+ SecureStoreErrorTypeV2 . UNRECOVERABLE ,
2940 ),
3041 Arguments .of(
31- SecureStorageError (Exception ()),
32- SecureStoreErrorType .GENERAL ,
42+ SecureStorageErrorV2 (BadPaddingException ()),
43+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
44+ ),
45+ Arguments .of(
46+ SecureStorageErrorV2 (UserNotAuthenticatedException ()),
47+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
48+ ),
49+ Arguments .of(
50+ SecureStorageErrorV2 (NoSuchAlgorithmException ()),
51+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
52+ ),
53+ Arguments .of(
54+ SecureStorageErrorV2 (NoSuchPaddingException ()),
55+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
56+ ),
57+ Arguments .of(
58+ SecureStorageErrorV2 (java.lang.UnsupportedOperationException ()),
59+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
60+ ),
61+ Arguments .of(
62+ SecureStorageErrorV2 (InvalidKeyException ()),
63+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
64+ ),
65+ Arguments .of(
66+ SecureStorageErrorV2 (UnrecoverableKeyException ()),
67+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
68+ ),
69+ Arguments .of(
70+ SecureStorageErrorV2 (KeyStoreException ()),
71+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
72+ ),
73+ Arguments .of(
74+ SecureStorageErrorV2 (IllegalStateException ()),
75+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
76+ ),
77+ Arguments .of(
78+ SecureStorageErrorV2 (InvalidAlgorithmParameterException ()),
79+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
80+ ),
81+ Arguments .of(
82+ SecureStorageErrorV2 (IndexOutOfBoundsException ()),
83+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
84+ ),
85+ Arguments .of(
86+ SecureStorageErrorV2 (GeneralSecurityException ()),
87+ SecureStoreErrorTypeV2 .UNRECOVERABLE ,
88+ ),
89+ Arguments .of(
90+ SecureStorageErrorV2 (Exception ()),
91+ SecureStoreErrorTypeV2 .RECOVERABLE ,
3392 ),
3493 )
3594 }
0 commit comments