Search in sources :

Example 36 with SettingsProxyModel

use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.

the class SettingsProxyValidatorTest method validatePasswordWithoutUsernameTest.

@Test
void validatePasswordWithoutUsernameTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyHost(HOST);
    settingsProxyModel.setProxyPort(PORT);
    settingsProxyModel.setProxyPassword(PASSWORD);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
    assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_USERNAME_FIELD_NAME));
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Example 37 with SettingsProxyModel

use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.

the class SettingsProxyValidatorTest method validateNameMissingTest.

@Test
void validateNameMissingTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setProxyHost(HOST);
    settingsProxyModel.setProxyPort(PORT);
    settingsProxyModel.setProxyUsername(USERNAME);
    settingsProxyModel.setProxyPassword(PASSWORD);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
    assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_CONFIGURATION_NAME));
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Example 38 with SettingsProxyModel

use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.

the class SettingsProxyValidatorTest method validateTest.

@Test
void validateTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyHost(HOST);
    settingsProxyModel.setProxyPort(PORT);
    settingsProxyModel.setProxyUsername(USERNAME);
    settingsProxyModel.setProxyPassword(PASSWORD);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertFalse(validationResponseModel.hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Example 39 with SettingsProxyModel

use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.

the class SettingsProxyValidatorTest method validateUsernameWithoutPasswordIsProxyPasswordSetTest.

@Test
void validateUsernameWithoutPasswordIsProxyPasswordSetTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyHost(HOST);
    settingsProxyModel.setProxyPort(PORT);
    settingsProxyModel.setProxyUsername(USERNAME);
    settingsProxyModel.setIsProxyPasswordSet(true);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertFalse(validationResponseModel.hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Example 40 with SettingsProxyModel

use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.

the class SettingsProxyValidatorTest method validateIsPasswordSetWithoutUsernameTest.

@Test
void validateIsPasswordSetWithoutUsernameTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyHost(HOST);
    settingsProxyModel.setProxyPort(PORT);
    settingsProxyModel.setIsProxyPasswordSet(true);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
    assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_USERNAME_FIELD_NAME));
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) 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