use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class EncryptedResponseFromIdpValidatorTest method validateStatus_shouldThrowExceptionIfAuthnFailedHasASubSubStatus.
@Test
public void validateStatus_shouldThrowExceptionIfAuthnFailedHasASubSubStatus() throws Exception {
StatusCode subStatusCode = aStatusCode().withValue(StatusCode.AUTHN_FAILED).withSubStatusCode(createSubStatusCode()).build();
Status status = createStatus(StatusCode.RESPONDER, subStatusCode);
Response response = aResponse().withStatus(status).build();
assertValidationFailure(response, nestedSubStatusCodesBreached(1));
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformAuthnFailed.
@Test
public void transform_shouldTransformAuthnFailed() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status status = samlObjectFactory.createStatus();
StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
topLevelStatusCode.setValue(StatusCode.RESPONDER);
status.setStatusCode(topLevelStatusCode);
StatusCode subStatusCode = samlObjectFactory.createStatusCode();
subStatusCode.setValue(StatusCode.AUTHN_FAILED);
topLevelStatusCode.setStatusCode(subStatusCode);
IdpIdaStatus transformedStatus = unmarshaller.fromSaml(status);
assertThat(transformedStatus).isEqualTo(IdpIdaStatus.authenticationFailed());
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformRequesterErrorWithMessage.
@Test
public void transform_shouldTransformRequesterErrorWithMessage() {
String message = "some message";
StatusCode topLevelStatusCode = aStatusCode().withValue(StatusCode.REQUESTER).build();
Status status = aStatus().withStatusCode(topLevelStatusCode).withMessage(aStatusMessage().withMessage(message).build()).build();
IdpIdaStatus transformedStatus = unmarshaller.fromSaml(status);
assertThat(transformedStatus).isEqualTo(IdpIdaStatus.requesterError());
assertThat(transformedStatus.getMessage().isPresent()).isEqualTo(true);
assertThat(transformedStatus.getMessage().get()).isEqualTo(message);
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformRequesterErrorWithoutMessage.
@Test
public void transform_shouldTransformRequesterErrorWithoutMessage() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status status = samlObjectFactory.createStatus();
StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
topLevelStatusCode.setValue(StatusCode.REQUESTER);
status.setStatusCode(topLevelStatusCode);
IdpIdaStatus transformedStatus = unmarshaller.fromSaml(status);
assertThat(transformedStatus).isEqualTo(IdpIdaStatus.requesterError());
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformSuccessWithNoSubCode.
@Test
public void transform_shouldTransformSuccessWithNoSubCode() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status originalStatus = samlObjectFactory.createStatus();
StatusCode successStatusCode = samlObjectFactory.createStatusCode();
successStatusCode.setValue(StatusCode.SUCCESS);
originalStatus.setStatusCode(successStatusCode);
IdpIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
assertThat(transformedStatus).isEqualTo(IdpIdaStatus.success());
}
Aggregations