use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager in project hub-alert by blackducksoftware.
the class JiraServerGlobalTestActionTest method testPermissionOK.
@Test
void testPermissionOK() 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);
ActionResponse<ValidationResponseModel> validationResponseModel = jiraServerGlobalTestAction.testWithPermissionCheck(jiraServerGlobalConfigModel);
assertTrue(validationResponseModel.isSuccessful());
assertEquals(HttpStatus.OK, validationResponseModel.getHttpStatus());
}
use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager 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());
}
use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager in project hub-alert by blackducksoftware.
the class JiraServerGlobalTestActionTest method testPermissionForbidden.
@Test
void testPermissionForbidden() {
AuthorizationManager authorizationManager = createAuthorizationManager(0);
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
JiraServerGlobalTestAction jiraServerGlobalTestAction = new JiraServerGlobalTestAction(authorizationManager, validator, jiraServerTestActionFactory);
ActionResponse<ValidationResponseModel> validationResponseModel = jiraServerGlobalTestAction.testWithPermissionCheck(jiraServerGlobalConfigModel);
assertTrue(validationResponseModel.isError());
assertEquals(HttpStatus.FORBIDDEN, validationResponseModel.getHttpStatus());
}
use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager 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());
}
use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager 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());
}
Aggregations