Search in sources :

Example 6 with ConfigurationTestResult

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

the class EmailGlobalTestActionTest method testConfigInvalidDestinationTest.

@Test
public void testConfigInvalidDestinationTest() {
    AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
    EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
    EmailGlobalTestAction emailGlobalTestAction = new EmailGlobalTestAction(authorizationManager, validator, null, null, null);
    ConfigurationTestResult testResult = emailGlobalTestAction.testConfigModelContent("not a valid email address", new EmailGlobalConfigModel());
    assertFalse(testResult.isSuccess());
}
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) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test)

Example 7 with ConfigurationTestResult

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

the class EmailGlobalTestActionTest method testConfigValidTest.

@Test
public void testConfigValidTest() 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);
    ConfigurationTestResult testResult = emailGlobalTestAction.testConfigModelContent("noreply@synopsys.com", new 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)

Example 8 with ConfigurationTestResult

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

the class SettingsProxyTestActionTest method blankTestUrlTest.

@Test
void blankTestUrlTest() {
    ProxyTestService proxyTestService = Mockito.mock(ProxyTestService.class);
    SettingsProxyTestAction settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ConfigurationTestResult testResult = settingsProxyTestAction.testConfigModelContent("", defaultSettingsProxyModel);
    assertFalse(testResult.isSuccess());
}
Also used : 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 9 with ConfigurationTestResult

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

the class SettingsProxyTestActionTest method testConfigModelContentTest.

@Test
void testConfigModelContentTest() {
    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);
    ConfigurationTestResult testResult = settingsProxyTestAction.testConfigModelContent(TEST_URL, defaultSettingsProxyModel);
    assertEquals(configurationTestResult, testResult);
}
Also used : 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 10 with ConfigurationTestResult

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

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