use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorResourceTest method shouldReturnADtoWhenResponseIs_TooOld.
@Test
public void shouldReturnADtoWhenResponseIs_TooOld() throws Exception {
final String requestId = "requestId";
final String msaStatusCode = SamlStatusCode.MATCH;
final Status status = aStatus().withStatusCode(aStatusCode().withSubStatusCode(aStatusCode().withValue(msaStatusCode).build()).withValue(SUCCESS).build()).build();
final SamlResponseContainerDto samlResponseContainerDto = new SamlResponseContainerDto(Base64.getEncoder().encodeToString(aValidMatchResponseFromMatchingService(requestId, status, DateTime.now().minusDays(1)).getBytes()), TEST_RP);
Response clientResponse = postToSamlEngine(samlResponseContainerDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = clientResponse.readEntity(ErrorStatusDto.class);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorResourceTest method shouldReturnADtoWhenResponseIs_NoMatch.
@Test
public void shouldReturnADtoWhenResponseIs_NoMatch() throws Exception {
final String requestId = "requestId";
final String msaStatusCode = SamlStatusCode.NO_MATCH;
final Status status = aStatus().withStatusCode(aStatusCode().withSubStatusCode(aStatusCode().withValue(msaStatusCode).build()).withValue(RESPONDER).build()).build();
final SamlResponseContainerDto samlResponseContainerDto = new SamlResponseContainerDto(Base64.getEncoder().encodeToString(aValidNoMatchResponseFromMatchingService(requestId, status, TEST_RP_MS).getBytes()), TEST_RP);
Response clientResponse = postToSamlEngine(samlResponseContainerDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = clientResponse.readEntity(InboundResponseFromMatchingServiceDto.class);
assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(TEST_RP_MS);
assertThat(inboundResponseFromMatchingServiceDto.getInResponseTo()).isEqualTo(requestId);
assertThat(inboundResponseFromMatchingServiceDto.getStatus().name()).isEqualTo(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService.name());
assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance()).isNotPresent();
assertThat(inboundResponseFromMatchingServiceDto.getEncryptedMatchingServiceAssertion()).isNotPresent();
}
use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorResourceTest method shouldNotReturnADtoResponse_WhenBadlySigned_NoMatch.
@Test
public void shouldNotReturnADtoResponse_WhenBadlySigned_NoMatch() throws Exception {
final String requestId = "requestId";
final String msaStatusCode = SamlStatusCode.NO_MATCH;
final Status status = aStatus().withStatusCode(aStatusCode().withSubStatusCode(aStatusCode().withValue(msaStatusCode).build()).withValue(RESPONDER).build()).build();
final SamlResponseContainerDto samlResponseContainerDto = new SamlResponseContainerDto(Base64.getEncoder().encodeToString(aValidNoMatchResponseFromMatchingServiceisBadlySigned(requestId, status, TEST_RP_MS).getBytes()), TEST_RP);
Response clientResponse = postToSamlEngine(samlResponseContainerDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = clientResponse.readEntity(ErrorStatusDto.class);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformNoAuthenticationContext.
@Test
public void transform_shouldTransformNoAuthenticationContext() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status originalStatus = samlObjectFactory.createStatus();
StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
topLevelStatusCode.setValue(StatusCode.RESPONDER);
StatusCode subStatusCode = samlObjectFactory.createStatusCode();
subStatusCode.setValue(StatusCode.NO_AUTHN_CONTEXT);
topLevelStatusCode.setStatusCode(subStatusCode);
originalStatus.setStatusCode(topLevelStatusCode);
IdpIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
assertThat(transformedStatus).isEqualTo(IdpIdaStatus.noAuthenticationContext());
}
use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method shouldRemainNoAuthnContextIfStatusDetailPresentButUnknown.
@Test
public void shouldRemainNoAuthnContextIfStatusDetailPresentButUnknown() throws Exception {
String xml = readXmlFile("status-noauthncontext-withotherdetail.xml");
Response response = stringToOpenSamlObjectTransformer.apply(xml);
IdpIdaStatus idpIdaStatus = getStatusFrom(response);
assertThat(idpIdaStatus.getStatusCode()).isEqualTo(IdpIdaStatus.Status.NoAuthenticationContext);
}
Aggregations