use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder 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.DefaultSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.
the class DefaultLogoutManagerTests method initialize.
@BeforeEach
public void initialize() {
tgt = new MockTicketGrantingTicket("casuser");
when(client.isValidEndPoint(any(String.class))).thenReturn(true);
when(client.isValidEndPoint(any(URL.class))).thenReturn(true);
when(client.sendMessageToEndPoint(any(HttpMessage.class))).thenReturn(true);
val validator = new SimpleUrlValidatorFactoryBean(true).getObject();
singleLogoutServiceMessageHandler = new DefaultSingleLogoutServiceMessageHandler(client, new DefaultSingleLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, validator), true, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
this.simpleWebApplicationServiceImpl = getService(URL);
tgt.getServices().put(ID, this.simpleWebApplicationServiceImpl);
val plan = new DefaultLogoutExecutionPlan();
plan.registerSingleLogoutServiceMessageHandler(singleLogoutServiceMessageHandler);
this.logoutManager = new DefaultLogoutManager(false, plan);
this.registeredService = getRegisteredService(URL);
when(servicesManager.findServiceBy(this.simpleWebApplicationServiceImpl)).thenReturn(this.registeredService);
assertTrue(plan.getLogoutRedirectionStrategies().isEmpty());
}
use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder 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));
}
use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.
the class DefaultSingleLogoutServiceMessageHandlerTests method verifyEmpty.
@Test
public void verifyEmpty() {
val servicesManager = mock(ServicesManager.class);
val service = new RegexRegisteredService();
service.setServiceId(UUID.randomUUID().toString());
when(servicesManager.findServiceBy(any(Service.class))).thenReturn(service);
val handler = new DefaultSingleLogoutServiceMessageHandler(new SimpleHttpClientFactoryBean().getObject(), new DefaultSingleLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, mock(UrlValidator.class)), false, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
assertTrue(handler.handle(CoreAuthenticationTestUtils.getWebApplicationService(), UUID.randomUUID().toString(), SingleLogoutExecutionRequest.builder().build()).isEmpty());
}
Aggregations