use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class MfaConfigValidatorTests method validateSuccessful.
@Test
void validateSuccessful() throws InvalidIdentityZoneConfigurationException {
when(mockJdbcMfaProviderProvisioning.retrieveByName(matches("some-provider"), anyString())).thenReturn(new MfaProvider());
MfaConfig configuration = new MfaConfig().setEnabled(true).setProviderName("some-provider");
mfaConfigValidator.validate(configuration, "some-zone");
}
use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class TotpMfaEndpointIntegrationTests method enableMfaInZone.
private MfaProvider enableMfaInZone(String zoneAdminToken) {
MfaProvider provider = IntegrationTestUtils.createGoogleMfaProvider(baseUrl, zoneAdminToken, MockMvcUtils.constructGoogleMfaProvider(), mfaZone.getId());
mfaZone.getConfig().getMfaConfig().setEnabled(true).setProviderName(provider.getName());
mfaZone = IntegrationTestUtils.createZoneOrUpdateSubdomain(adminClient, baseUrl, "testzone1", mfaZone.getSubdomain(), mfaZone.getConfig());
return provider;
}
use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testDeleteMfaUserCredentialsUserDoesNotExist.
@Test
void testDeleteMfaUserCredentialsUserDoesNotExist() throws Exception {
MfaProvider provider = createMfaProvider(IdentityZoneHolder.get().getId());
IdentityZoneHolder.get().getConfig().setMfaConfig(new MfaConfig().setEnabled(true).setProviderName("mfaProvider"));
String userId = "invalidUserId";
MockHttpServletRequestBuilder delete = delete("/Users/" + userId + "/mfa").header("Authorization", "Bearer " + uaaAdminToken).contentType(APPLICATION_JSON);
mockMvc.perform(delete).andExpect(status().isNotFound());
try {
mfaCredentialsProvisioning.retrieve(userId, provider.getId());
fail();
} catch (UserMfaConfigDoesNotExistException e) {
// no op
}
}
use of org.cloudfoundry.identity.uaa.mfa.MfaProvider 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.MfaProvider in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testDeleteMfaUserCredentialsUserNotRegistered.
@Test
void testDeleteMfaUserCredentialsUserNotRegistered() throws Exception {
ScimUser user = createUser(uaaAdminToken);
MfaProvider provider = createMfaProvider(IdentityZoneHolder.get().getId());
IdentityZoneHolder.get().getConfig().setMfaConfig(new MfaConfig().setEnabled(true).setProviderName("mfaProvider"));
assertMfaCredentialsNotExisting(user, provider);
MockHttpServletRequestBuilder delete = delete("/Users/" + user.getId() + "/mfa").header("Authorization", "Bearer " + uaaAdminToken).contentType(APPLICATION_JSON);
mockMvc.perform(delete).andExpect(status().isOk());
assertMfaCredentialsNotExisting(user, provider);
}
Aggregations