use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.
the class SessionServiceTest method sendErrorResponseFromHub_shouldErrorWhenSamlEngineProxyReturnsAnError.
@Test(expected = ApplicationException.class)
public void sendErrorResponseFromHub_shouldErrorWhenSamlEngineProxyReturnsAnError() throws Exception {
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
ResponseFromHub responseFromHub = aResponseFromHubDto().withRelayState("relayState").build();
when(authnRequestHandler.getErrorResponseFromHub(sessionId)).thenReturn(responseFromHub);
when(samlEngineProxy.generateErrorResponseFromHub(any())).thenThrow(ApplicationException.createAuditedException(ExceptionType.NETWORK_ERROR, UUID.randomUUID()));
service.getRpErrorResponse(sessionId);
}
use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.
the class SuccessfulMatchStateControllerTest method getPreparedResponse_shouldReturnResponse.
@Test
public void getPreparedResponse_shouldReturnResponse() {
List<String> enabledIdentityProviders = singletonList(state.getIdentityProviderEntityId());
ResponseFromHub expectedResponseFromHub = ResponseFromHubBuilder.aResponseFromHubDto().build();
when(identityProvidersConfigProxy.getEnabledIdentityProviders(eq(state.getRequestIssuerEntityId()), anyBoolean(), any(LevelOfAssurance.class))).thenReturn(enabledIdentityProviders);
when(responseFromHubFactory.createSuccessResponseFromHub(state.getRequestId(), state.getMatchingServiceAssertion(), state.getRelayState(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri())).thenReturn(expectedResponseFromHub);
ResponseFromHub result = controller.getPreparedResponse();
Assert.assertEquals(result, expectedResponseFromHub);
}
use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.
the class SessionServiceTest method shouldUpdateSessionStateAndCallSamlEngineWhenResponseFromHubIsRequested.
@Test
public void shouldUpdateSessionStateAndCallSamlEngineWhenResponseFromHubIsRequested() {
// Given
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
ResponseFromHub responseFromHub = aResponseFromHubDto().build();
when(authnRequestHandler.getResponseFromHub(sessionId)).thenReturn(responseFromHub);
AuthnResponseFromHubContainerDto expected = anAuthnResponseFromHubContainerDto().build();
when(samlEngineProxy.generateRpAuthnResponse(responseFromHub)).thenReturn(expected);
// When
AuthnResponseFromHubContainerDto actual = service.getRpAuthnResponse(sessionId);
// Then
assertThat(actual).isEqualTo(expected);
}
use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState.
@Test
public void shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, policyConfiguration, null, responseFromHubFactory, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
final ResponseFromHub responseFromHub = controller.getErrorResponse();
assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
use of uk.gov.ida.hub.policy.domain.ResponseFromHub in project verify-hub by alphagov.
the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInSessionStartedState.
@Test
public void shouldReturnErrorResponseWhenAskedAndInSessionStartedState() {
SessionStartedState state = SessionStartedStateBuilder.aSessionStartedState().build();
StateController stateController = new SessionStartedStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, identityProvidersConfigProxy);
when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Aggregations