Search in sources :

Example 1 with TransactionIdaStatus

use of uk.gov.ida.saml.core.domain.TransactionIdaStatus 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)

Example 2 with TransactionIdaStatus

use of uk.gov.ida.saml.core.domain.TransactionIdaStatus in project verify-hub by alphagov.

the class TransactionIdaStatusUnmarshallerTest method transform_shouldTransformRequesterErrorFromIdpAsSentByHub.

@Test
public void transform_shouldTransformRequesterErrorFromIdpAsSentByHub() {
    Status status = aStatus().withStatusCode(aStatusCode().withValue(StatusCode.RESPONDER).withSubStatusCode(aStatusCode().withValue(StatusCode.REQUESTER).build()).build()).build();
    TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(status);
    assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.RequesterError);
}
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) TransactionIdaStatus(uk.gov.ida.saml.core.domain.TransactionIdaStatus) Test(org.junit.jupiter.api.Test)

Example 3 with TransactionIdaStatus

use of uk.gov.ida.saml.core.domain.TransactionIdaStatus in project verify-hub by alphagov.

the class TransactionIdaStatusUnmarshallerTest 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);
    TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(status);
    assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.AuthenticationFailed);
}
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)

Example 4 with TransactionIdaStatus

use of uk.gov.ida.saml.core.domain.TransactionIdaStatus in project verify-hub by alphagov.

the class TransactionIdaStatusUnmarshallerTest 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);
    TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
    assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.Success);
}
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)

Example 5 with TransactionIdaStatus

use of uk.gov.ida.saml.core.domain.TransactionIdaStatus in project verify-hub by alphagov.

the class TransactionIdaStatusUnmarshallerTest 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);
    TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
    assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
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

Test (org.junit.jupiter.api.Test)5 Status (org.opensaml.saml.saml2.core.Status)5 TransactionIdaStatus (uk.gov.ida.saml.core.domain.TransactionIdaStatus)5 StatusBuilder.aStatus (uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus)5 StatusCode (org.opensaml.saml.saml2.core.StatusCode)4 OpenSamlXmlObjectFactory (uk.gov.ida.saml.core.OpenSamlXmlObjectFactory)4 SamlStatusCode (uk.gov.ida.saml.core.domain.SamlStatusCode)4 StatusCodeBuilder.aStatusCode (uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode)4