use of org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy in project cas by apereo.
the class RegisteredServiceAuthenticationPolicyResolverTests method checkAnyPolicy.
@Test
public void checkAnyPolicy() {
val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid1"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
val policies = resolver.resolve(transaction);
assertEquals(1, policies.size());
assertTrue(policies.iterator().next() instanceof AtLeastOneCredentialValidatedAuthenticationPolicy);
}
use of org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy in project cas by apereo.
the class RegisteredServiceAuthenticationPolicyResolverTests method checkGroovyPolicy.
@Test
public void checkGroovyPolicy() {
val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid5"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
val policies = resolver.resolve(transaction);
assertEquals(1, policies.size());
assertTrue(policies.iterator().next() instanceof GroovyScriptAuthenticationPolicy);
}
use of org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy in project cas by apereo.
the class RegisteredServiceAuthenticationPolicyResolverTests method checkAllPolicy.
@Test
public void checkAllPolicy() {
val resolver = new RegisteredServiceAuthenticationPolicyResolver(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid3"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
val policies = resolver.resolve(transaction);
assertEquals(1, policies.size());
assertTrue(policies.iterator().next() instanceof AllAuthenticationHandlersSucceededAuthenticationPolicy);
}
use of org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy in project cas by apereo.
the class DefaultSingleSignOnParticipationStrategyTests method verifyCookieCreationByService.
@Test
public void verifyCookieCreationByService() {
val mgr = mock(ServicesManager.class);
val registeredService = CoreAuthenticationTestUtils.getRegisteredService();
val policy = new DefaultRegisteredServiceSingleSignOnParticipationPolicy();
policy.setCreateCookieOnRenewedAuthentication(TriStateBoolean.FALSE);
when(registeredService.getSingleSignOnParticipationPolicy()).thenReturn(policy);
when(mgr.findServiceBy(any(Service.class))).thenReturn(registeredService);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
val plan = new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy());
val sso = new SingleSignOnProperties().setCreateSsoCookieOnRenewAuthn(false).setRenewAuthnEnabled(true);
val strategy = new DefaultSingleSignOnParticipationStrategy(mgr, sso, mock(TicketRegistrySupport.class), plan);
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication("casuser"), context);
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(request).requestContext(context).build();
val create = strategy.isCreateCookieOnRenewedAuthentication(ssoRequest);
assertTrue(create.isFalse());
}
use of org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy in project cas by apereo.
the class LogoutManagerImplTests method setUp.
@Before
public void setUp() {
when(client.isValidEndPoint(any(String.class))).thenReturn(true);
when(client.isValidEndPoint(any(URL.class))).thenReturn(true);
when(client.sendMessageToEndPoint(any(HttpMessage.class))).thenReturn(true);
singleLogoutServiceMessageHandler = new DefaultSingleLogoutServiceMessageHandler(client, new SamlCompliantLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(), true, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
final Map<String, Service> services = new HashMap<>();
this.simpleWebApplicationServiceImpl = RegisteredServiceTestUtils.getService(URL);
services.put(ID, this.simpleWebApplicationServiceImpl);
when(this.tgt.getServices()).thenReturn(services);
this.logoutManager = new LogoutManagerImpl(new SamlCompliantLogoutMessageCreator(), singleLogoutServiceMessageHandler, false);
this.registeredService = RegisteredServiceTestUtils.getRegisteredService(URL);
when(servicesManager.findServiceBy(this.simpleWebApplicationServiceImpl)).thenReturn(this.registeredService);
}
Aggregations