Search in sources :

Example 26 with DefaultRegisteredServiceProperty

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

the class JwtTokenCipherSigningPublicKeyEndpointTests method verifyOperation.

@Test
public void verifyOperation() throws Exception {
    val service = RegisteredServiceTestUtils.getService("https://publickey.service");
    val registeredService = RegisteredServiceTestUtils.getRegisteredService(service.getId());
    val signingKey = new DefaultRegisteredServiceProperty();
    signingKey.addValue("classpath:/jwtRS256.key");
    registeredService.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.TOKEN_AS_SERVICE_TICKET_SIGNING_KEY.getPropertyName(), signingKey);
    servicesManager.save(registeredService);
    assertNotNull(endpoint.fetchPublicKey(service.getId()));
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with DefaultRegisteredServiceProperty

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

the class DefaultCaptchaActivationStrategyTests method verifyByIpPatternPerService.

@Test
public void verifyByIpPatternPerService() {
    val servicesManager = mock(ServicesManager.class);
    val strategy = new DefaultCaptchaActivationStrategy(servicesManager);
    val request = new MockHttpServletRequest();
    val context = getRequestContext(request);
    request.setRemoteAddr("185.86.151.99");
    request.setLocalAddr("195.88.151.11");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    val service = RegisteredServiceTestUtils.getService(UUID.randomUUID().toString());
    val registeredService = RegisteredServiceTestUtils.getRegisteredService(service.getId());
    registeredService.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.CAPTCHA_ENABLED.getPropertyName(), new DefaultRegisteredServiceProperty("true"));
    registeredService.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.CAPTCHA_IP_ADDRESS_PATTERN.getPropertyName(), new DefaultRegisteredServiceProperty("no-match1", "no-match2", "\\d\\d\\.8.+\\.99"));
    when(servicesManager.findServiceBy(any(Service.class))).thenReturn(registeredService);
    WebUtils.putServiceIntoFlowScope(context, service);
    val properties = new GoogleRecaptchaProperties().setEnabled(false);
    assertTrue(strategy.shouldActivate(context, properties).isPresent());
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) GoogleRecaptchaProperties(org.apereo.cas.configuration.model.support.captcha.GoogleRecaptchaProperties) Service(org.apereo.cas.authentication.principal.Service) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test)

Example 28 with DefaultRegisteredServiceProperty

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

the class ValidateCaptchaActionTests method verifyCaptchaValidationSkipped.

@Test
public void verifyCaptchaValidationSkipped() throws Exception {
    val context = new MockRequestContext();
    val request = new MockHttpServletRequest();
    val data = "{\"success\": true }";
    request.addParameter(GoogleCaptchaV2Validator.REQUEST_PARAM_RECAPTCHA_RESPONSE, data);
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
    val service = RegisteredServiceTestUtils.getService(UUID.randomUUID().toString());
    val registeredService = RegisteredServiceTestUtils.getRegisteredService(service.getId());
    registeredService.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.CAPTCHA_ENABLED.getPropertyName(), new DefaultRegisteredServiceProperty("false"));
    servicesManager.save(registeredService);
    WebUtils.putServiceIntoFlowScope(context, service);
    val result = validateCaptchaAction.execute(context);
    assertNull(result);
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

DefaultRegisteredServiceProperty (org.apereo.cas.services.DefaultRegisteredServiceProperty)28 lombok.val (lombok.val)24 Test (org.junit.jupiter.api.Test)20 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)7 HashSet (java.util.HashSet)4 LinkedHashMap (java.util.LinkedHashMap)4 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)4 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)4 HashMap (java.util.HashMap)3 Service (org.apereo.cas.authentication.principal.Service)3 AnonymousRegisteredServiceUsernameAttributeProvider (org.apereo.cas.services.AnonymousRegisteredServiceUsernameAttributeProvider)3 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)3 ShibbolethCompatiblePersistentIdGenerator (org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator)2 GoogleRecaptchaProperties (org.apereo.cas.configuration.model.support.captcha.GoogleRecaptchaProperties)2 RefuseRegisteredServiceProxyPolicy (org.apereo.cas.services.RefuseRegisteredServiceProxyPolicy)2 RegisteredServiceProperty (org.apereo.cas.services.RegisteredServiceProperty)2 RegisteredServicePublicKeyImpl (org.apereo.cas.services.RegisteredServicePublicKeyImpl)2 ReturnAllAttributeReleasePolicy (org.apereo.cas.services.ReturnAllAttributeReleasePolicy)2 ClientInfo (org.apereo.inspektr.common.web.ClientInfo)2