Search in sources :

Example 31 with Status

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

the class EncryptedResponseFromMatchingServiceValidatorTest method validateResponse_shouldThrowExceptionForFailureResponsesWithAssertions.

@Test
public void validateResponse_shouldThrowExceptionForFailureResponsesWithAssertions() throws Exception {
    Status status = createStatus(StatusCode.RESPONDER, createSubStatusCode(SamlStatusCode.NO_MATCH));
    Response response = aResponse().withStatus(status).build();
    assertValidationFailure(response, nonSuccessHasUnEncryptedAssertions());
}
Also used : ResponseValidatorTestHelper.createStatus(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus) Status(org.opensaml.saml.saml2.core.Status) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.jupiter.api.Test)

Example 32 with Status

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

the class MatchingServiceIdaStatusUnmarshallerTest method transform_shouldTransformHealthyStatusFromMatchingService.

@Test
public void transform_shouldTransformHealthyStatusFromMatchingService() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status status = samlObjectFactory.createStatus();
    StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
    topLevelStatusCode.setValue(StatusCode.SUCCESS);
    status.setStatusCode(topLevelStatusCode);
    StatusCode subStatusCode = samlObjectFactory.createStatusCode();
    subStatusCode.setValue(SamlStatusCode.HEALTHY);
    topLevelStatusCode.setStatusCode(subStatusCode);
    MatchingServiceIdaStatus transformedStatus = unmarshaller.fromSaml(status);
    assertThat(transformedStatus).isEqualTo(MatchingServiceIdaStatus.Healthy);
}
Also used : Status(org.opensaml.saml.saml2.core.Status) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) SamlStatusCode(uk.gov.ida.saml.core.domain.SamlStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 33 with Status

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

the class MatchingServiceIdaStatusUnmarshallerTest method transform_shouldTransformNoMatchFromMatchingService.

@Test
public void transform_shouldTransformNoMatchFromMatchingService() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status originalStatus = samlObjectFactory.createStatus();
    StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
    topLevelStatusCode.setValue(StatusCode.RESPONDER);
    StatusCode subStatusCode = samlObjectFactory.createStatusCode();
    subStatusCode.setValue(SamlStatusCode.NO_MATCH);
    topLevelStatusCode.setStatusCode(subStatusCode);
    originalStatus.setStatusCode(topLevelStatusCode);
    MatchingServiceIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
    assertThat(transformedStatus).isEqualTo(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService);
}
Also used : Status(org.opensaml.saml.saml2.core.Status) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) SamlStatusCode(uk.gov.ida.saml.core.domain.SamlStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 34 with Status

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

the class MatchingServiceIdaStatusUnmarshallerTest method transform_shouldTransformRequesterErrorFromMatchingService.

@Test
public void transform_shouldTransformRequesterErrorFromMatchingService() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status originalStatus = samlObjectFactory.createStatus();
    StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
    topLevelStatusCode.setValue(StatusCode.REQUESTER);
    originalStatus.setStatusCode(topLevelStatusCode);
    MatchingServiceIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
    assertThat(transformedStatus).isEqualTo(MatchingServiceIdaStatus.RequesterError);
}
Also used : Status(org.opensaml.saml.saml2.core.Status) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) SamlStatusCode(uk.gov.ida.saml.core.domain.SamlStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 35 with Status

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

the class MatchingServiceIdaStatusUnmarshallerTest method transform_shouldTransformMatchingServiceSuccessfulMatch.

@Test
public void transform_shouldTransformMatchingServiceSuccessfulMatch() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status originalStatus = samlObjectFactory.createStatus();
    StatusCode successStatusCode = samlObjectFactory.createStatusCode();
    successStatusCode.setValue(StatusCode.SUCCESS);
    originalStatus.setStatusCode(successStatusCode);
    StatusCode matchStatusCode = samlObjectFactory.createStatusCode();
    matchStatusCode.setValue(SamlStatusCode.MATCH);
    successStatusCode.setStatusCode(matchStatusCode);
    MatchingServiceIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
    assertThat(transformedStatus).isEqualTo(MatchingServiceIdaStatus.MatchingServiceMatch);
}
Also used : Status(org.opensaml.saml.saml2.core.Status) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) SamlStatusCode(uk.gov.ida.saml.core.domain.SamlStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Aggregations

Status (org.opensaml.saml.saml2.core.Status)103 Test (org.junit.jupiter.api.Test)83 Response (org.opensaml.saml.saml2.core.Response)59 StatusCode (org.opensaml.saml.saml2.core.StatusCode)33 IdpIdaStatus (uk.gov.ida.saml.hub.domain.IdpIdaStatus)33 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)27 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)22 SAMLCallback (org.apache.wss4j.common.saml.SAMLCallback)20 Document (org.w3c.dom.Document)20 TransactionIdaStatus (uk.gov.ida.saml.core.domain.TransactionIdaStatus)20 Element (org.w3c.dom.Element)19 StatusBuilder.aStatus (uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus)19 DateTime (org.joda.time.DateTime)17 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)16 ResponseValidatorTestHelper.createStatus (uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus)16 OpenSamlXmlObjectFactory (uk.gov.ida.saml.core.OpenSamlXmlObjectFactory)14 StatusCodeBuilder.aStatusCode (uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode)14 Crypto (org.apache.wss4j.common.crypto.Crypto)9 SamlStatusCode (uk.gov.ida.saml.core.domain.SamlStatusCode)9 InputStream (java.io.InputStream)8