use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyTestActionTestIT method testUrlWithBadResponseTest.
@Test
void testUrlWithBadResponseTest() {
SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck("http://thisUrlWillReturnFailures", settingsProxyModel);
assertTrue(testResult.isSuccessful());
assertTrue(testResult.getContent().isPresent());
ValidationResponseModel validationResponseModel = testResult.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyTestActionTestIT method malformedTargetUrlTest.
@Test
void malformedTargetUrlTest() {
SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck("Not a valid url", settingsProxyModel);
assertTrue(testResult.isSuccessful());
assertTrue(testResult.getContent().isPresent());
ValidationResponseModel validationResponseModel = testResult.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyTestActionTestIT method createSettingsProxyModel.
private SettingsProxyModel createSettingsProxyModel(TestProperties testProperties) {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
settingsProxyModel.setProxyHost(testProperties.getProperty(TestPropertyKey.TEST_PROXY_HOST));
settingsProxyModel.setProxyPort(Integer.valueOf(testProperties.getProperty(TestPropertyKey.TEST_PROXY_PORT)));
testProperties.getOptionalProperty(TestPropertyKey.TEST_PROXY_USERNAME).ifPresent(settingsProxyModel::setProxyUsername);
testProperties.getOptionalProperty(TestPropertyKey.TEST_PROXY_PASSWORD).ifPresent(settingsProxyModel::setProxyPassword);
return settingsProxyModel;
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class ProxyConfigurationModelConverterTest method invalidPortTest.
@Test
void invalidPortTest() {
ConfigurationModel configurationModel = createDefaultConfigurationModel();
configurationModel.getField(ProxyConfigurationModelConverter.FIELD_KEY_PORT).ifPresent(field -> field.setFieldValue("twenty-five"));
ProxyConfigurationModelConverter converter = new ProxyConfigurationModelConverter();
Optional<SettingsProxyModel> model = converter.convert(configurationModel);
assertTrue(model.isEmpty());
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class ProxyConfigurationModelConverterTest method emptyFieldsTest.
@Test
void emptyFieldsTest() {
ConfigurationModel emptyModel = new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, Map.of());
ProxyConfigurationModelConverter converter = new ProxyConfigurationModelConverter();
Optional<SettingsProxyModel> model = converter.convert(emptyModel);
assertTrue(model.isPresent());
SettingsProxyModel proxyModel = model.get();
assertTrue(proxyModel.getProxyUsername().isEmpty());
assertTrue(proxyModel.getProxyPassword().isEmpty());
assertTrue(proxyModel.getProxyHost().isEmpty());
assertTrue(proxyModel.getProxyPort().isEmpty());
assertTrue(proxyModel.getNonProxyHosts().isEmpty());
}
Aggregations