use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method cycle3SuccessfulMatchResponseFromMatchingService_shouldLogCycle3MatchEventToEventSink.
@Test
public void cycle3SuccessfulMatchResponseFromMatchingService_shouldLogCycle3MatchEventToEventSink() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, mock(StateTransitionAction.class), policyConfiguration, mock(LevelOfAssuranceValidator.class), null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(matchingServiceEntityId, requestId, "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_MATCH);
assertThat(argumentCaptor.getValue().getSessionId()).isEqualTo(sessionId.getSessionId());
assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.request_id)).isEqualTo(requestId);
assertThat(argumentCaptor.getValue().getOriginatingService()).isEqualTo(serviceInfo.getName());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method statusShouldSendNoMatchResponseToTransaction_whenNoMatchResponseSentFromMatchingServiceCycle3Match.
@Test
public void statusShouldSendNoMatchResponseToTransaction_whenNoMatchResponseSentFromMatchingServiceCycle3Match() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
ArgumentCaptor<NoMatchState> argumentCaptor = ArgumentCaptor.forClass(NoMatchState.class);
NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
NoMatchStateController noMatchStateController = new NoMatchStateController(argumentCaptor.getValue(), responseFromHubFactory);
ResponseProcessingDetails responseProcessingDetails = noMatchStateController.getResponseProcessingDetails();
assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_NO_MATCH_RESPONSE_TO_TRANSACTION);
assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent.
private void anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(SessionId sessionId) throws JsonProcessingException {
final URI policyUri = policy.uri(UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_RESPONSE_RESOURCE).build(sessionId).getPath());
SamlAuthnResponseContainerDto samlAuthnResponseContainerDto = new SamlAuthnResponseContainerDto("saml-response", new SessionId(sessionId.getSessionId()), "principal-ip-address");
InboundResponseFromIdpDto inboundResponseFromIdpDto = InboundResponseFromIdpDtoBuilder.successResponse(idpEntityId, LEVEL_2);
configStub.setUpStubForMatchingServiceRequest(rpEntityId, msaEntityId);
samlEngineStub.setupStubForAttributeQueryRequest(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
samlEngineStub.setupStubForIdpAuthnResponseTranslate(inboundResponseFromIdpDto);
samlSoapProxyProxyStubRule.setUpStubForSendHubMatchingServiceRequest(sessionId);
postResponse(policyUri, samlAuthnResponseContainerDto);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method fullSuccessfulJourneyThroughAllStates.
@Test
public void fullSuccessfulJourneyThroughAllStates() throws Exception {
final SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForRegistration(sessionId, idpEntityId);
anIdpAuthnRequestWasGenerated(sessionId);
anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
aCycle3AttributeHasBeenSentToPolicyFromTheUser(sessionId, "#1");
aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled(sessionId);
aUserAccountCreationResponseIsReceived(sessionId, MatchingServiceIdaStatus.UserAccountCreated);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RESPONSE_PROCESSING_DETAILS_RESOURCE).build(sessionId);
Response response = getResponse(policy.uri(uri.toASCIIString()));
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
ResponseProcessingDetails responseProcessingDetails = response.readEntity(ResponseProcessingDetails.class);
assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_USER_ACCOUNT_CREATED_RESPONSE_TO_TRANSACTION);
assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
assertThat(getSessionStateName(sessionId)).isEqualTo(UserAccountCreatedState.class.getName());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest.
@Test
public void responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest() throws Exception {
SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForRegistration(sessionId, idpEntityId);
anIdpAuthnRequestWasGenerated(sessionId);
anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
aCycle3AttributeHasBeenSentToPolicyFromTheUser(sessionId, "#1");
SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.MatchingServiceMatch, "a-thoroughly-different-request-id", msaEntityId, Optional.of("assertionBlob"), Optional.of(LEVEL_2));
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
Response response = postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
// Note that the state does not get updated if there is a StateProcessingValidationException
assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle3MatchRequestSentState.class.getName());
}
Aggregations