Search in sources :

Example 6 with AuthenticationErrorResponse

use of uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleNoAuthnContextResponseFromIdp_shouldLogEvent.

@Test
public void handleNoAuthnContextResponseFromIdp_shouldLogEvent() {
    AuthenticationErrorResponse authenticationErrorResponse = anAuthenticationErrorResponse().withIssuerId(IDP_ENTITY_ID).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    controller.handleNoAuthenticationContextResponseFromIdp(authenticationErrorResponse);
    verify(hubEventLogger).logNoAuthnContextEvent(NEW_SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) Test(org.junit.Test)

Example 7 with AuthenticationErrorResponse

use of uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleNoAuthenticationContextResponseFromIdp_shouldTransitionToAuthnFailedErrorStateWhenRegistrationCancelled.

@Test
public void handleNoAuthenticationContextResponseFromIdp_shouldTransitionToAuthnFailedErrorStateWhenRegistrationCancelled() {
    controller = idpSelectedStateBuilder(true);
    AuthenticationErrorResponse authenticationErrorResponse = anAuthenticationErrorResponse().withIssuerId(IDP_ENTITY_ID).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(any(String.class), eq(controller.isRegistrationContext()), eq(PROVIDED_LOA))).thenReturn(singletonList(authenticationErrorResponse.getIssuer()));
    controller.handleNoAuthenticationContextResponseFromIdp(authenticationErrorResponse);
    verify(stateTransitionAction).transitionTo(isA(AuthnFailedErrorState.class));
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) AuthnFailedErrorState(uk.gov.ida.hub.policy.domain.state.AuthnFailedErrorState) Test(org.junit.Test)

Example 8 with AuthenticationErrorResponse

use of uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleNoAuthenticationContextResponseFromIdp_shouldThrowExceptionWhenIdpIsDisabled.

@Test(expected = IdpDisabledException.class)
public void handleNoAuthenticationContextResponseFromIdp_shouldThrowExceptionWhenIdpIsDisabled() {
    AuthenticationErrorResponse authenticationErrorResponse = anAuthenticationErrorResponse().build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(emptyList());
    controller.handleNoAuthenticationContextResponseFromIdp(authenticationErrorResponse);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) Test(org.junit.Test)

Example 9 with AuthenticationErrorResponse

use of uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleAuthenticationFailedResponseFromIdp_shouldThrowExceptionWhenIdpIsDisabled.

@Test(expected = IdpDisabledException.class)
public void handleAuthenticationFailedResponseFromIdp_shouldThrowExceptionWhenIdpIsDisabled() {
    AuthenticationErrorResponse authenticationErrorResponse = anAuthenticationErrorResponse().build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(emptyList());
    controller.handleAuthenticationFailedResponseFromIdp(authenticationErrorResponse);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) Test(org.junit.Test)

Example 10 with AuthenticationErrorResponse

use of uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleResponseFromIdp_shouldTransitionToAuthnFailedStateWhenAGenericAuthenticationFailureHasOccurred.

@Test
public void handleResponseFromIdp_shouldTransitionToAuthnFailedStateWhenAGenericAuthenticationFailureHasOccurred() {
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    AuthenticationErrorResponse authenticationErrorResponse = anAuthenticationErrorResponse().withIssuerId(IDP_ENTITY_ID).build();
    controller.handleAuthenticationFailedResponseFromIdp(authenticationErrorResponse);
    ArgumentCaptor<State> stateArgumentCaptor = ArgumentCaptor.forClass(State.class);
    verify(stateTransitionAction).transitionTo(stateArgumentCaptor.capture());
    assertThat(stateArgumentCaptor.getValue()).isInstanceOf(AuthnFailedErrorState.class);
}
Also used : AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) State(uk.gov.ida.hub.policy.domain.State) AuthnFailedErrorState(uk.gov.ida.hub.policy.domain.state.AuthnFailedErrorState) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) FraudEventDetectedState(uk.gov.ida.hub.policy.domain.state.FraudEventDetectedState) IdpSelectedStateBuilder.anIdpSelectedState(uk.gov.ida.hub.policy.builder.state.IdpSelectedStateBuilder.anIdpSelectedState) PausedRegistrationState(uk.gov.ida.hub.policy.domain.state.PausedRegistrationState) SessionStartedState(uk.gov.ida.hub.policy.domain.state.SessionStartedState) Test(org.junit.Test)

Aggregations

AuthenticationErrorResponse (uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse)13 AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse (uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse)9 Test (org.junit.Test)7 AuthnFailedErrorState (uk.gov.ida.hub.policy.domain.state.AuthnFailedErrorState)2 SessionStartedState (uk.gov.ida.hub.policy.domain.state.SessionStartedState)2 IdpSelectedStateBuilder.anIdpSelectedState (uk.gov.ida.hub.policy.builder.state.IdpSelectedStateBuilder.anIdpSelectedState)1 State (uk.gov.ida.hub.policy.domain.State)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 FraudEventDetectedState (uk.gov.ida.hub.policy.domain.state.FraudEventDetectedState)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1 PausedRegistrationState (uk.gov.ida.hub.policy.domain.state.PausedRegistrationState)1