### Question:
WebAuthnCredentialProvider implements CredentialProvider, CredentialInputValidator, CredentialInputUpdater { @Override public boolean updateCredential(RealmModel realm, UserModel user, CredentialInput input) { if (input == null) return false; CredentialModel model = createCredentialModel(input); if (model == null) return false; session.userCredentialManager().createCredential(realm, user, model); return true; } WebAuthnCredentialProvider(KeycloakSession session); @Override boolean updateCredential(RealmModel realm, UserModel user, CredentialInput input); @Override void disableCredentialType(RealmModel realm, UserModel user, String credentialType); @Override Set<String> getDisableableCredentialTypes(RealmModel realm, UserModel user); @Override boolean supportsCredentialType(String credentialType); @Override boolean isConfiguredFor(RealmModel realm, UserModel user, String credentialType); @Override boolean isValid(RealmModel realm, UserModel user, CredentialInput input);  }### Answer:
@Test public void test_updateCredential() throws Exception { CredentialModel credModel = mock(CredentialModel.class); WebAuthnCredentialModel model = getValidWebAuthnCredentialModel(); when(session.userCredentialManager() .createCredential(any(RealmModel.class), any(UserModel.class), any(CredentialModel.class))) .thenReturn(credModel); Assert.assertTrue(provider.updateCredential(mock(RealmModel.class), mock(UserModel.class), model)); }
@Test public void test_updateCredential_input_null() throws Exception { Assert.assertFalse(provider.updateCredential(mock(RealmModel.class), mock(UserModel.class), null)); }
@Test public void test_updateCredential_input_invalid_type() throws Exception { WebAuthnCredentialModel model = mock(WebAuthnCredentialModel.class); when(model.getType()).thenReturn("unknown"); Assert.assertFalse(provider.updateCredential(mock(RealmModel.class), mock(UserModel.class), model)); }