@Test public void illegal_api_is_rejected() throws Exception { when(target.getApiVersion()).thenReturn("illegal"); when(apiValidation.validate(eq("illegal"))).thenReturn(failedResult); validatorToTest.validate(target, errors); verify(errors).rejectValue(eq(SecHubConfiguration.PROPERTY_API_VERSION),eq("api.error.unsupported.version"),any()); }
@Override public void validate(Object target, Errors errors) { LOG.debug("Start validation for: {}", target); SecHubConfiguration configuration = (SecHubConfiguration) target; validateAPI(configuration, errors); validateAtLeastOneScanConfiguration(configuration, errors); validateWebScan(configuration, errors); validateInfraScan(configuration, errors); if (errors.hasErrors()) { List<ObjectError> objectErrors = errors.getAllErrors(); for (ObjectError error : objectErrors) { LOG.info("Rejected sechub configuration from user:{}. Reason: {}", userContextService.getUserId(), error.getDefaultMessage()); } } }
SecHubConfigurationValidator implements Validator { @Override public void validate(Object target, Errors errors) { LOG.debug("Start validation for: {}", target); SecHubConfiguration configuration = (SecHubConfiguration) target; validateAPI(configuration, errors); validateAtLeastOneScanConfiguration(configuration, errors); validateWebScan(configuration, errors); validateInfraScan(configuration, errors); if (errors.hasErrors()) { List<ObjectError> objectErrors = errors.getAllErrors(); for (ObjectError error : objectErrors) { LOG.info("Rejected sechub configuration from user:{}. Reason: {}", userContextService.getUserId(), error.getDefaultMessage()); } } } }
SecHubConfigurationValidator implements Validator { @Override public void validate(Object target, Errors errors) { LOG.debug("Start validation for: {}", target); SecHubConfiguration configuration = (SecHubConfiguration) target; validateAPI(configuration, errors); validateAtLeastOneScanConfiguration(configuration, errors); validateWebScan(configuration, errors); validateInfraScan(configuration, errors); if (errors.hasErrors()) { List<ObjectError> objectErrors = errors.getAllErrors(); for (ObjectError error : objectErrors) { LOG.info("Rejected sechub configuration from user:{}. Reason: {}", userContextService.getUserId(), error.getDefaultMessage()); } } }  }
SecHubConfigurationValidator implements Validator { @Override public void validate(Object target, Errors errors) { LOG.debug("Start validation for: {}", target); SecHubConfiguration configuration = (SecHubConfiguration) target; validateAPI(configuration, errors); validateAtLeastOneScanConfiguration(configuration, errors); validateWebScan(configuration, errors); validateInfraScan(configuration, errors); if (errors.hasErrors()) { List<ObjectError> objectErrors = errors.getAllErrors(); for (ObjectError error : objectErrors) { LOG.info("Rejected sechub configuration from user:{}. Reason: {}", userContextService.getUserId(), error.getDefaultMessage()); } } }  @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }
SecHubConfigurationValidator implements Validator { @Override public void validate(Object target, Errors errors) { LOG.debug("Start validation for: {}", target); SecHubConfiguration configuration = (SecHubConfiguration) target; validateAPI(configuration, errors); validateAtLeastOneScanConfiguration(configuration, errors); validateWebScan(configuration, errors); validateInfraScan(configuration, errors); if (errors.hasErrors()) { List<ObjectError> objectErrors = errors.getAllErrors(); for (ObjectError error : objectErrors) { LOG.info("Rejected sechub configuration from user:{}. Reason: {}", userContextService.getUserId(), error.getDefaultMessage()); } } }  @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors);  }