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());
}
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));
}
Aggregations