use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionServiceTest method shouldCreateASessionFromInputs.
@Test
public void shouldCreateASessionFromInputs() {
// Given
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
givenSamlEngineTranslatesRequest(samlResponse);
givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, false);
// When
SessionId result = service.create(requestDto);
// Then
assertThat(result, is(sessionId));
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class EidasSessionResourceContractTest method shouldGetValidatedEidasAuthnResponseFromSamlEngineVerification.
@PactVerification(value = SAML_ENGINE_SERVICE, fragment = "shouldGetValidatedEidasAuthnResponseFromSamlEngine")
@Test
public void shouldGetValidatedEidasAuthnResponseFromSamlEngineVerification() throws Exception {
configStub.setupStubForEidasRPCountries(TEST_RP, EIDAS_COUNTRIES.stream().map(EidasCountryDto::getEntityId).collect(Collectors.toList()));
SessionId sessionId = createSessionInCountrySelectingState();
selectACountry(sessionId);
Response response = postAuthnResponseToPolicy(sessionId);
assertThatResponseIsSuccess(response);
assertThatAQRReceivedBySamlSoapProxyHasSameDataAsSamlEngineSent();
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class AuthnRequestFromTransactionResourceIntegrationTest method getRequestIssuerId_shouldReturnRequestIssuerId.
@Test
public void getRequestIssuerId_shouldReturnRequestIssuerId() {
SessionId session = SessionId.createNewSessionId();
TestSessionResourceHelper.createSessionInIdpSelectedState(session, samlResponse.getIssuer(), idpEntityId, client, buildUriForTestSession(IDP_SELECTED_STATE, session));
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_FROM_TRANSACTION_ROOT + Urls.PolicyUrls.AUTHN_REQUEST_ISSUER_ID_PATH).build(session);
Response response = client.target(policy.uri(uri.toASCIIString())).request().get();
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(response.readEntity(String.class)).isEqualTo(samlResponse.getIssuer());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3DataResourceTest method shouldGetCycle3AttributeRequestDataFromConfiguration.
@Test
public void shouldGetCycle3AttributeRequestDataFromConfiguration() throws JsonProcessingException {
// Given
SessionId sessionId = SessionIdBuilder.aSessionId().build();
String rpEntityId = new Cycle3DTO(sessionId).getRequestIssuerId();
Response sessionCreatedResponse = createSessionInAwaitingCycle3DataState(sessionId);
assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
// When
Cycle3AttributeRequestData actualResponse = getCycle3Data(sessionId);
// Then
Cycle3AttributeRequestData expectedResponse = aCycle3AttributeRequestData().withAttributeName(cycle3Attribute.getAttributeName().get()).withRequestIssuerId(rpEntityId).build();
assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class EidasCycle3DataResourceTest method shouldReturnSuccessWhenDataSubmitted.
@Test
public void shouldReturnSuccessWhenDataSubmitted() throws JsonProcessingException {
final SessionId sessionId = SessionIdBuilder.aSessionId().build();
final String rpEntityId = new EidasCycle3DTO(sessionId).getRequestIssuerEntityId();
final String msaEntityId = new EidasCycle3DTO(sessionId).getMatchingServiceAdapterEntityId();
final Response sessionCreatedResponse = createSessionInEidasAwaitingCycle3DataState(sessionId);
assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
final Cycle3UserInput cycle3UserInput = new Cycle3UserInput("test-value", "principal-ip-address-seen-by-hub");
samlEngineStub.setupStubForEidasAttributeQueryRequestGeneration(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
configStub.setUpStubForMatchingServiceRequest(rpEntityId, msaEntityId);
final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
postCycle3Data(sessionId, cycle3UserInput);
assertThat(getSessionStateName(sessionId)).isEqualTo(EidasCycle3MatchRequestSentState.class.getName());
}
Aggregations