Search in sources :

Example 41 with RegexRegisteredService

use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.

the class ServiceThemeResolverTests method verifyGetServiceThemeDoesNotExist.

@Test
public void verifyGetServiceThemeDoesNotExist() {
    val r = new RegexRegisteredService();
    r.setTheme("myTheme");
    r.setId(1000);
    r.setName("Test Service");
    r.setServiceId("myServiceId");
    this.servicesManager.save(r);
    val request = new MockHttpServletRequest();
    val ctx = mock(RequestContext.class);
    val scope = new LocalAttributeMap<>();
    scope.put(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(r.getServiceId()));
    when(ctx.getFlowScope()).thenReturn(scope);
    RequestContextHolder.setRequestContext(ctx);
    request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, MOZILLA);
    assertEquals(DEFAULT_THEME_NAME, this.themeResolver.resolveThemeName(request));
}
Also used : lombok.val(lombok.val) LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 42 with RegexRegisteredService

use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.

the class ServiceAuthorizationCheckMockitoActionTests method getAction.

private Action getAction() {
    val authorizedRegisteredService = new RegexRegisteredService();
    val unauthorizedRegisteredService = new RegexRegisteredService();
    unauthorizedRegisteredService.setAccessStrategy(new DefaultRegisteredServiceAccessStrategy(false, false));
    val list = new ArrayList<RegisteredService>();
    list.add(authorizedRegisteredService);
    list.add(unauthorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.authorizedService)).thenReturn(authorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.unauthorizedService)).thenReturn(unauthorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.undefinedService)).thenReturn(null);
    when(this.servicesManager.getAllServices()).thenReturn(list);
    return new ServiceAuthorizationCheckAction(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
}
Also used : lombok.val(lombok.val) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) ArrayList(java.util.ArrayList) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) DefaultRegisteredServiceAccessStrategy(org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy)

Aggregations

RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)42 lombok.val (lombok.val)12 Test (org.junit.Test)12 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)10 RegisteredService (org.apereo.cas.services.RegisteredService)10 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)8 Service (org.apereo.cas.authentication.principal.Service)6 Test (org.junit.jupiter.api.Test)6 RegisteredServiceEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceEditBean)5 DefaultRegisteredServiceAccessStrategy (org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)4 URL (java.net.URL)3 SecureRandom (java.security.SecureRandom)3 HashMap (java.util.HashMap)3 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)3 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)3 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)3 AnonymousRegisteredServiceUsernameAttributeProvider (org.apereo.cas.services.AnonymousRegisteredServiceUsernameAttributeProvider)3