use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.
the class PolicyStubRule method receiveAuthnResponseFromCountry.
public void receiveAuthnResponseFromCountry(String sessionId, LevelOfAssurance loaAchieved) throws JsonProcessingException {
String locationUri = getAuthnResponseFromCountryLocation(sessionId);
ResponseActionDto responseActionDto = ResponseActionDto.success(new SessionId(sessionId), false, loaAchieved);
register(locationUri, Status.OK.getStatusCode(), responseActionDto);
}
use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.
the class PolicyStubRule method receiveAuthnResponseFromIdp.
public void receiveAuthnResponseFromIdp(String sessionId, LevelOfAssurance loaAchieved) throws JsonProcessingException {
String locationUri = getAuthnResponseFromIdpLocation(sessionId);
ResponseActionDto responseActionDto = ResponseActionDto.success(new SessionId(sessionId), false, loaAchieved);
register(locationUri, Status.OK.getStatusCode(), responseActionDto);
}
use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.
the class CountryMetadataConsumerTest method shouldServeCountryMetadata.
@Test
public void shouldServeCountryMetadata() throws Exception {
// Given
SessionId sessionId = SessionId.createNewSessionId();
policyStubRule.receiveAuthnResponseFromCountry(sessionId.toString(), LEVEL_2);
String response = authnResponseFactory.aSamlResponseFromIdp("a-request", countryMetadata.getCountryMetadataUri(), idpSigningCert, idpSigningKey, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
// When
ResponseActionDto post = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1")).readEntity(ResponseActionDto.class);
// Then
assertThat(post.getSessionId()).isEqualTo(sessionId);
assertThat(post.getLoaAchieved()).isEqualTo(LEVEL_2);
}
use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.
the class MetadataConsumerTests method shouldAllowRequestsWhenMetadataIsAvailableAndValid.
@Test
public void shouldAllowRequestsWhenMetadataIsAvailableAndValid() throws Exception {
SessionId sessionId = SessionId.createNewSessionId();
policyStubRule.register(UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_RESPONSE_RESOURCE).build(sessionId).getPath(), 200, ResponseActionDto.success(sessionId, true, LEVEL_2));
String response = authnResponseFactory.aSamlResponseFromIdp(TestEntityIds.STUB_IDP_ONE, STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
ResponseActionDto post = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1")).readEntity(ResponseActionDto.class);
assertThat(post.getSessionId()).isEqualTo(sessionId);
assertThat(post.getLoaAchieved()).isEqualTo(LEVEL_2);
}
use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiTest method handleResponsePost_shouldReturnActionDtoOnSuccessfulRegistration.
@Test
public void handleResponsePost_shouldReturnActionDtoOnSuccessfulRegistration() throws MarshallingException, SignatureException {
ResponseActionDto responseActionDto = ResponseActionDto.success(SESSION_ID, true, LevelOfAssurance.LEVEL_2);
when(stringSamlResponseTransformer.apply(SAML_REQUEST)).thenReturn(validSamlResponse);
when(samlMessageSignatureValidator.validate(any(org.opensaml.saml.saml2.core.Response.class), any(QName.class))).thenReturn(SamlValidationResponse.aValidResponse());
when(sessionProxy.receiveAuthnResponseFromIdp(any(SamlAuthnResponseContainerDto.class), eq(SESSION_ID))).thenReturn(responseActionDto);
Response response = samlMessageReceiverApi.handleResponsePost(SAML_REQUEST_DTO);
assertThat(response.getStatus()).isEqualTo(Status.OK.getStatusCode());
assertThat(response.getEntity()).isEqualTo(responseActionDto);
}
Aggregations