CredentialProtectionExtensionAuthenticatorInput implements RegistrationExtensionAuthenticatorInput { @Override public Serializable getValue(String key) { if (KEY_CRED_PROTECT.equals(key)) { return credProtect; } throw new IllegalArgumentException(String.format("%s is not valid key.", key)); } CredentialProtectionExtensionAuthenticatorInput(CredentialProtectionPolicy credProtect); @Override String getIdentifier(); CredentialProtectionPolicy getCredProtect(); @Override Serializable getValue(String key); @Override void validate(); static final String ID; static final String KEY_CRED_PROTECT; }
@Test void getValue_with_valid_key_test(){ CredentialProtectionExtensionAuthenticatorInput target = new CredentialProtectionExtensionAuthenticatorInput(CredentialProtectionPolicy.USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST); assertThatCode(()->target.getValue("credProtect")).doesNotThrowAnyException(); }
@Test void getValue_with_invalid_key_test(){ CredentialProtectionExtensionAuthenticatorInput target = new CredentialProtectionExtensionAuthenticatorInput(CredentialProtectionPolicy.USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST); assertThatThrownBy(()->target.getValue("invalid")).isInstanceOf(IllegalArgumentException.class); }