use of org.apereo.cas.configuration.model.support.captcha.GoogleRecaptchaProperties in project cas by apereo.
the class GoogleCaptchaV3ValidatorTests method verifyOperation.
@Test
public void verifyOperation() {
val props = new GoogleRecaptchaProperties().setScore(.1).setSecret(UUID.randomUUID().toString()).setVerifyUrl("http://localhost:8812");
val validator = new GoogleCaptchaV3Validator(props);
val request = new MockHttpServletRequest();
request.addParameter(GoogleCaptchaV3Validator.REQUEST_PARAM_RECAPTCHA_TOKEN, UUID.randomUUID().toString());
assertNotNull(validator.getRecaptchaResponse(request));
}
use of org.apereo.cas.configuration.model.support.captcha.GoogleRecaptchaProperties in project cas by apereo.
the class CaptchaValidatorTests method verifyBadResponse.
@Test
public void verifyBadResponse() {
val secret = UUID.randomUUID().toString();
val props = new GoogleRecaptchaProperties().setScore(1).setSecret(secret).setVerifyUrl("http://localhost:8812");
val validator = new GoogleCaptchaV2Validator(props);
try (val webServer = new MockWebServer(8812, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val response = UUID.randomUUID().toString();
assertFalse(validator.validate(response, "Mozilla/5.0"));
}
}
Aggregations