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);
}
}
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();
}
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();
}
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();
}
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));
}
Aggregations