Search in sources :

Example 11 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode 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 12 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode 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 13 with StatusCode

use of org.opensaml.saml.saml2.core.StatusCode 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 14 with StatusCode

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

Example 15 with StatusCode

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

the class TransactionIdaStatusUnmarshallerTest method transform_shouldTransformNoMatchFromHub.

@Test
public void transform_shouldTransformNoMatchFromHub() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status originalStatus = samlObjectFactory.createStatus();
    StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
    topLevelStatusCode.setValue(StatusCode.SUCCESS);
    StatusCode subStatusCode = samlObjectFactory.createStatusCode();
    subStatusCode.setValue(SamlStatusCode.NO_MATCH);
    topLevelStatusCode.setStatusCode(subStatusCode);
    originalStatus.setStatusCode(topLevelStatusCode);
    TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
    assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.NoMatchingServiceMatchFromHub);
}
Also used : Status(org.opensaml.saml.saml2.core.Status) TransactionIdaStatus(uk.gov.ida.saml.core.domain.TransactionIdaStatus) StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) TransactionIdaStatus(uk.gov.ida.saml.core.domain.TransactionIdaStatus) SamlStatusCode(uk.gov.ida.saml.core.domain.SamlStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) 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