use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionValidatorTest method fieldNameTooShortTest.
@Test
void fieldNameTooShortTest() {
SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtility, systemMessageAccessor);
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel("too", Boolean.FALSE, "short", Boolean.FALSE, false);
ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(2, validationResponseModel.getErrors().size());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionValidatorTest method validateNotInitializedTest.
@Test
void validateNotInitializedTest() {
MockAlertProperties alertPropertiesNoEncryption = new MockAlertProperties();
alertPropertiesNoEncryption.setEncryptionPassword("");
alertPropertiesNoEncryption.setEncryptionSalt("");
FilePersistenceUtil filePersistenceUtilWithoutProperties = new FilePersistenceUtil(alertPropertiesNoEncryption, gson);
EncryptionUtility encryptionUtilityWithoutProperties = new EncryptionUtility(alertPropertiesNoEncryption, filePersistenceUtilWithoutProperties);
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel("password", Boolean.FALSE, "globalSalt", Boolean.FALSE, false);
SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.api.common.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.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validatePortWithoutHostTest.
@Test
void validatePortWithoutHostTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel(ID, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, CREATED_AT, LAST_UPDATED, null, PORT, USERNAME, PASSWORD, Boolean.TRUE, NON_PROXY_HOSTS);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(1, validationResponseModel.getErrors().size());
assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_HOST_FIELD_NAME));
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validateUsernameBlank.
@Test
void validateUsernameBlank() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel(ID, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, CREATED_AT, LAST_UPDATED, HOST, PORT, "", PASSWORD, Boolean.TRUE, NON_PROXY_HOSTS);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertFalse(validationResponseModel.hasErrors());
}
Aggregations