Search in sources :

Example 1 with UserGoogleMfaCredentialsProvisioning

use of org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentialsProvisioning 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);
}
Also used : MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider) CommonLoginPolicy(org.cloudfoundry.identity.uaa.authentication.manager.CommonLoginPolicy) MfaProviderProvisioning(org.cloudfoundry.identity.uaa.mfa.MfaProviderProvisioning) ApplicationEvent(org.springframework.context.ApplicationEvent) GoogleMfaProviderConfig(org.cloudfoundry.identity.uaa.mfa.GoogleMfaProviderConfig) UaaUserDatabase(org.cloudfoundry.identity.uaa.user.UaaUserDatabase) UserGoogleMfaCredentialsProvisioning(org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentialsProvisioning) UaaAuthentication(org.cloudfoundry.identity.uaa.authentication.UaaAuthentication) SavedRequestAwareAuthenticationSuccessHandler(org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) CommonLoginPolicy(org.cloudfoundry.identity.uaa.authentication.manager.CommonLoginPolicy) LoginPolicy(org.cloudfoundry.identity.uaa.authentication.manager.LoginPolicy) RandomValueStringGenerator(org.springframework.security.oauth2.common.util.RandomValueStringGenerator) Before(org.junit.Before)

Aggregations

UaaAuthentication (org.cloudfoundry.identity.uaa.authentication.UaaAuthentication)1 CommonLoginPolicy (org.cloudfoundry.identity.uaa.authentication.manager.CommonLoginPolicy)1 LoginPolicy (org.cloudfoundry.identity.uaa.authentication.manager.LoginPolicy)1 GoogleMfaProviderConfig (org.cloudfoundry.identity.uaa.mfa.GoogleMfaProviderConfig)1 MfaProvider (org.cloudfoundry.identity.uaa.mfa.MfaProvider)1 MfaProviderProvisioning (org.cloudfoundry.identity.uaa.mfa.MfaProviderProvisioning)1 UserGoogleMfaCredentialsProvisioning (org.cloudfoundry.identity.uaa.mfa.UserGoogleMfaCredentialsProvisioning)1 UaaUserDatabase (org.cloudfoundry.identity.uaa.user.UaaUserDatabase)1 Before (org.junit.Before)1 ApplicationEvent (org.springframework.context.ApplicationEvent)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1 RandomValueStringGenerator (org.springframework.security.oauth2.common.util.RandomValueStringGenerator)1 SavedRequestAwareAuthenticationSuccessHandler (org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler)1