use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager in project hub-alert by blackducksoftware.
the class DistributionActionsTest method createDistributionActions.
private DistributionActions createDistributionActions(Comparator<DistributionWithAuditInfo> sorter) {
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.when(authorizationManager.hasReadPermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(true);
DistributionAccessor defaultDistributionAccessor = Mockito.mock(DistributionAccessor.class);
Mockito.when(defaultDistributionAccessor.getDistributionWithAuditInfo(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyString(), Mockito.any(), Mockito.anySet())).thenReturn(createDistributionInfo(sorter));
DistributionActions distributionActions = new DistributionActions(defaultDistributionAccessor, authorizationManager, descriptorMap);
return distributionActions;
}
use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager in project hub-alert by blackducksoftware.
the class DescriptorMetadataActionsTest method createDescriptorController.
private DescriptorMetadataActions createDescriptorController() {
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.doReturn(true).when(authorizationManager).isReadOnly(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasPermissions(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasReadPermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasDeletePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasWritePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasCreatePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasExecutePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(true).when(authorizationManager).hasReadPermission(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(true).when(authorizationManager).hasDeletePermission(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(true).when(authorizationManager).hasWritePermission(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(true).when(authorizationManager).hasCreatePermission(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(true).when(authorizationManager).hasExecutePermission(Mockito.anyString(), Mockito.anyString());
DescriptorMetadataActions actions = new DescriptorMetadataActions(descriptors, authorizationManager);
return actions;
}
use of com.synopsys.integration.alert.common.security.authorization.AuthorizationManager in project hub-alert by blackducksoftware.
the class DescriptorMetadataActionsTest method getDescriptorsWithoutPermissionTest.
@Test
public void getDescriptorsWithoutPermissionTest() {
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.doReturn(true).when(authorizationManager).hasPermissions(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
Mockito.doReturn(false).when(authorizationManager).hasReadPermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class));
DescriptorMetadataActions actions = new DescriptorMetadataActions(descriptors, authorizationManager);
ActionResponse<DescriptorsResponseModel> response = actions.getDescriptorsByPermissions(null, null, null);
assertTrue(response.isSuccessful());
assertTrue(response.hasContent());
List<AccessOperation> allAccessOperations = response.getContent().stream().map(DescriptorsResponseModel::getDescriptors).flatMap(Set::stream).map(DescriptorMetadata::getOperations).flatMap(Set::stream).collect(Collectors.toList());
assertEquals(0, allAccessOperations.size());
}
Aggregations