Search in sources :

Example 16 with MfaProvider

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");
}
Also used : MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider) Test(org.junit.jupiter.api.Test)

Example 17 with MfaProvider

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;
}
Also used : MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider)

Example 18 with MfaProvider

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
    }
}
Also used : MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider) MfaConfig(org.cloudfoundry.identity.uaa.zone.MfaConfig) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) UserMfaConfigDoesNotExistException(org.cloudfoundry.identity.uaa.mfa.exception.UserMfaConfigDoesNotExistException) Test(org.junit.jupiter.api.Test)

Example 19 with MfaProvider

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);
}
Also used : ScimUser(org.cloudfoundry.identity.uaa.scim.ScimUser) MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider) MfaConfig(org.cloudfoundry.identity.uaa.zone.MfaConfig) UserGoogleMfaCredentials(org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentials) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 20 with MfaProvider

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);
}
Also used : ScimUser(org.cloudfoundry.identity.uaa.scim.ScimUser) MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider) MfaConfig(org.cloudfoundry.identity.uaa.zone.MfaConfig) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

MfaProvider (org.cloudfoundry.identity.uaa.mfa.MfaProvider)29 Test (org.junit.jupiter.api.Test)16 GoogleMfaProviderConfig (org.cloudfoundry.identity.uaa.mfa.GoogleMfaProviderConfig)12 MockMvcUtils.constructGoogleMfaProvider (org.cloudfoundry.identity.uaa.mock.util.MockMvcUtils.constructGoogleMfaProvider)10 RandomValueStringGenerator (org.springframework.security.oauth2.common.util.RandomValueStringGenerator)7 IdentityZone (org.cloudfoundry.identity.uaa.zone.IdentityZone)6 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)6 MfaProviderProvisioning (org.cloudfoundry.identity.uaa.mfa.MfaProviderProvisioning)5 MfaConfig (org.cloudfoundry.identity.uaa.zone.MfaConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 MvcResult (org.springframework.test.web.servlet.MvcResult)5 ScimUser (org.cloudfoundry.identity.uaa.scim.ScimUser)4 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)4 JdbcMfaProviderProvisioning (org.cloudfoundry.identity.uaa.mfa.JdbcMfaProviderProvisioning)3 UserGoogleMfaCredentials (org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentials)3 ResultActions (org.springframework.test.web.servlet.ResultActions)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 UaaPrincipal (org.cloudfoundry.identity.uaa.authentication.UaaPrincipal)2 Before (org.junit.Before)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2