Search in sources :

Example 1 with ConfigurationTestResult

use of com.synopsys.integration.alert.common.message.model.ConfigurationTestResult in project hub-alert by blackducksoftware.

the class JiraServerGlobalTestActionTest method testAppMissing.

@Test
void testAppMissing() throws IntegrationException {
    AuthorizationManager authorizationManager = createAuthorizationManager(255);
    JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
    JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
    JiraServerGlobalTestActionWrapper testActionWrapper = Mockito.mock(JiraServerGlobalTestActionWrapper.class);
    Mockito.when(jiraServerTestActionFactory.createTestActionWrapper(Mockito.any())).thenReturn(testActionWrapper);
    Mockito.when(testActionWrapper.canUserGetIssues()).thenReturn(true);
    Mockito.when(testActionWrapper.isAppCheckEnabled()).thenReturn(true);
    Mockito.when(testActionWrapper.isUserAdmin()).thenReturn(true);
    Mockito.when(testActionWrapper.isAppMissing()).thenReturn(true);
    JiraServerGlobalTestAction jiraServerGlobalTestAction = new JiraServerGlobalTestAction(authorizationManager, validator, jiraServerTestActionFactory);
    ConfigurationTestResult testResult = jiraServerGlobalTestAction.testConfigModelContent(jiraServerGlobalConfigModel);
    assertFalse(testResult.isSuccess());
}
Also used : JiraServerGlobalConfigurationValidator(com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigurationTestResult

use of com.synopsys.integration.alert.common.message.model.ConfigurationTestResult in project hub-alert by blackducksoftware.

the class JiraServerGlobalTestActionTest method testUserCannotGetIssues.

@Test
void testUserCannotGetIssues() throws IntegrationException {
    AuthorizationManager authorizationManager = createAuthorizationManager(255);
    JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
    JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
    JiraServerGlobalTestActionWrapper testActionWrapper = Mockito.mock(JiraServerGlobalTestActionWrapper.class);
    Mockito.when(jiraServerTestActionFactory.createTestActionWrapper(Mockito.any())).thenReturn(testActionWrapper);
    Mockito.when(testActionWrapper.canUserGetIssues()).thenReturn(false);
    JiraServerGlobalTestAction jiraServerGlobalTestAction = new JiraServerGlobalTestAction(authorizationManager, validator, jiraServerTestActionFactory);
    ConfigurationTestResult testResult = jiraServerGlobalTestAction.testConfigModelContent(jiraServerGlobalConfigModel);
    assertFalse(testResult.isSuccess());
}
Also used : JiraServerGlobalConfigurationValidator(com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurationTestResult

use of com.synopsys.integration.alert.common.message.model.ConfigurationTestResult in project hub-alert by blackducksoftware.

the class JiraServerGlobalTestActionTest method testConfigValidTest.

@Test
void testConfigValidTest() throws IntegrationException {
    AuthorizationManager authorizationManager = createAuthorizationManager(255);
    JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
    JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
    JiraServerGlobalTestActionWrapper testActionWrapper = Mockito.mock(JiraServerGlobalTestActionWrapper.class);
    Mockito.when(jiraServerTestActionFactory.createTestActionWrapper(Mockito.any())).thenReturn(testActionWrapper);
    Mockito.when(testActionWrapper.canUserGetIssues()).thenReturn(true);
    Mockito.when(testActionWrapper.isAppCheckEnabled()).thenReturn(true);
    Mockito.when(testActionWrapper.isUserAdmin()).thenReturn(true);
    Mockito.when(testActionWrapper.isAppMissing()).thenReturn(false);
    JiraServerGlobalTestAction jiraServerGlobalTestAction = new JiraServerGlobalTestAction(authorizationManager, validator, jiraServerTestActionFactory);
    ConfigurationTestResult testResult = jiraServerGlobalTestAction.testConfigModelContent(jiraServerGlobalConfigModel);
    assertTrue(testResult.isSuccess());
}
Also used : JiraServerGlobalConfigurationValidator(com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurationTestResult

use of com.synopsys.integration.alert.common.message.model.ConfigurationTestResult 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 5 with ConfigurationTestResult

use of com.synopsys.integration.alert.common.message.model.ConfigurationTestResult in project hub-alert by blackducksoftware.

the class EmailGlobalTestActionTest method testSmtpPasswordMissingTest.

@Test
public void testSmtpPasswordMissingTest() throws AlertException {
    AuthorizationManager authorizationManager = createAuthorizationManager(255);
    EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
    EmailChannelMessagingService emailChannelMessagingService = Mockito.mock(EmailChannelMessagingService.class);
    Mockito.when(emailChannelMessagingService.sendMessage(Mockito.any(), Mockito.any())).thenReturn(new MessageResult("PASS"));
    JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
    EmailGlobalTestAction emailGlobalTestAction = new EmailGlobalTestAction(authorizationManager, validator, emailChannelMessagingService, javamailPropertiesFactory, configurationAccessor);
    EmailGlobalConfigModel emailGlobalConfigModel = new EmailGlobalConfigModel();
    emailGlobalConfigModel.setIsSmtpPasswordSet(true);
    EmailGlobalConfigModel configModelWithPassword = new EmailGlobalConfigModel();
    configModelWithPassword.setIsSmtpPasswordSet(true);
    configModelWithPassword.setSmtpPassword("password");
    Mockito.when(configurationAccessor.getConfiguration()).thenReturn(Optional.of(configModelWithPassword));
    ConfigurationTestResult testResult = emailGlobalTestAction.testConfigModelContent("noreply@synopsys.com", emailGlobalConfigModel);
    assertTrue(testResult.isSuccess(), "Expected the message result to not have errors");
}
Also used : 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) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)18 Test (org.junit.jupiter.api.Test)17 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)12 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)6 JiraServerGlobalConfigurationValidator (com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator)6 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)6 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)5 ProxyTestService (com.synopsys.integration.alert.common.rest.proxy.ProxyTestService)5 SettingsProxyTestAction (com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction)5 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)5 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)3 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)2 TestProperties (com.synopsys.integration.alert.test.common.TestProperties)2 TestTags (com.synopsys.integration.alert.test.common.TestTags)2 Tags (org.junit.jupiter.api.Tags)2 Gson (com.google.gson.Gson)1 EmailAttachmentFileCreator (com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFileCreator)1 MessageContentGroupCsvCreator (com.synopsys.integration.alert.channel.email.attachment.MessageContentGroupCsvCreator)1 EmailAddressGatherer (com.synopsys.integration.alert.channel.email.distribution.address.EmailAddressGatherer)1 JobEmailAddressValidator (com.synopsys.integration.alert.channel.email.distribution.address.JobEmailAddressValidator)1