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()));
}
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());
}
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);
}
Aggregations