use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto in project verify-hub by alphagov.
the class EidasMatchingServiceResourceIntegrationTest method shouldTransitionToNoMatchStateWhenNoMatchIsReceivedForEidasCycle0And1WithCycle3Disabled.
@Test
public void shouldTransitionToNoMatchStateWhenNoMatchIsReceivedForEidasCycle0And1WithCycle3Disabled() throws Exception {
final SessionId sessionId = aSessionIsCreated();
selectACountry(sessionId, NETHERLANDS);
samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
postAuthnResponseToPolicy(sessionId);
final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService, translatedAuthnRequest.getId(), MSA_ENTITY_ID, Optional.absent(), Optional.absent());
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
configStub.setUpStubForCycle01NoMatchCycle3Disabled(RP_ENTITY_ID);
final Response response = postAttributeQueryResponseToPolicy(sessionId);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(getSessionStateName(sessionId)).isEqualTo(NoMatchState.class.getName());
}
use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto in project verify-hub by alphagov.
the class EidasMatchingServiceResourceIntegrationTest method shouldTransitionToEidasSuccessfulMatchStateWhenMatchIsReceivedForEidasCycle0And1.
@Test
public void shouldTransitionToEidasSuccessfulMatchStateWhenMatchIsReceivedForEidasCycle0And1() throws Exception {
final SessionId sessionId = aSessionIsCreated();
selectACountry(sessionId, NETHERLANDS);
samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
postAuthnResponseToPolicy(sessionId);
final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.MatchingServiceMatch, translatedAuthnRequest.getId(), MSA_ENTITY_ID, Optional.of("assertionBlob"), Optional.of(LevelOfAssurance.LEVEL_2));
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
final Response response = postAttributeQueryResponseToPolicy(sessionId);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(getSessionStateName(sessionId)).isEqualTo(EidasSuccessfulMatchState.class.getName());
}
use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto in project verify-hub by alphagov.
the class MatchingServiceResponseService method handleSuccessResponse.
public void handleSuccessResponse(SessionId sessionId, SamlResponseDto samlResponse) {
getSessionIfItExists(sessionId);
SamlResponseContainerDto samlResponseContainer = new SamlResponseContainerDto(samlResponse.getSamlResponse(), sessionRepository.getRequestIssuerEntityId(sessionId));
try {
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = samlEngineProxy.translateMatchingServiceResponse(samlResponseContainer);
updateSessionState(sessionId, inboundResponseFromMatchingServiceDto);
} catch (ApplicationException e) {
// this is not ideal but if the call to saml-proxy fails we want to log the failure
// in the state and then process the exception
logExceptionAndUpdateState("Error translating matching service response", sessionId, e);
}
}
use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto in project verify-hub by alphagov.
the class MatchingServiceResponseServiceTest method handle_shouldLogToEventSinkAndNotifyPolicyOnRequesterError.
@Test
public void handle_shouldLogToEventSinkAndNotifyPolicyOnRequesterError() {
final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.RequesterError, inResponseTo, "issuer", Optional.empty(), Optional.empty());
when(samlEngineProxy.translateMatchingServiceResponse(any())).thenReturn(inboundResponseFromMatchingServiceDto);
matchingServiceResponseService.handleSuccessResponse(sessionId, samlResponseDto);
verify(waitingForMatchingServiceResponseStateController, times(1)).handleRequestFailure();
verify(eventLogger).logErrorEvent(format("Requester error in response from matching service for session {0}", sessionId), sessionId);
}
use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Disabled.
private void aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Disabled(SessionId sessionId) throws JsonProcessingException {
SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService, translatedAuthnRequest.getId(), msaEntityId, Optional.empty(), Optional.empty());
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
configStub.setUpStubForCycle01NoMatchCycle3Disabled(rpEntityId);
List<UserAccountCreationAttribute> userAccountCreationAttributes = List.of(UserAccountCreationAttribute.CURRENT_ADDRESS);
configStub.setUpStubForUserAccountCreation(rpEntityId, userAccountCreationAttributes);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
postResponse(uri, msaSamlResponseDto);
}
Aggregations