Search in sources :

Example 6 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode 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());
}
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 7 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.

the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformRequesterErrorWithRequestDeniedSubstatus.

@Test
public void transform_shouldTransformRequesterErrorWithRequestDeniedSubstatus() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status status = samlObjectFactory.createStatus();
    StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
    topLevelStatusCode.setValue(StatusCode.REQUESTER);
    StatusCode subStatusCode = samlObjectFactory.createStatusCode();
    subStatusCode.setValue(StatusCode.REQUEST_DENIED);
    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 8 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.

the class ResponseValidatorTestHelper method createStatus.

public static Status createStatus(String statusCodeValue, StatusCode subStatusCode) {
    StatusCodeBuilder statusCodeBuilder = aStatusCode().withValue(statusCodeValue);
    StatusCode statusCode = subStatusCode == null ? statusCodeBuilder.build() : statusCodeBuilder.withSubStatusCode(subStatusCode).build();
    return aStatus().withStatusCode(statusCode).build();
}
Also used : StatusCodeBuilder(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder) StatusCode(org.opensaml.saml.saml2.core.StatusCode) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode)

Example 9 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.

the class EncryptedResponseFromIdpValidatorTest method validateStatus_shouldThrowExceptionIfSuccessHasASubStatus.

@Test
public void validateStatus_shouldThrowExceptionIfSuccessHasASubStatus() throws Exception {
    StatusCode subStatusCode = createSubStatusCode();
    Status status = createStatus(StatusCode.SUCCESS, subStatusCode);
    Response response = aResponse().withStatus(status).build();
    assertValidationFailure(response, invalidSubStatusCode(subStatusCode.getValue(), StatusCode.SUCCESS));
}
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 10 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.

the class EncryptedResponseFromIdpValidatorTest method validateStatus_shouldThrowExceptionIfRequesterHasASubStatus.

@Test
public void validateStatus_shouldThrowExceptionIfRequesterHasASubStatus() throws Exception {
    StatusCode subStatusCode = createSubStatusCode();
    Status status = createStatus(StatusCode.REQUESTER, subStatusCode);
    Response response = aResponse().withStatus(status).build();
    assertValidationFailure(response, invalidSubStatusCode(subStatusCode.getValue(), StatusCode.REQUESTER));
}
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)

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