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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations