Search in sources :

Example 6 with Violation

use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.

the class CreateAccountRequestValidatorTest method validateValidEmail.

@Test
void validateValidEmail() {
    final CreateAccountRequestDTO request = CreateAccountRequestDTO.builder().externalId("external").email(AccountEmailDTO.builder().email("valid@valid.com").build()).domain("main").build();
    final Validator<CreateAccountRequestDTO> validator = Validators.getForClass(CreateAccountRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).isEmpty();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreateAccountRequestDTO(com.nexblocks.authguard.api.dto.requests.CreateAccountRequestDTO) Test(org.junit.jupiter.api.Test)

Example 7 with Violation

use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.

the class CreateAccountRequestValidatorTest method validateValidNoFields.

@Test
void validateValidNoFields() {
    final CreateAccountRequestDTO request = CreateAccountRequestDTO.builder().domain("main").build();
    final Validator<CreateAccountRequestDTO> validator = Validators.getForClass(CreateAccountRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).isEmpty();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreateAccountRequestDTO(com.nexblocks.authguard.api.dto.requests.CreateAccountRequestDTO) Test(org.junit.jupiter.api.Test)

Example 8 with Violation

use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.

the class CreateAccountRequestValidatorTest method validateValidBackupEmail.

@Test
void validateValidBackupEmail() {
    final CreateAccountRequestDTO request = CreateAccountRequestDTO.builder().externalId("external").backupEmail(AccountEmailDTO.builder().email("valid@valid.com").build()).domain("main").build();
    final Validator<CreateAccountRequestDTO> validator = Validators.getForClass(CreateAccountRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).isEmpty();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreateAccountRequestDTO(com.nexblocks.authguard.api.dto.requests.CreateAccountRequestDTO) Test(org.junit.jupiter.api.Test)

Example 9 with Violation

use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.

the class CreateAppRequestValidatorTest method validateMissingNameAndDomain.

@Test
void validateMissingNameAndDomain() {
    final CreateAppRequestDTO request = CreateAppRequestDTO.builder().build();
    final Validator<CreateAppRequestDTO> validator = Validators.getForClass(CreateAppRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).containsExactlyInAnyOrder(new Violation("name", ViolationType.MISSING_REQUIRED_VALUE), new Violation("domain", ViolationType.MISSING_REQUIRED_VALUE));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreateAppRequestDTO(com.nexblocks.authguard.api.dto.requests.CreateAppRequestDTO) Test(org.junit.jupiter.api.Test)

Example 10 with Violation

use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.

the class CreateCredentialsRequestValidatorTest method validateInvalidIdentifierFields.

@Test
void validateInvalidIdentifierFields() {
    final CreateCredentialsRequestDTO request = CreateCredentialsRequestDTO.builder().accountId("account").domain("main").addIdentifiers(UserIdentifierDTO.builder().build()).plainPassword("password").build();
    final Validator<CreateCredentialsRequestDTO> validator = Validators.getForClass(CreateCredentialsRequestDTO.class);
    final List<Violation> violations = validator.validate(request);
    assertThat(violations).containsExactlyInAnyOrder(new Violation("type", ViolationType.MISSING_REQUIRED_VALUE), new Violation("identifier", ViolationType.MISSING_REQUIRED_VALUE));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) CreateCredentialsRequestDTO(com.nexblocks.authguard.api.dto.requests.CreateCredentialsRequestDTO) Test(org.junit.jupiter.api.Test)

Aggregations

Violation (com.nexblocks.authguard.api.dto.validation.violations.Violation)44 Test (org.junit.jupiter.api.Test)40 CreateAccountRequestDTO (com.nexblocks.authguard.api.dto.requests.CreateAccountRequestDTO)6 PasswordResetRequestDTO (com.nexblocks.authguard.api.dto.requests.PasswordResetRequestDTO)5 UpdateAccountRequestDTO (com.nexblocks.authguard.api.dto.requests.UpdateAccountRequestDTO)5 AuthRequestDTO (com.nexblocks.authguard.api.dto.requests.AuthRequestDTO)4 RequestValidationError (com.nexblocks.authguard.api.dto.entities.RequestValidationError)3 CreateCredentialsRequestDTO (com.nexblocks.authguard.api.dto.requests.CreateCredentialsRequestDTO)3 PermissionsRequestDTO (com.nexblocks.authguard.api.dto.requests.PermissionsRequestDTO)3 AccountEmailsRequestDTO (com.nexblocks.authguard.api.dto.requests.AccountEmailsRequestDTO)2 CreateAppRequestDTO (com.nexblocks.authguard.api.dto.requests.CreateAppRequestDTO)2 CreatePermissionRequestDTO (com.nexblocks.authguard.api.dto.requests.CreatePermissionRequestDTO)2 CreateRoleRequestDTO (com.nexblocks.authguard.api.dto.requests.CreateRoleRequestDTO)2 OtpRequestDTO (com.nexblocks.authguard.api.dto.requests.OtpRequestDTO)2 PasswordlessRequestDTO (com.nexblocks.authguard.api.dto.requests.PasswordlessRequestDTO)2 RolesRequestDTO (com.nexblocks.authguard.api.dto.requests.RolesRequestDTO)2 UserIdentifiersRequestDTO (com.nexblocks.authguard.api.dto.requests.UserIdentifiersRequestDTO)1 RequestValidationException (com.nexblocks.authguard.rest.exceptions.RequestValidationException)1