Search in sources :

Example 21 with Violation

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

the class OAuthRoute method getAuthUrl.

void getAuthUrl(final Context context) {
    final String provider = context.queryParam("provider");
    if (provider == null) {
        context.status(400).json(new RequestValidationError(Collections.singletonList(new Violation("provider", ViolationType.MISSING_REQUIRED_VALUE))));
    } else {
        final String url = oAuthService.getAuthorizationUrl(provider).join();
        context.redirect(url);
    }
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) RequestValidationError(com.nexblocks.authguard.api.dto.entities.RequestValidationError)

Example 22 with Violation

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

the class AccountEmailsRequestValidatorTest method validateValid.

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

Example 23 with Violation

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

the class AuthRequestValidatorTest method validateWithIdentifierAndDomain.

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

Example 24 with Violation

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

the class AuthRequestValidatorTest method validateNoViolations.

@Test
void validateNoViolations() {
    final AuthRequestDTO valid = AuthRequestDTO.builder().restrictions(TokenRestrictionsDTO.builder().addScopes("scope").addPermissions("permission").build()).build();
    final Validator<AuthRequestDTO> validator = Validators.getForClass(AuthRequestDTO.class);
    final List<Violation> violations = validator.validate(valid);
    assertThat(violations).isEmpty();
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) AuthRequestDTO(com.nexblocks.authguard.api.dto.requests.AuthRequestDTO) Test(org.junit.jupiter.api.Test)

Example 25 with Violation

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

the class AuthRequestValidatorTest method validateWithIdentifierButNoDomain.

@Test
void validateWithIdentifierButNoDomain() {
    final AuthRequestDTO valid = AuthRequestDTO.builder().identifier("identifier").build();
    final Validator<AuthRequestDTO> validator = Validators.getForClass(AuthRequestDTO.class);
    final List<Violation> violations = validator.validate(valid);
    assertThat(violations).containsExactly(new Violation("domain", ViolationType.MISSING_REQUIRED_VALUE));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) AuthRequestDTO(com.nexblocks.authguard.api.dto.requests.AuthRequestDTO) 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