Search in sources :

Example 1 with OtpRequestDTO

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);
}
Also used : RequestContextBO(com.nexblocks.authguard.service.model.RequestContextBO) AuthResponseDTO(com.nexblocks.authguard.api.dto.entities.AuthResponseDTO) OtpRequestDTO(com.nexblocks.authguard.api.dto.requests.OtpRequestDTO)

Example 2 with OtpRequestDTO

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));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) OtpRequestDTO(com.nexblocks.authguard.api.dto.requests.OtpRequestDTO) Test(org.junit.jupiter.api.Test)

Example 3 with OtpRequestDTO

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();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) OtpRequestDTO(com.nexblocks.authguard.api.dto.requests.OtpRequestDTO) Test(org.junit.jupiter.api.Test)

Aggregations

OtpRequestDTO (com.nexblocks.authguard.api.dto.requests.OtpRequestDTO)3 Violation (com.nexblocks.authguard.api.dto.validation.violations.Violation)2 Test (org.junit.jupiter.api.Test)2 AuthResponseDTO (com.nexblocks.authguard.api.dto.entities.AuthResponseDTO)1 RequestContextBO (com.nexblocks.authguard.service.model.RequestContextBO)1