use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class TotpMfaEndpointTest method setup.
@Before
public void setup() {
userId = new RandomValueStringGenerator(5).generate();
userGoogleMfaCredentialsProvisioning = mock(UserGoogleMfaCredentialsProvisioning.class);
mfaProviderProvisioning = mock(MfaProviderProvisioning.class);
uaaAuthentication = mock(UaaAuthentication.class);
mfaProvider = new MfaProvider();
mfaProvider.setName("provider-name");
mfaProvider.setId("provider_id1");
mfaProvider.setConfig(new GoogleMfaProviderConfig());
mfaProvider.setType(MfaProvider.MfaProviderType.GOOGLE_AUTHENTICATOR);
otherMfaProvider = new MfaProvider();
otherMfaProvider.setName("other-provider-name");
otherMfaProvider.setId("provider_id2");
otherMfaProvider.setConfig(new GoogleMfaProviderConfig());
otherMfaProvider.setType(MfaProvider.MfaProviderType.GOOGLE_AUTHENTICATOR);
mockSuccessHandler = mock(SavedRequestAwareAuthenticationSuccessHandler.class);
SecurityContextHolder.getContext().setAuthentication(uaaAuthentication);
publisher = mock(ApplicationEventPublisher.class);
eventCaptor = ArgumentCaptor.forClass(ApplicationEvent.class);
doNothing().when(publisher).publishEvent(eventCaptor.capture());
userDb = mock(UaaUserDatabase.class);
mockMfaPolicy = mock(CommonLoginPolicy.class);
when(mockMfaPolicy.isAllowed(anyString())).thenReturn(new LoginPolicy.Result(true, 0));
endpoint = new TotpMfaEndpoint(userGoogleMfaCredentialsProvisioning, mfaProviderProvisioning, "/login/mfa/completed", userDb, mockMfaPolicy);
endpoint.setApplicationEventPublisher(publisher);
}
use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testDeleteMfaUserCredentials.
@Test
void testDeleteMfaUserCredentials() throws Exception {
ScimUser user = createUser(uaaAdminToken);
MfaProvider provider = createMfaProvider(IdentityZoneHolder.get().getId());
IdentityZoneHolder.get().getConfig().setMfaConfig(new MfaConfig().setEnabled(true).setProviderName("mfaProvider"));
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 createMfaProvider.
private MfaProvider createMfaProvider(String identityZoneId) {
String index = generator.generate();
String mfaProviderId = "mfaProviderId" + index;
String mfaProviderName = "mfaProvider" + index;
MfaProvider provider = new MfaProvider().setName(mfaProviderName).setId(mfaProviderId).setType(MfaProvider.MfaProviderType.GOOGLE_AUTHENTICATOR).setConfig(new GoogleMfaProviderConfig()).setIdentityZoneId(identityZoneId);
mfaProviderProvisioning.create(provider, identityZoneId);
return provider;
}
use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class MfaProviderEndpointsIntegrationTests method createMfaProvider.
@Test
public void createMfaProvider() {
MfaProvider result = IntegrationTestUtils.createGoogleMfaProvider(baseUrl, adminToken, mfaProvider, "");
assertTrue("id is not empty", StringUtils.hasText(result.getId()));
}
use of org.cloudfoundry.identity.uaa.mfa.MfaProvider in project uaa by cloudfoundry.
the class MfaProviderEndpointsIntegrationTests method setup.
@Before
public void setup() throws Exception {
adminToken = IntegrationTestUtils.getZoneAdminToken(baseUrl, serverRunning);
mfaProvider = new MfaProvider();
mfaProvider.setConfig(new GoogleMfaProviderConfig());
mfaProvider.setType(MfaProvider.MfaProviderType.GOOGLE_AUTHENTICATOR);
mfaProvider.setName("testMfaProvider");
}
Aggregations