Search in sources :

Example 11 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class StorageDomainCommandBase method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionCheckSubjects = new ArrayList<>();
    permissionCheckSubjects.add(new PermissionSubject(getParameters().getStorageDomainId(), VdcObjectType.Storage, getActionType().getActionGroup()));
    return permissionCheckSubjects;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Example 12 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class AddVmTemplateCommandTest method testPermissionsForAddingTemplateDedicatedHostNotChanged.

@Test
public void testPermissionsForAddingTemplateDedicatedHostNotChanged() {
    setupDedicatedHostForVmAndTemplate(true);
    List<PermissionSubject> permissionCheckSubjects = cmd.getPermissionCheckSubjects();
    for (PermissionSubject permissionSubject : permissionCheckSubjects) {
        assertFalse(ActionGroup.EDIT_ADMIN_TEMPLATE_PROPERTIES.equals(permissionSubject.getActionGroup()));
    }
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Test(org.junit.Test)

Example 13 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class AddVmTemplateCommandTest method testPermissionsForAddingTemplateDedicatedHostChanged.

@Test
public void testPermissionsForAddingTemplateDedicatedHostChanged() {
    setupDedicatedHostForVmAndTemplate(false);
    PermissionSubject editDefaultHostPermission = new PermissionSubject(vm.getStoragePoolId(), VdcObjectType.StoragePool, ActionGroup.EDIT_ADMIN_TEMPLATE_PROPERTIES);
    List<PermissionSubject> permissionCheckSubjects = cmd.getPermissionCheckSubjects();
    permissionCheckSubjects.stream().filter(permissionSubject -> ActionGroup.EDIT_ADMIN_TEMPLATE_PROPERTIES == permissionSubject.getActionGroup()).forEach(permissionSubject -> verifyPermissions(editDefaultHostPermission, permissionSubject));
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Mock(org.mockito.Mock) Guid(org.ovirt.engine.core.compat.Guid) ValidationResultMatchers(org.ovirt.engine.core.bll.validator.ValidationResultMatchers) HashMap(java.util.HashMap) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator) Map(java.util.Map) Spy(org.mockito.Spy) StoragePoolDao(org.ovirt.engine.core.dao.StoragePoolDao) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) Version(org.ovirt.engine.core.compat.Version) Mockito.doReturn(org.mockito.Mockito.doReturn) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) ImagesHandler(org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) DiskVmElementDao(org.ovirt.engine.core.dao.DiskVmElementDao) VmDao(org.ovirt.engine.core.dao.VmDao) DiskHandler(org.ovirt.engine.core.bll.storage.disk.DiskHandler) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Assert.assertFalse(org.junit.Assert.assertFalse) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) VmDeviceUtils(org.ovirt.engine.core.bll.utils.VmDeviceUtils) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) Mockito.mock(org.mockito.Mockito.mock) Test(org.junit.Test)

Example 14 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class ChangeVDSClusterCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = new ArrayList<>();
    VdsDynamic vdsDynamic = getVds().getDynamicData();
    // in order to approve a host
    if (vdsDynamic != null && !VDSStatus.PendingApproval.equals(vdsDynamic.getStatus())) {
        permissionList.add(new PermissionSubject(getParameters().getVdsId(), VdcObjectType.VDS, getActionType().getActionGroup()));
    }
    permissionList.add(new PermissionSubject(getParameters().getClusterId(), VdcObjectType.Cluster, getActionType().getActionGroup()));
    List<PermissionSubject> unmodifiableList = Collections.unmodifiableList(permissionList);
    return unmodifiableList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) ArrayList(java.util.ArrayList)

Example 15 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class EndExternalJobCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = new ArrayList<>();
    permissionList.add(new PermissionSubject(MultiLevelAdministrationHandler.SYSTEM_OBJECT_ID, VdcObjectType.System, ActionGroup.INJECT_EXTERNAL_TASKS));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Aggregations

PermissionSubject (org.ovirt.engine.core.bll.utils.PermissionSubject)71 ArrayList (java.util.ArrayList)47 Guid (org.ovirt.engine.core.compat.Guid)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)5 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ImagesHandler (org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler)3 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)3 VM (org.ovirt.engine.core.common.businessentities.VM)3 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)3 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 DiskVmElementDao (org.ovirt.engine.core.dao.DiskVmElementDao)3 Arrays (java.util.Arrays)2