Search in sources :

Example 26 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class SLOSamlIdPRedirectProfileHandlerControllerTests method verifyOperationRedirectWithParameter.

@Test
@Order(1)
public void verifyOperationRedirectWithParameter() throws Exception {
    val request = new MockHttpServletRequest();
    request.setMethod("GET");
    val response = new MockHttpServletResponse();
    val service = getSamlRegisteredServiceFor(false, false, false, "https://cassp.example.org");
    service.setLogoutUrl("https://github.com/apereo/cas");
    executeTest(request, response, service);
    assertEquals(HttpStatus.SC_OK, response.getStatus());
    assertNotNull(WebUtils.getLogoutRedirectUrl(request, String.class));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 27 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class SLOSamlIdPPostProfileHandlerControllerTests method verifyOperation.

@Test
@Order(1)
public void verifyOperation() throws Exception {
    val request = new MockHttpServletRequest();
    request.setMethod("POST");
    val response = new MockHttpServletResponse();
    val service = getSamlRegisteredServiceFor(false, false, false, "https://cassp.example.org");
    servicesManager.save(service);
    var builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(LogoutRequest.DEFAULT_ELEMENT_NAME);
    var logoutRequest = (LogoutRequest) builder.buildObject();
    builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
    val issuer = (Issuer) builder.buildObject();
    issuer.setValue(service.getServiceId());
    logoutRequest.setIssuer(issuer);
    val adaptor = SamlRegisteredServiceServiceProviderMetadataFacade.get(samlRegisteredServiceCachingMetadataResolver, service, service.getServiceId()).get();
    logoutRequest = samlIdPObjectSigner.encode(logoutRequest, service, adaptor, response, request, SAMLConstants.SAML2_POST_BINDING_URI, logoutRequest, new MessageContext());
    val xml = SamlUtils.transformSamlObject(openSamlConfigBean, logoutRequest).toString();
    request.addParameter(SamlProtocolConstants.PARAMETER_SAML_REQUEST, EncodingUtils.encodeBase64(xml));
    controller.handleSaml2ProfileSLOPostRequest(response, request);
    assertEquals(HttpStatus.SC_OK, response.getStatus());
}
Also used : lombok.val(lombok.val) SAMLObjectBuilder(org.opensaml.saml.common.SAMLObjectBuilder) Issuer(org.opensaml.saml.saml2.core.Issuer) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) LogoutRequest(org.opensaml.saml.saml2.core.LogoutRequest) MessageContext(org.opensaml.messaging.context.MessageContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 28 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class PatternMatchingEntityIdAttributeReleasePolicyTests method verifyPatternDoesMatch.

@Test
@Order(3)
public void verifyPatternDoesMatch() {
    val filter = new PatternMatchingEntityIdAttributeReleasePolicy();
    filter.setEntityIds("https://sp.+");
    filter.setAllowedAttributes(CollectionUtils.wrapList("uid", "givenName", "displayName"));
    val registeredService = SamlIdPTestUtils.getSamlRegisteredService();
    registeredService.setAttributeReleasePolicy(filter);
    val context = RegisteredServiceAttributeReleasePolicyContext.builder().registeredService(registeredService).service(CoreAuthenticationTestUtils.getService()).principal(CoreAuthenticationTestUtils.getPrincipal()).build();
    val attributes = filter.getAttributes(context);
    assertFalse(attributes.isEmpty());
}
Also used : lombok.val(lombok.val) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 29 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class PatternMatchingEntityIdAttributeReleasePolicyTests method verifyPatternDoesNotMatch.

@Test
@Order(1)
public void verifyPatternDoesNotMatch() {
    val filter = new PatternMatchingEntityIdAttributeReleasePolicy();
    filter.setAllowedAttributes(CollectionUtils.wrapList("uid"));
    val registeredService = SamlIdPTestUtils.getSamlRegisteredService();
    registeredService.setAttributeReleasePolicy(filter);
    val context = RegisteredServiceAttributeReleasePolicyContext.builder().registeredService(registeredService).service(CoreAuthenticationTestUtils.getService()).principal(CoreAuthenticationTestUtils.getPrincipal()).build();
    val attributes = filter.getAttributes(context);
    assertTrue(attributes.isEmpty());
}
Also used : lombok.val(lombok.val) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 30 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class WsFederationResponseValidatorTests method verifyFailedOperation.

@Test
@Order(1)
public void verifyFailedOperation() throws Exception {
    val context = prepareContext();
    assertThrows(IllegalArgumentException.class, () -> wsFederationResponseValidator.validateWsFederationAuthenticationRequest(context));
}
Also used : lombok.val(lombok.val) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Order (org.junit.jupiter.api.Order)76 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)76 Test (org.junit.jupiter.api.Test)74 lombok.val (lombok.val)67 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)30 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)24 Service (org.apereo.cas.authentication.principal.Service)23 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 DefaultMultifactorAuthenticationProviderResolver (org.apereo.cas.authentication.DefaultMultifactorAuthenticationProviderResolver)7 Tag (org.junit.jupiter.api.Tag)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 RepeatedTest (org.junit.jupiter.api.RepeatedTest)5 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)4 TicketGrantingTicketFactory (org.apereo.cas.ticket.TicketGrantingTicketFactory)4 MessageContext (org.opensaml.messaging.context.MessageContext)4 JEEContext (org.pac4j.core.context.JEEContext)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 URLBuilder (net.shibboleth.utilities.java.support.net.URLBuilder)3