use of com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationActionTest method testDeleteForbidden.
@Test
public void testDeleteForbidden() {
AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
DescriptorKey descriptorKey = ChannelKeys.EMAIL;
PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.NO_PERMISSIONS);
AuthorizationManager authorizationManager = authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
UUID configId = UUID.randomUUID();
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigAccessor emailGlobalConfigAccessor = Mockito.mock(EmailGlobalConfigAccessor.class);
EmailGlobalCrudActions configActions = new EmailGlobalCrudActions(authorizationManager, emailGlobalConfigAccessor, validator);
ActionResponse<EmailGlobalConfigModel> response = configActions.delete();
assertEquals(HttpStatus.FORBIDDEN, response.getHttpStatus());
}
use of com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationActionTest method testDelete.
@Test
public void testDelete() {
AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
DescriptorKey descriptorKey = ChannelKeys.EMAIL;
PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.FULL_PERMISSIONS);
AuthorizationManager authorizationManager = authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigAccessor emailGlobalConfigAccessor = Mockito.mock(EmailGlobalConfigAccessor.class);
EmailGlobalConfigModel model = new EmailGlobalConfigModel();
model.setSmtpHost("host");
model.setSmtpFrom("from");
model.setSmtpAuth(true);
model.setSmtpUsername("user");
model.setSmtpPassword("password");
Mockito.when(emailGlobalConfigAccessor.getConfiguration()).thenReturn(Optional.of(model));
Mockito.when(emailGlobalConfigAccessor.doesConfigurationExist()).thenReturn(true);
EmailGlobalCrudActions configActions = new EmailGlobalCrudActions(authorizationManager, emailGlobalConfigAccessor, validator);
ActionResponse<EmailGlobalConfigModel> response = configActions.delete();
assertEquals(HttpStatus.NO_CONTENT, response.getHttpStatus());
}
use of com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationActionTest method testDeleteNotFound.
@Test
public void testDeleteNotFound() {
AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
DescriptorKey descriptorKey = ChannelKeys.EMAIL;
PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.FULL_PERMISSIONS);
AuthorizationManager authorizationManager = authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigAccessor emailGlobalConfigAccessor = Mockito.mock(EmailGlobalConfigAccessor.class);
Mockito.when(emailGlobalConfigAccessor.getConfiguration()).thenReturn(Optional.empty());
EmailGlobalCrudActions configActions = new EmailGlobalCrudActions(authorizationManager, emailGlobalConfigAccessor, validator);
ActionResponse<EmailGlobalConfigModel> response = configActions.delete();
assertEquals(HttpStatus.NOT_FOUND, response.getHttpStatus());
}
use of com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationActionTest method testGetOneForbidden.
@Test
public void testGetOneForbidden() {
AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
DescriptorKey descriptorKey = ChannelKeys.EMAIL;
PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.NO_PERMISSIONS);
AuthorizationManager authorizationManager = authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigAccessor emailGlobalConfigAccessor = Mockito.mock(EmailGlobalConfigAccessor.class);
EmailGlobalCrudActions configActions = new EmailGlobalCrudActions(authorizationManager, emailGlobalConfigAccessor, validator);
ActionResponse<EmailGlobalConfigModel> response = configActions.getOne();
assertEquals(HttpStatus.FORBIDDEN, response.getHttpStatus());
}
use of com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationActionTest method testCreateForbidden.
@Test
public void testCreateForbidden() {
AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
DescriptorKey descriptorKey = ChannelKeys.EMAIL;
PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.NO_PERMISSIONS);
AuthorizationManager authorizationManager = authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailGlobalConfigAccessor emailGlobalConfigAccessor = Mockito.mock(EmailGlobalConfigAccessor.class);
EmailGlobalConfigModel model = new EmailGlobalConfigModel();
model.setSmtpHost("host");
model.setSmtpFrom("from");
model.setSmtpAuth(true);
model.setSmtpUsername("user");
model.setSmtpPassword("password");
EmailGlobalCrudActions configActions = new EmailGlobalCrudActions(authorizationManager, emailGlobalConfigAccessor, validator);
ActionResponse<EmailGlobalConfigModel> response = configActions.create(model);
assertEquals(HttpStatus.FORBIDDEN, response.getHttpStatus());
}
Aggregations