Search in sources :

Example 6 with TestProperties

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

the class EmailGlobalTestActionTest method testSmtpPasswordMissingTestIT.

@Test
@Tags(value = { @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void testSmtpPasswordMissingTestIT() {
    AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
    EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
    TestProperties testProperties = new TestProperties();
    String emailAddress = testProperties.getProperty(TestPropertyKey.TEST_EMAIL_RECIPIENT);
    assumeTrue(testProperties.getOptionalProperty(TestPropertyKey.TEST_EMAIL_SMTP_PASSWORD).isPresent());
    JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
    EmailChannelMessagingService validEmailChannelMessagingService = createValidEmailChannelMessagingService(emailAddress);
    EmailGlobalTestAction emailGlobalTestAction = new EmailGlobalTestAction(authorizationManager, validator, validEmailChannelMessagingService, javamailPropertiesFactory, configurationAccessor);
    EmailGlobalConfigModel globalConfigModelWithoutPassword = createEmailGlobalConfigModelObfuscated(testProperties);
    EmailGlobalConfigModel globalConfigModelWithPassword = createValidEmailGlobalConfigModel(testProperties);
    Mockito.when(configurationAccessor.getConfiguration()).thenReturn(Optional.of(globalConfigModelWithPassword));
    ConfigurationTestResult testResult = emailGlobalTestAction.testConfigModelContent(emailAddress, globalConfigModelWithoutPassword);
    assertTrue(testResult.isSuccess(), "Expected the message result to not have errors");
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) EmailGlobalConfigModel(com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel) EmailGlobalConfigurationValidator(com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test) TestTags(com.synopsys.integration.alert.test.common.TestTags) Tags(org.junit.jupiter.api.Tags)

Example 7 with TestProperties

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

the class EmailChannelTestIT method init.

@BeforeEach
public void init() {
    gson = new Gson();
    testProperties = new TestProperties();
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) Gson(com.google.gson.Gson) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with TestProperties

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

the class EmailGlobalFieldModelTestActionTest method testConfigITTest.

@Test
@Tags(value = { @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void testConfigITTest() {
    TestProperties testProperties = new TestProperties();
    String emailAddress = testProperties.getProperty(TestPropertyKey.TEST_EMAIL_RECIPIENT);
    FieldModel validFieldModel = createFieldModelToTest(emailAddress);
    JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
    EmailChannelMessagingService validEmailChannelMessagingService = createValidEmailChannelMessagingService(emailAddress);
    EmailGlobalFieldModelTestAction emailGlobalFieldModelTestAction = new EmailGlobalFieldModelTestAction(validEmailChannelMessagingService, javamailPropertiesFactory);
    FieldUtility validFieldUtility = createValidEmailGlobalFieldUtility(testProperties);
    try {
        MessageResult messageResult = emailGlobalFieldModelTestAction.testConfig("0", validFieldModel, validFieldUtility);
        assertFalse(messageResult.hasErrors(), "Expected the message result to not have errors");
        assertFalse(messageResult.hasWarnings(), "Expected the message result to not have warnings");
    } catch (AlertException e) {
        fail("An exception was thrown where none was expected", e);
    }
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test) TestTags(com.synopsys.integration.alert.test.common.TestTags) Tags(org.junit.jupiter.api.Tags)

Example 9 with TestProperties

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

the class ScalingPerformanceTest method initTest.

@BeforeAll
public static void initTest() {
    TestProperties testProperties = new TestProperties();
    SLACK_CHANNEL_WEBHOOK = testProperties.getProperty(TestPropertyKey.TEST_SLACK_WEBHOOK);
    SLACK_CHANNEL_NAME = testProperties.getProperty(TestPropertyKey.TEST_SLACK_CHANNEL_NAME);
    SLACK_CHANNEL_USERNAME = testProperties.getProperty(TestPropertyKey.TEST_SLACK_USERNAME);
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 10 with TestProperties

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

the class JmsNotificationReceiverTestIT method init.

@BeforeEach
public void init() {
    properties = new TestProperties();
    ConfigurationFieldModel providerConfigEnabled = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED);
    providerConfigEnabled.setFieldValue("TRUE");
    ConfigurationFieldModel providerConfigName = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
    providerConfigName.setFieldValue("blackduck-config");
    ConfigurationFieldModel blackduckUrl = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
    blackduckUrl.setFieldValue("https://www.synopsys.com");
    ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
    blackduckApiKey.setFieldValue("someApiKey");
    ConfigurationFieldModel blackduckTimeout = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
    blackduckTimeout.setFieldValue(String.valueOf(BlackDuckProperties.DEFAULT_TIMEOUT));
    ConfigurationModel blackduckConfigurationModel = defaultConfigurationAccessor.createConfiguration(blackDuckProviderKey, ConfigContextEnum.GLOBAL, List.of(providerConfigEnabled, providerConfigName, blackduckUrl, blackduckApiKey, blackduckTimeout));
    blackDuckGlobalConfigId = blackduckConfigurationModel.getConfigurationId();
    List<AlertNotificationModel> notificationContent = new ArrayList<>();
    for (Long i = 1L; i <= 1000; i++) {
        notificationContent.add(createAlertNotificationModel(i, false));
    }
    savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
    SlackJobDetailsModel slackJobDetailsModel = createSlackJobDetailsModel();
    DistributionJobRequestModel distributionJobRequestModel = createDistributionJobRequestModel("jobName1", slackJobDetailsModel);
    distributionJobModel = staticJobAccessor.createJob(distributionJobRequestModel);
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) SlackJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel) ArrayList(java.util.ArrayList) DistributionJobRequestModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

TestProperties (com.synopsys.integration.alert.test.common.TestProperties)24 Test (org.junit.jupiter.api.Test)10 Gson (com.google.gson.Gson)6 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)5 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)4 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)4 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)4 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)4 TestTags (com.synopsys.integration.alert.test.common.TestTags)4 Tags (org.junit.jupiter.api.Tags)4 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)3 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)3 GsonBuilder (com.google.gson.GsonBuilder)2 IssueTrackerCallbackInfoCreator (com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator)2 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)2 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)2 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)2