use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsProxyTestActionTest method testWithPermissionCheckTest.
@Test
void testWithPermissionCheckTest() {
ConfigurationTestResult configurationTestResult = ConfigurationTestResult.success();
ProxyTestService proxyTestService = Mockito.mock(ProxyTestService.class);
Mockito.when(proxyTestService.pingHost(Mockito.eq(TEST_URL), Mockito.any())).thenReturn(configurationTestResult);
SettingsProxyTestAction settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
ActionResponse<ValidationResponseModel> actionResponse = settingsProxyTestAction.testWithPermissionCheck(TEST_URL, defaultSettingsProxyModel);
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
Optional<ValidationResponseModel> validationResponseModel = actionResponse.getContent();
assertTrue(validationResponseModel.isPresent());
assertFalse(validationResponseModel.get().hasErrors());
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class RoleActions method validateWithoutChecks.
@Override
protected ValidationActionResponse validateWithoutChecks(RolePermissionModel resource) {
ValidationResponseModel responseModel;
List<AlertFieldStatus> alertFieldStatus = fullyValidateRoleNameField(resource);
if (alertFieldStatus.isEmpty()) {
responseModel = ValidationResponseModel.success("The role name is valid");
return new ValidationActionResponse(HttpStatus.OK, responseModel);
}
responseModel = ValidationResponseModel.fromStatusCollection("There were problems with the role configuration", alertFieldStatus);
return new ValidationActionResponse(HttpStatus.BAD_REQUEST, responseModel);
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationValidatorTest method verifyEmptyConfig.
@Test
void verifyEmptyConfig() {
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigModel model = new EmailGlobalConfigModel();
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(3, alertFieldStatuses.size(), "Validation found more or fewer errors than expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals(ConfigurationFieldValidator.REQUIRED_FIELD_MISSING_MESSAGE, status.getFieldMessage(), "Validation had unexpected field message.");
}
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationValidatorTest method verifyAuthNotProvided.
@Test
void verifyAuthNotProvided() {
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigModel model = new EmailGlobalConfigModel();
model.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
model.setSmtpHost("host");
model.setSmtpFrom("from");
model.setSmtpUsername("user");
model.setSmtpPassword("password");
ValidationResponseModel validationResponseModel = validator.validate(model);
assertFalse(validationResponseModel.hasErrors(), "There were errors in the configuration when none were expected.");
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationValidatorTest method verifyMissingAuth.
@Test
void verifyMissingAuth() {
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigModel model = new EmailGlobalConfigModel();
model.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
model.setSmtpHost("host");
model.setSmtpFrom("from");
model.setSmtpAuth(true);
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(2, alertFieldStatuses.size(), "Validation found more or fewer errors than expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals(EmailGlobalConfigurationValidator.REQUIRED_BECAUSE_AUTH, status.getFieldMessage(), "Validation had unexpected field message.");
}
}
Aggregations