Search in sources :

Example 1 with SAML2ResponseValidator

use of org.pac4j.saml.profile.api.SAML2ResponseValidator in project pac4j by pac4j.

the class SAML2LogoutMessageReceiverTest method shouldAcceptLogoutResponse.

@Test
public void shouldAcceptLogoutResponse() {
    var webContext = getMockWebContext();
    var context = getSaml2MessageContext(webContext);
    SAML2ResponseValidator validator = getLogoutValidator("/logoutUrl");
    var unit = new SAML2LogoutMessageReceiver(validator, context.getSAML2Configuration());
    try {
        unit.receiveMessage(context);
        fail("Should have thrown a FoundAction");
    } catch (SAMLException e) {
        fail(e.getMessage());
    } catch (FoundAction e) {
        assertTrue("SAML2LogoutMessageReceiver processed the logout message successfully", true);
        MatcherAssert.assertThat(e.getLocation(), is("/logoutUrl"));
    }
}
Also used : SAML2ResponseValidator(org.pac4j.saml.profile.api.SAML2ResponseValidator) FoundAction(org.pac4j.core.exception.http.FoundAction) SAMLException(org.pac4j.saml.exceptions.SAMLException) Test(org.junit.Test)

Example 2 with SAML2ResponseValidator

use of org.pac4j.saml.profile.api.SAML2ResponseValidator in project pac4j by pac4j.

the class SAML2LogoutMessageReceiverTest method shouldAcceptLogoutResponseWithNoRedirect.

@Test
public void shouldAcceptLogoutResponseWithNoRedirect() {
    var webContext = getMockWebContext();
    var context = getSaml2MessageContext(webContext);
    SAML2ResponseValidator validator = getLogoutValidator("");
    var unit = new SAML2LogoutMessageReceiver(validator, context.getSAML2Configuration());
    try {
        unit.receiveMessage(context);
        fail("Should have thrown a FoundAction");
    } catch (SAMLException e) {
        fail(e.getMessage());
    } catch (OkAction e) {
        assertTrue("SAML2LogoutMessageReceiver processed the logout message successfully", true);
        MatcherAssert.assertThat(e.getContent(), is(""));
    }
}
Also used : SAML2ResponseValidator(org.pac4j.saml.profile.api.SAML2ResponseValidator) SAMLException(org.pac4j.saml.exceptions.SAMLException) OkAction(org.pac4j.core.exception.http.OkAction) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SAMLException (org.pac4j.saml.exceptions.SAMLException)2 SAML2ResponseValidator (org.pac4j.saml.profile.api.SAML2ResponseValidator)2 FoundAction (org.pac4j.core.exception.http.FoundAction)1 OkAction (org.pac4j.core.exception.http.OkAction)1