Search in sources :

Example 11 with ConfigurationTestResult

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

the class JiraServerGlobalTestActionTest method testUserAdminMissing.

@Test
void testUserAdminMissing() 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(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 12 with ConfigurationTestResult

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

the class JiraServerGlobalTestActionTest method testConfigIssueTrackerException.

@Test
void testConfigIssueTrackerException() throws IntegrationException {
    AuthorizationManager authorizationManager = createAuthorizationManager(255);
    JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
    JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
    Mockito.when(jiraServerTestActionFactory.createTestActionWrapper(Mockito.any())).thenThrow(new IssueTrackerException("Test Exception message"));
    JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createValidJiraServerGlobalConfigModel();
    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) IssueTrackerException(com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueTrackerException) JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) 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 13 with ConfigurationTestResult

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

the class JiraServerGlobalTestActionTest method testAppCheckDisabled.

@Test
void testAppCheckDisabled() 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(false);
    Mockito.when(testActionWrapper.isUserAdmin()).thenThrow(new IntegrationException("Test failure: This exception should not be thrown!"));
    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) IntegrationException(com.synopsys.integration.exception.IntegrationException) 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 14 with ConfigurationTestResult

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

the class SettingsProxyTestActionTest method passwordAlreadySavedTest.

@Test
void passwordAlreadySavedTest() {
    ConfigurationTestResult configurationTestResult = ConfigurationTestResult.success();
    ProxyTestService proxyTestService = Mockito.mock(ProxyTestService.class);
    Mockito.when(proxyTestService.pingHost(Mockito.eq(TEST_URL), Mockito.any())).thenReturn(configurationTestResult);
    SettingsProxyModel settingsProxyModel = createDefaultSettingsProxyModel();
    settingsProxyModel.setProxyPassword(null);
    settingsProxyModel.setIsProxyPasswordSet(true);
    SettingsProxyTestAction settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
    ConfigurationTestResult testResult = settingsProxyTestAction.testConfigModelContent(TEST_URL, settingsProxyModel);
    assertEquals(configurationTestResult, testResult);
}
Also used : SettingsProxyTestAction(com.synopsys.integration.alert.component.settings.proxy.action.SettingsProxyTestAction) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) 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 15 with ConfigurationTestResult

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

the class SettingsProxyTestActionTest method testWithPermissionCheckFailureTest.

@Test
void testWithPermissionCheckFailureTest() {
    ConfigurationTestResult configurationTestResult = ConfigurationTestResult.failure("Failure");
    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());
    assertTrue(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