Search in sources :

Example 6 with SettingsProxyModel

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with SettingsProxyModel

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with SettingsProxyModel

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;
}
Also used : SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)

Example 9 with 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());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Example 10 with SettingsProxyModel

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());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Aggregations

SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)44 Test (org.junit.jupiter.api.Test)32 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)18 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)12 SettingsProxyTestAction (com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction)8 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)7 URI (java.net.URI)6 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)6 SettingsProxyCrudActions (com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyCrudActions)5 SettingsProxyConfigAccessor (com.synopsys.integration.alert.component.settings.proxy.database.accessor.SettingsProxyConfigAccessor)5 NonProxyHostsConfigurationRepository (com.synopsys.integration.alert.database.settings.proxy.NonProxyHostsConfigurationRepository)5 SettingsProxyConfigurationRepository (com.synopsys.integration.alert.database.settings.proxy.SettingsProxyConfigurationRepository)5 UUID (java.util.UUID)5 WithMockUser (org.springframework.security.test.context.support.WithMockUser)5 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)3 SettingsProxyConfigurationEntity (com.synopsys.integration.alert.database.settings.proxy.SettingsProxyConfigurationEntity)2 AssertionFailedError (org.opentest4j.AssertionFailedError)2 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)1 SettingsUtility (com.synopsys.integration.alert.common.descriptor.accessor.SettingsUtility)1 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)1