use of com.nexblocks.authguard.api.dto.requests.OtpRequestDTO in project AuthGuard by AuthGuard.
the class OtpRoute method verify.
public void verify(final Context context) {
final OtpRequestDTO body = otpRequestBodyHandler.getValidated(context);
final RequestContextBO requestContext = RequestContextExtractor.extractWithoutIdempotentKey(context);
final AuthResponseDTO tokens = restMapper.toDTO(otpService.authenticate(body.getPasswordId(), body.getPassword(), requestContext));
context.json(tokens);
}
use of com.nexblocks.authguard.api.dto.requests.OtpRequestDTO in project AuthGuard by AuthGuard.
the class OtpRequestValidatorTest method validateMissingFields.
@Test
void validateMissingFields() {
final OtpRequestDTO request = OtpRequestDTO.builder().build();
final Validator<OtpRequestDTO> validator = Validators.getForClass(OtpRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).containsExactlyInAnyOrder(new Violation("password", ViolationType.MISSING_REQUIRED_VALUE), new Violation("passwordId", ViolationType.MISSING_REQUIRED_VALUE));
}
use of com.nexblocks.authguard.api.dto.requests.OtpRequestDTO in project AuthGuard by AuthGuard.
the class OtpRequestValidatorTest method validateValid.
@Test
void validateValid() {
final OtpRequestDTO request = OtpRequestDTO.builder().passwordId("password-id").password("password").build();
final Validator<OtpRequestDTO> validator = Validators.getForClass(OtpRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
Aggregations