Search in sources :

Example 1 with ChainingSingleLogoutServiceLogoutUrlBuilder

use of org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.

the class ChainingSingleLogoutServiceLogoutUrlBuilderTests method verifyOperation.

@Test
public void verifyOperation() {
    val builder = new ChainingSingleLogoutServiceLogoutUrlBuilder(List.of(new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, SimpleUrlValidator.getInstance())));
    val service = CoreAuthenticationTestUtils.getWebApplicationService();
    val registeredService = mock(RegexRegisteredService.class);
    when(registeredService.matches(any(Service.class))).thenReturn(Boolean.TRUE);
    when(registeredService.getFriendlyName()).thenCallRealMethod();
    when(registeredService.getServiceId()).thenReturn(CoreAuthenticationTestUtils.CONST_TEST_URL);
    when(registeredService.matches(anyString())).thenReturn(Boolean.TRUE);
    when(registeredService.getAccessStrategy()).thenReturn(new DefaultRegisteredServiceAccessStrategy());
    when(registeredService.getLogoutUrl()).thenReturn("https://somewhere.org");
    servicesManager.save(registeredService);
    assertTrue(builder.supports(registeredService, service, Optional.empty()));
    assertTrue(builder.isServiceAuthorized(service, Optional.empty(), Optional.empty()));
    assertFalse(builder.determineLogoutUrl(registeredService, service, Optional.empty()).isEmpty());
}
Also used : lombok.val(lombok.val) ChainingSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) Service(org.apereo.cas.authentication.principal.Service) DefaultRegisteredServiceAccessStrategy(org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy) Test(org.junit.jupiter.api.Test)

Example 2 with ChainingSingleLogoutServiceLogoutUrlBuilder

use of org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.

the class SamlIdPSingleLogoutServiceLogoutUrlBuilderTests method verifyChainOperation.

@Test
public void verifyChainOperation() {
    val defaultBuilder = new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, SimpleUrlValidator.getInstance());
    val chain = new ChainingSingleLogoutServiceLogoutUrlBuilder(List.of(samlLogoutUrlBuilder, defaultBuilder));
    val samlRegisteredService = SamlIdPTestUtils.getSamlRegisteredService();
    samlRegisteredService.setLogoutType(RegisteredServiceLogoutType.FRONT_CHANNEL);
    val service = RegisteredServiceTestUtils.getService("https://mocky.io");
    val results = chain.determineLogoutUrl(samlRegisteredService, service);
    assertEquals(1, results.size());
    val res = results.iterator().next();
    assertTrue(res.getProperties().containsKey(SamlIdPSingleLogoutServiceLogoutUrlBuilder.PROPERTY_NAME_SINGLE_LOGOUT_BINDING));
}
Also used : lombok.val(lombok.val) ChainingSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)2 ChainingSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder)2 DefaultSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder)2 Test (org.junit.jupiter.api.Test)2 Service (org.apereo.cas.authentication.principal.Service)1 DefaultRegisteredServiceAccessStrategy (org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy)1 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)1