Search in sources :

Example 31 with StatusCode

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));
}
Also used : ResponseValidatorTestHelper.createStatus(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlTransformationErrorFactory.invalidSubStatusCode(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.invalidSubStatusCode) ResponseValidatorTestHelper.createSubStatusCode(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createSubStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) SamlTransformationErrorFactory.invalidStatusCode(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.invalidStatusCode) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) Test(org.junit.jupiter.api.Test)

Example 32 with StatusCode

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());
}
Also used : StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 33 with StatusCode

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);
}
Also used : StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 34 with StatusCode

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());
}
Also used : StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 35 with StatusCode

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());
}
Also used : StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Aggregations

StatusCode (org.opensaml.saml.saml2.core.StatusCode)36 Status (org.opensaml.saml.saml2.core.Status)30 Test (org.junit.jupiter.api.Test)18 OpenSamlXmlObjectFactory (uk.gov.ida.saml.core.OpenSamlXmlObjectFactory)14 StatusCodeBuilder.aStatusCode (uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode)14 SamlStatusCode (uk.gov.ida.saml.core.domain.SamlStatusCode)11 StatusBuilder.aStatus (uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus)10 IdpIdaStatus (uk.gov.ida.saml.hub.domain.IdpIdaStatus)9 StatusMessage (org.opensaml.saml.saml2.core.StatusMessage)6 SamlTransformationErrorFactory.invalidStatusCode (uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.invalidStatusCode)5 SamlTransformationErrorFactory.invalidSubStatusCode (uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.invalidSubStatusCode)5 Issuer (org.opensaml.saml.saml2.core.Issuer)4 StatusBuilder (org.opensaml.saml.saml2.core.impl.StatusBuilder)4 StatusCodeBuilder (org.opensaml.saml.saml2.core.impl.StatusCodeBuilder)4 TransactionIdaStatus (uk.gov.ida.saml.core.domain.TransactionIdaStatus)4 LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)3 SamlValidationException (uk.gov.ida.saml.hub.exception.SamlValidationException)3 XMLObject (org.opensaml.core.xml.XMLObject)2 Response (org.opensaml.saml.saml2.core.Response)2 IssuerBuilder (org.opensaml.saml.saml2.core.impl.IssuerBuilder)2