Search in sources :

Example 31 with ValidationResponseModel

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

the class SettingsEncryptionValidatorTest method validateNotInitializedTest.

@Test
public 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();
    settingsEncryptionModel.setEncryptionPassword("password");
    settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertFalse(validationResponseModel.hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.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 32 with ValidationResponseModel

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

the class SettingsEncryptionValidatorTest method fieldNameTooShortTest.

@Test
public void fieldNameTooShortTest() {
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtility, systemMessageAccessor);
    SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
    settingsEncryptionModel.setEncryptionPassword("too");
    settingsEncryptionModel.setEncryptionGlobalSalt("short");
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(2, validationResponseModel.getErrors().size());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) Test(org.junit.jupiter.api.Test)

Example 33 with ValidationResponseModel

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

the class SettingsProxyValidatorTest method validateHostWithoutPortTest.

@Test
void validateHostWithoutPortTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyHost(HOST);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
    assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_PORT_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 34 with ValidationResponseModel

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

the class SettingsProxyValidatorTest method validatePortWithoutHostTest.

@Test
void validatePortWithoutHostTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyPort(PORT);
    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.common.rest.model.ValidationResponseModel) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) Test(org.junit.jupiter.api.Test)

Example 35 with ValidationResponseModel

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

the class SettingsProxyValidatorTest method validateUsernameWithoutPasswordTest.

@Test
void validateUsernameWithoutPasswordTest() {
    SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
    settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
    settingsProxyModel.setProxyHost(HOST);
    settingsProxyModel.setProxyPort(PORT);
    settingsProxyModel.setProxyUsername(USERNAME);
    ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
    assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_PASSWORD_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

ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)84 Test (org.junit.jupiter.api.Test)66 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)33 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)25 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)23 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)18 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)15 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)13 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)9 SettingsProxyTestAction (com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction)9 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)7 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)7 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)7 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)7 AlertFieldException (com.synopsys.integration.alert.common.exception.AlertFieldException)7 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)7 IntegrationException (com.synopsys.integration.exception.IntegrationException)7 IntegrationRestException (com.synopsys.integration.rest.exception.IntegrationRestException)7 Map (java.util.Map)7 FieldModelTestAction (com.synopsys.integration.alert.common.action.FieldModelTestAction)6