use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.
the class PasswordResetRequestValidatorTest method validateMissingIdentifierAndOldPassword.
@Test
void validateMissingIdentifierAndOldPassword() {
final PasswordResetRequestDTO request = PasswordResetRequestDTO.builder().byToken(false).build();
final Validator<PasswordResetRequestDTO> validator = Validators.getForClass(PasswordResetRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).contains(new Violation("identifier", ViolationType.MISSING_REQUIRED_VALUE));
assertThat(violations).contains(new Violation("oldPassword", ViolationType.MISSING_REQUIRED_VALUE));
assertThat(violations).contains(new Violation("newPassword", ViolationType.MISSING_REQUIRED_VALUE));
}
use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.
the class PermissionsRequestValidatorTest method validateValid.
@Test
void validateValid() {
final PermissionsRequestDTO request = PermissionsRequestDTO.builder().action(PermissionsRequest.Action.GRANT).addPermissions(PermissionDTO.builder().group("group").name("*").build()).build();
final Validator<PermissionsRequestDTO> validator = Validators.getForClass(PermissionsRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.
the class PermissionsRequestValidatorTest method validateInvalidPermission.
@Test
void validateInvalidPermission() {
final PermissionsRequestDTO request = PermissionsRequestDTO.builder().action(PermissionsRequest.Action.GRANT).addPermissions(PermissionDTO.builder().build()).build();
final Validator<PermissionsRequestDTO> validator = Validators.getForClass(PermissionsRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).containsExactlyInAnyOrder(new Violation("group", ViolationType.MISSING_REQUIRED_VALUE), new Violation("name", ViolationType.MISSING_REQUIRED_VALUE));
}
use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.
the class RolesRequestValidatorTest method validateValid.
@Test
void validateValid() {
final RolesRequestDTO request = RolesRequestDTO.builder().action(RolesRequest.Action.GRANT).addRoles("test").build();
final Validator<RolesRequestDTO> validator = Validators.getForClass(RolesRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
use of com.nexblocks.authguard.api.dto.validation.violations.Violation in project AuthGuard by AuthGuard.
the class UpdateAccountRequestValidatorTest method validateValidBackupEmail.
@Test
void validateValidBackupEmail() {
final UpdateAccountRequestDTO request = UpdateAccountRequestDTO.builder().backupEmail(AccountEmailDTO.builder().email("valid@valid.com").build()).build();
final Validator<UpdateAccountRequestDTO> validator = Validators.getForClass(UpdateAccountRequestDTO.class);
final List<Violation> violations = validator.validate(request);
assertThat(violations).isEmpty();
}
Aggregations