Search in sources :

Example 11 with ValidationResponseModel

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.api.common.model.ValidationResponseModel) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) Test(org.junit.jupiter.api.Test)

Example 12 with ValidationResponseModel

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.api.common.model.ValidationResponseModel) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility) Test(org.junit.jupiter.api.Test)

Example 13 with ValidationResponseModel

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.api.common.model.ValidationResponseModel) SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) ProxyTestService(com.synopsys.integration.alert.common.rest.proxy.ProxyTestService) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 14 with ValidationResponseModel

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

Example 15 with ValidationResponseModel

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

Aggregations

ValidationResponseModel (com.synopsys.integration.alert.api.common.model.ValidationResponseModel)179 Test (org.junit.jupiter.api.Test)139 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)66 AlertFieldStatus (com.synopsys.integration.alert.api.common.model.errors.AlertFieldStatus)54 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)50 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)36 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)29 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)26 JiraServerGlobalConfigAccessor (com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor)20 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)18 SettingsProxyTestAction (com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction)18 IntegrationException (com.synopsys.integration.exception.IntegrationException)16 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)14 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)14 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)14 AlertFieldException (com.synopsys.integration.alert.common.exception.AlertFieldException)14 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)14 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)14 IntegrationRestException (com.synopsys.integration.rest.exception.IntegrationRestException)14 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)12