### Question:
WebAuthnCredentialProvider implements CredentialProvider, CredentialInputValidator, CredentialInputUpdater { @Override public void disableCredentialType(RealmModel realm, UserModel user, String credentialType) { if (!supportsCredentialType(credentialType)) return; for (CredentialModel credential : session.userCredentialManager().getStoredCredentialsByType(realm, user, credentialType)) { session.userCredentialManager().removeStoredCredential(realm, user, credential.getId()); } } 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_disableCredentialType() throws Exception { when(session.userCredentialManager() .getStoredCredentialsByType(any(RealmModel.class), any(UserModel.class), anyString())) .thenReturn(Arrays.asList(mock(CredentialModel.class))); when(session.userCredentialManager() .removeStoredCredential(any(RealmModel.class), any(UserModel.class), anyString())) .thenReturn(true); try { provider.disableCredentialType(mock(RealmModel.class), mock(UserModel.class), WebAuthnCredentialModel.WEBAUTHN_CREDENTIAL_TYPE); } catch (Exception e) { Assert.fail(e.getMessage()); } verify(session.userCredentialManager(), times(1)).removeStoredCredential(any(RealmModel.class), any(UserModel.class), anyString()); }
@Test public void test_disableCredentialType_unknown_type() throws Exception { try { provider.disableCredentialType(mock(RealmModel.class), mock(UserModel.class), "unknown"); } catch (Exception e) { Assert.fail(e.getMessage()); } verify(session.userCredentialManager(), never()).removeStoredCredential(any(RealmModel.class), any(UserModel.class), anyString()); }