use of org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult in project haikudepotserver by haiku.
the class CaptchaApiImpl method generateCaptcha.
@Override
public ResponseEntity<GenerateCaptureResponseEnvelope> generateCaptcha(Object body) {
GenerateCaptchaResult resultV1 = captchaApiV1.generateCaptcha(new GenerateCaptchaRequest());
org.haiku.haikudepotserver.api2.model.GenerateCaptchaResult resultV2 = new org.haiku.haikudepotserver.api2.model.GenerateCaptchaResult();
resultV2.setToken(resultV1.token);
resultV2.setPngImageDataBase64(resultV1.pngImageDataBase64);
return ResponseEntity.ok(new GenerateCaptureResponseEnvelope().result(resultV2));
}
use of org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult in project haikudepotserver by haiku.
the class CaptchaApiIT method testGenerateCaptcha.
/**
* <p>This is a bit of a limited test because there is nothing to actually check without having a person
* to interpret the image. In any case, it will provide for an element of just exercising the API to make
* sure that it at least does not fail.</p>
*/
@Test
public void testGenerateCaptcha() {
// ------------------------------------
GenerateCaptchaResult result = captchaApi.generateCaptcha(new GenerateCaptchaRequest());
// ------------------------------------
Assertions.assertThat(result.token).isNotEmpty();
Assertions.assertThat(captchaRepository.get(result.token)).isNotNull();
}
use of org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult in project haikudepotserver by haiku.
the class CaptchaApiImpl method generateCaptcha.
@Override
public GenerateCaptchaResult generateCaptcha(GenerateCaptchaRequest generateCaptchaRequest) {
Preconditions.checkNotNull(generateCaptchaRequest);
Captcha captcha = captchaService.generate();
GenerateCaptchaResult result = new GenerateCaptchaResult();
result.token = captcha.getToken();
result.pngImageDataBase64 = BaseEncoding.base64().encode(captcha.getPngImageData());
return result;
}
Aggregations