use of org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentials in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testDeleteMfaUserCredentialsMfaNotEnabled.
@Test
void testDeleteMfaUserCredentialsMfaNotEnabled() throws Exception {
ScimUser user = createUser(uaaAdminToken);
MfaProvider provider = createMfaProvider(IdentityZoneHolder.get().getId());
IdentityZoneHolder.get().getConfig().setMfaConfig(new MfaConfig().setEnabled(false));
UserGoogleMfaCredentials creds = new UserGoogleMfaCredentials(user.getId(), "ABCDEFGHIJKLMNOP", 1234, Collections.singletonList(123456)).setMfaProviderId(provider.getId());
mfaCredentialsProvisioning.save(creds, IdentityZoneHolder.get().getId());
assertNotNull(mfaCredentialsProvisioning.retrieve(user.getId(), provider.getId()));
MockHttpServletRequestBuilder delete = delete("/Users/" + user.getId() + "/mfa").header("Authorization", "Bearer " + uaaAdminToken).contentType(APPLICATION_JSON);
mockMvc.perform(delete).andExpect(status().isOk());
assertMfaCredentialsNotExisting(user, provider);
}
use of org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentials in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testDeleteMfaUserCredentialsWithZoneSwitching.
@Test
void testDeleteMfaUserCredentialsWithZoneSwitching() throws Exception {
IdentityZone identityZone = getIdentityZone();
String authorities = "zones." + identityZone.getId() + ".admin";
clientDetails = MockMvcUtils.createClient(mockMvc, uaaAdminToken, "switchClientId", "switchClientSecret", null, null, Collections.singletonList("client_credentials"), authorities, null, IdentityZone.getUaa());
String uaaAdminTokenFromOtherZone = testClient.getClientCredentialsOAuthAccessToken("switchClientId", "switchClientSecret", authorities);
ScimUser user = setUpScimUser(identityZone);
MfaProvider provider = createMfaProvider(identityZone.getId());
identityZone.getConfig().setMfaConfig(new MfaConfig().setEnabled(true).setProviderName("mfaProvider"));
MockMvcUtils.updateIdentityZone(identityZone, webApplicationContext);
UserGoogleMfaCredentials creds = new UserGoogleMfaCredentials(user.getId(), "ABCDEFGHIJKLMNOP", 1234, Collections.singletonList(123456)).setMfaProviderId(provider.getId());
mfaCredentialsProvisioning.save(creds, identityZone.getId());
assertNotNull(mfaCredentialsProvisioning.retrieve(user.getId(), provider.getId()));
MockHttpServletRequestBuilder delete = delete("/Users/" + user.getId() + "/mfa").header("Authorization", "Bearer " + uaaAdminTokenFromOtherZone).header(HEADER, identityZone.getId()).contentType(APPLICATION_JSON);
mockMvc.perform(delete).andExpect(status().isOk());
assertMfaCredentialsNotExisting(user, provider);
}
Aggregations