Search in sources :

Example 21 with AuthorizationManager

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) JiraServerGlobalConfigurationValidator(com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) Test(org.junit.jupiter.api.Test)

Example 22 with AuthorizationManager

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());
}
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 23 with AuthorizationManager

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());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) JiraServerGlobalConfigurationValidator(com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) Test(org.junit.jupiter.api.Test)

Example 24 with AuthorizationManager

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());
}
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 25 with AuthorizationManager

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

Aggregations

AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)83 Test (org.junit.jupiter.api.Test)78 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)49 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)38 PermissionMatrixModel (com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel)38 AuthenticationTestUtils (com.synopsys.integration.alert.test.common.AuthenticationTestUtils)38 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)27 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)26 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)23 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)20 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)16 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)15 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)14 EmailGlobalConfigAccessor (com.synopsys.integration.alert.channel.email.database.accessor.EmailGlobalConfigAccessor)13 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)12 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)9 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)9 JiraServerGlobalConfigurationValidator (com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator)8 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)8 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)7