use of org.apereo.cas.configuration.model.core.sso.SingleSignOnProperties in project cas by apereo.
the class DefaultSingleSignOnParticipationStrategyTests method verifyRegisteredServiceWithValidSsoAndServiceExpPolicy.
@Test
public void verifyRegisteredServiceWithValidSsoAndServiceExpPolicy() {
val mgr = mock(ServicesManager.class);
val registeredService = CoreAuthenticationTestUtils.getRegisteredService();
when(registeredService.getAccessStrategy().isServiceAccessAllowedForSso()).thenReturn(true);
when(registeredService.getTicketGrantingTicketExpirationPolicy()).thenReturn(new DefaultRegisteredServiceTicketGrantingTicketExpirationPolicy(1));
when(mgr.findServiceBy(any(Service.class))).thenReturn(registeredService);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val tgt = new MockTicketGrantingTicket("casuser");
tgt.setCreated(ZonedDateTime.now(ZoneOffset.UTC).minusHours(1));
val sso = new SingleSignOnProperties();
val ticketRegistrySupport = mock(TicketRegistrySupport.class);
when(ticketRegistrySupport.getTicket(anyString())).thenReturn(tgt);
val strategy = new DefaultSingleSignOnParticipationStrategy(mgr, sso, ticketRegistrySupport, mock(AuthenticationServiceSelectionPlan.class));
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
WebUtils.putRegisteredService(context, registeredService);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication("casuser"), context);
WebUtils.putTicketGrantingTicketInScopes(context, tgt);
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(request).requestContext(context).build();
assertFalse(strategy.isParticipating(ssoRequest));
}
use of org.apereo.cas.configuration.model.core.sso.SingleSignOnProperties in project cas by apereo.
the class DefaultSingleSignOnParticipationStrategyTests method verifyRegisteredServiceFromContextEvaluatedBeforeService.
@Test
public void verifyRegisteredServiceFromContextEvaluatedBeforeService() {
val mgr = mock(ServicesManager.class);
val registeredService = CoreAuthenticationTestUtils.getRegisteredService();
val callbackRegisteredService = CoreAuthenticationTestUtils.getRegisteredService("https://cas/idp/profile/SAML2/Callback");
when(registeredService.getAccessStrategy().isServiceAccessAllowedForSso()).thenReturn(false);
when(callbackRegisteredService.getAccessStrategy().isServiceAccessAllowedForSso()).thenReturn(true);
when(mgr.findServiceBy(any(Service.class))).thenReturn(callbackRegisteredService);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val sso = new SingleSignOnProperties().setCreateSsoCookieOnRenewAuthn(false).setRenewAuthnEnabled(true);
val strategy = new DefaultSingleSignOnParticipationStrategy(mgr, sso, mock(TicketRegistrySupport.class), mock(AuthenticationServiceSelectionPlan.class));
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
WebUtils.putRegisteredService(context, registeredService);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication("casuser"), context);
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(request).requestContext(context).build();
assertFalse(strategy.isParticipating(ssoRequest));
}
use of org.apereo.cas.configuration.model.core.sso.SingleSignOnProperties in project cas by apereo.
the class DefaultSingleSignOnParticipationStrategyTests method verifyParticipatesForRenewDisabled.
@Test
public void verifyParticipatesForRenewDisabled() {
val mgr = mock(ServicesManager.class);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val sso = new SingleSignOnProperties().setCreateSsoCookieOnRenewAuthn(false).setRenewAuthnEnabled(true);
val strategy = new DefaultSingleSignOnParticipationStrategy(mgr, sso, mock(TicketRegistrySupport.class), mock(AuthenticationServiceSelectionPlan.class));
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(request).requestContext(context).build();
assertFalse(strategy.isParticipating(ssoRequest));
}
use of org.apereo.cas.configuration.model.core.sso.SingleSignOnProperties in project cas by apereo.
the class DefaultSingleSignOnParticipationStrategyTests method verifyDoesNotParticipateForService.
@Test
public void verifyDoesNotParticipateForService() {
val mgr = mock(ServicesManager.class);
val registeredService = CoreAuthenticationTestUtils.getRegisteredService();
when(registeredService.getAccessStrategy().isServiceAccessAllowedForSso()).thenReturn(false);
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();
assertFalse(strategy.isParticipating(ssoRequest));
}
Aggregations