use of com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult in project sechub by mercedes-benz.
the class ProjectUpdateWhitelistServiceTest method before.
@Before
public void before() throws Exception {
serviceToTest = new ProjectUpdateWhitelistService();
repository = mock(ProjectRepository.class);
eventBus = mock(DomainMessageService.class);
uriValidation = mock(URIValidation.class);
serviceToTest.repository = repository;
serviceToTest.auditLog = mock(AuditLogService.class);
serviceToTest.assertion = mock(UserInputAssertion.class);
serviceToTest.eventBus = eventBus;
serviceToTest.uriValidation = uriValidation;
serviceToTest.logSanitizer = mock(LogSanitizer.class);
project = mock(Project.class);
whitelist = new LinkedHashSet<>();
whitelist.add(new URI("127.0.0.1"));
when(project.getWhiteList()).thenReturn(whitelist);
when(uriValidation.validate(any())).thenReturn(new ValidationResult());
}
use of com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult in project sechub by mercedes-benz.
the class ProjectJsonInputValidation method checkApiVersion.
public void checkApiVersion(Errors errors, ProjectJsonInput input) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, ProjectJsonInput.PROPERTY_API_VERSION, "field.required");
String apiVersion = input.getApiVersion();
if (apiVersion == null) {
return;
/* handled before */
}
ValidationResult apiValidationResult = apiVersionValidation.validate(apiVersion);
if (!apiValidationResult.isValid()) {
errors.rejectValue(ProjectJsonInput.PROPERTY_API_VERSION, "api.error.unsupported.version", apiValidationResult.getErrorDescription());
}
}
use of com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult in project sechub by mercedes-benz.
the class SignupJsonInputValidator method validate.
@Override
public void validate(Object target, Errors errors) {
SignupJsonInput selfRegistration = (SignupJsonInput) target;
LOG.debug("Start validation for self registration of: {}", selfRegistration.getUserId());
ValidationUtils.rejectIfEmptyOrWhitespace(errors, PROPERTY_API_VERSION, "field.required");
ValidationResult apiVersionValidationResult = apiVersionValidation.validate(selfRegistration.getApiVersion());
if (!apiVersionValidationResult.isValid()) {
errors.rejectValue(PROPERTY_API_VERSION, "api.error.unsupported.version", apiVersionValidationResult.getErrorDescription());
return;
}
ValidationResult userIdValidationResult = useridValidation.validate(selfRegistration.getUserId());
if (!userIdValidationResult.isValid()) {
errors.rejectValue(PROPERTY_USER_ID, "api.error.registration.userid.invalid", userIdValidationResult.getErrorDescription());
return;
}
ValidationResult emailValidationResult = emailValidation.validate(selfRegistration.getEmailAdress());
if (!emailValidationResult.isValid()) {
errors.rejectValue(PROPERTY_EMAIL_ADRESS, "api.error.email.invalid", "Invalid email adress");
return;
}
LOG.debug("Selfregistration of {} was accepted", selfRegistration.getUserId());
}
use of com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult in project sechub by mercedes-benz.
the class ProductExecutionrProfileValidationImplTest method oneError.
private ValidationResult oneError(String message) {
ValidationResult validationResult = new ValidationResult();
validationResult.addError(message);
return validationResult;
}
use of com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult in project sechub by mercedes-benz.
the class ProductExecutionrProfileValidationImplTest method calls_subvalidators_with_values_and_missign_uuid_in_config_is_also_recognized_so_5_errors.
@Test
public void calls_subvalidators_with_values_and_missign_uuid_in_config_is_also_recognized_so_5_errors() {
/* prepare */
ProductExecutionProfile profile = new ProductExecutionProfile();
profile.id = "pid";
profile.description = "desc";
ProductExecutorConfig configuration = mock(ProductExecutorConfig.class);
profile.configurations.add(configuration);
profile.projectIds.add("1234");
profile.projectIds.add("54333");
/* execute */
ValidationResult result = validationToTest.validate(profile);
/* test */
verify(validationToTest.profileIdValidation, times(1)).validate("pid");
verify(validationToTest.descriptionValidation, times(1)).validate("desc");
verify(validationToTest.projectIdValidation).validate("1234");
verify(validationToTest.projectIdValidation).validate("54333");
/* fith error si because of missing uuid */
if (result.getErrors().size() != 5) {
fail("Expected 5 error, but got:" + result.getErrors());
}
}
Aggregations