Search in sources :

Example 16 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class MsTeamsChannelTest method createConnectionFactory.

private ChannelRestConnectionFactory createConnectionFactory() {
    MockAlertProperties testAlertProperties = new MockAlertProperties();
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
    return new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Example 17 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class BlackDuckSSOConfigRetrieverTest method createBlackDuckProperties.

private BlackDuckProperties createBlackDuckProperties() {
    TestProperties testProperties = new TestProperties();
    String blackDuckUrl = testProperties.getBlackDuckURL();
    String blackDuckApiKey = testProperties.getBlackDuckAPIToken();
    String blackDuckTimeout = testProperties.getOptionalProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_TIMEOUT).orElse("300");
    MockAlertProperties mockAlertProperties = new MockAlertProperties();
    ProxyManager mockProxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(mockProxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
    ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(0L, 0L, null, null, ConfigContextEnum.GLOBAL);
    configurationModel.put(createConfigFieldModel(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED, Boolean.TRUE.toString()));
    configurationModel.put(createConfigFieldModel(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME, BlackDuckSSOConfigRetrieverTest.class.getSimpleName()));
    configurationModel.put(createConfigFieldModel(BlackDuckDescriptor.KEY_BLACKDUCK_URL, blackDuckUrl));
    configurationModel.put(createConfigFieldModel(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY, blackDuckApiKey));
    configurationModel.put(createConfigFieldModel(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT, blackDuckTimeout));
    return new BlackDuckProperties(0L, new Gson(), BlackDuckServicesFactory.createDefaultObjectMapper(), mockAlertProperties, mockProxyManager, configurationModel);
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) ConfigurationModelMutable(com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable) BlackDuckProperties(com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) Gson(com.google.gson.Gson)

Example 18 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class SettingsEncryptionValidatorTest method validateNotInitializedNoPasswordTest.

@Test
public void validateNotInitializedNoPasswordTest() {
    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.setEncryptionGlobalSalt("globalSalt");
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
}
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 19 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class SettingsEncryptionValidatorTest method validateNotInitializedNoGlobalSaltTest.

@Test
public void validateNotInitializedNoGlobalSaltTest() {
    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");
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
}
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)

Aggregations

MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)19 Test (org.junit.jupiter.api.Test)10 Gson (com.google.gson.Gson)9 EmailAttachmentFileCreator (com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFileCreator)7 MessageContentGroupCsvCreator (com.synopsys.integration.alert.channel.email.attachment.MessageContentGroupCsvCreator)7 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)7 EmailMessagingService (com.synopsys.integration.alert.service.email.EmailMessagingService)7 JobEmailAddressValidator (com.synopsys.integration.alert.channel.email.distribution.address.JobEmailAddressValidator)6 ValidatedEmailAddresses (com.synopsys.integration.alert.channel.email.distribution.address.ValidatedEmailAddresses)6 FreemarkerTemplatingService (com.synopsys.integration.alert.service.email.template.FreemarkerTemplatingService)6 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)5 FilePersistenceUtil (com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil)5 EmailAddressGatherer (com.synopsys.integration.alert.channel.email.distribution.address.EmailAddressGatherer)4 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)4 EncryptionUtility (com.synopsys.integration.alert.common.security.EncryptionUtility)4 SettingsEncryptionModel (com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel)4 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)4 ChannelRestConnectionFactory (com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory)3 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)3 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)2