use of org.apereo.cas.services.ExcludedAuthenticationHandlersRegisteredServiceAuthenticationPolicyCriteria in project cas by apereo.
the class RegisteredServiceAuthenticationPolicySingleSignOnParticipationStrategyTests method verifySsoWithExcludedHandlers.
@Test
public void verifySsoWithExcludedHandlers() throws Exception {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val svc = RegisteredServiceTestUtils.getRegisteredService("serviceid1", Map.of());
val policy = new DefaultRegisteredServiceAuthenticationPolicy();
policy.setCriteria(new ExcludedAuthenticationHandlersRegisteredServiceAuthenticationPolicyCriteria());
policy.setExcludedAuthenticationHandlers(Set.of(SimpleTestUsernamePasswordAuthenticationHandler.class.getName()));
svc.setAuthenticationPolicy(policy);
val ticketRegistry = new DefaultTicketRegistry();
val strategy = getSingleSignOnStrategy(svc, ticketRegistry);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService("serviceid1"));
val tgt = new MockTicketGrantingTicket("casuser");
ticketRegistry.addTicket(tgt);
WebUtils.putTicketGrantingTicketInScopes(context, tgt);
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(request).requestContext(context).build();
assertTrue(strategy.supports(ssoRequest));
assertFalse(strategy.isParticipating(ssoRequest));
}
Aggregations