Search in sources :

Example 1 with GenerateCaptchaResult

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));
}
Also used : GenerateCaptureResponseEnvelope(org.haiku.haikudepotserver.api2.model.GenerateCaptureResponseEnvelope) GenerateCaptchaResult(org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult) GenerateCaptchaRequest(org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaRequest)

Example 2 with GenerateCaptchaResult

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();
}
Also used : GenerateCaptchaResult(org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult) GenerateCaptchaRequest(org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaRequest) Test(org.junit.jupiter.api.Test) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest)

Example 3 with GenerateCaptchaResult

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;
}
Also used : Captcha(org.haiku.haikudepotserver.captcha.model.Captcha) GenerateCaptchaResult(org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult)

Aggregations

GenerateCaptchaResult (org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaResult)3 GenerateCaptchaRequest (org.haiku.haikudepotserver.api1.model.captcha.GenerateCaptchaRequest)2 AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)1 GenerateCaptureResponseEnvelope (org.haiku.haikudepotserver.api2.model.GenerateCaptureResponseEnvelope)1 Captcha (org.haiku.haikudepotserver.captcha.model.Captcha)1 Test (org.junit.jupiter.api.Test)1