CredentialProtectionExtensionAuthenticatorOutput implements RegistrationExtensionAuthenticatorOutput { @Override public Serializable getValue(String key) { if(!key.equals(KEY_CRED_PROTECT)){ throw new IllegalArgumentException(String.format("%s is the only valid key.", getIdentifier())); } return credProtect; } CredentialProtectionExtensionAuthenticatorOutput(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(){ CredentialProtectionExtensionAuthenticatorOutput target = new CredentialProtectionExtensionAuthenticatorOutput(CredentialProtectionPolicy.USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST); assertThatCode(()->target.getValue("credProtect")).doesNotThrowAnyException(); }
@Test void getValue_with_invalid_key_test(){ CredentialProtectionExtensionAuthenticatorOutput target = new CredentialProtectionExtensionAuthenticatorOutput(CredentialProtectionPolicy.USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST); assertThatThrownBy(()->target.getValue("invalid")).isInstanceOf(IllegalArgumentException.class); }