use of org.apereo.cas.web.GoogleCaptchaV2Validator in project cas by apereo.
the class ValidateCaptchaActionTests method verifyCaptchaFails.
@Test
public void verifyCaptchaFails() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
try (val webServer = new MockWebServer(9305, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE)) {
webServer.start();
val props = new GoogleRecaptchaProperties().setVerifyUrl("http://localhost:9305");
val validateAction = new ValidateCaptchaAction(new GoogleCaptchaV2Validator(props), captchaActivationStrategy);
val result = validateAction.execute(context);
assertNotNull(result);
assertEquals(CasWebflowConstants.TRANSITION_ID_CAPTCHA_ERROR, result.getId());
}
}
Aggregations