Search in sources :

Example 1 with XXGroupDao

use of org.apache.ranger.db.XXGroupDao in project ranger by apache.

the class TestXUserMgr method test18ModifyGroupsVisibilitySetOne.

@Test
public void test18ModifyGroupsVisibilitySetOne() {
    XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    XXGroup xxGroup = new XXGroup();
    HashMap<Long, Integer> groupVisibilityMap = new HashMap<Long, Integer>();
    Integer value = 1;
    groupVisibilityMap.put(userId, value);
    Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
    Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
    Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vXGroup);
    Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
    xUserMgr.modifyGroupsVisibility(groupVisibilityMap);
    Assert.assertEquals(value, vXGroup.getIsVisible());
    Assert.assertEquals(userId, vXGroup.getId());
    Mockito.verify(daoManager).getXXGroup();
    Mockito.verify(xGroupService).populateViewBean(xxGroup);
    Mockito.verify(xGroupService).updateResource(vXGroup);
}
Also used : XXGroup(org.apache.ranger.entity.XXGroup) HashMap(java.util.HashMap) VXGroup(org.apache.ranger.view.VXGroup) XXGroupDao(org.apache.ranger.db.XXGroupDao) Test(org.junit.Test)

Example 2 with XXGroupDao

use of org.apache.ranger.db.XXGroupDao in project ranger by apache.

the class TestXUserMgr method test27DeleteXGroup.

@Test
public void test27DeleteXGroup() {
    setup();
    boolean force = true;
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    // XXGroup
    XXGroupDao xXGroupDao = Mockito.mock(XXGroupDao.class);
    XXGroup xXGroup = new XXGroup();
    Mockito.when(daoManager.getXXGroup()).thenReturn(xXGroupDao);
    Mockito.when(xXGroupDao.getById(vXGroup.getId())).thenReturn(xXGroup);
    Mockito.when(xGroupService.populateViewBean(xXGroup)).thenReturn(vXGroup);
    // VXGroupUser
    VXGroupUserList vxGroupUserList = new VXGroupUserList();
    XXGroupUserDao xGroupUserDao = Mockito.mock(XXGroupUserDao.class);
    VXGroupUser vxGroupUser = new VXGroupUser();
    vxGroupUser.setId(userId);
    vxGroupUser.setName("group user test");
    vxGroupUser.setOwner("Admin");
    vxGroupUser.setUserId(userId);
    vxGroupUser.setUpdatedBy("User");
    Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
    Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGroupUserDao);
    // VXPermMap
    VXPermMapList vXPermMapList = new VXPermMapList();
    XXPermMapDao xXPermMapDao = Mockito.mock(XXPermMapDao.class);
    Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(vXPermMapList);
    Mockito.when(daoManager.getXXPermMap()).thenReturn(xXPermMapDao);
    // VXAuditMap
    VXAuditMapList vXAuditMapList = new VXAuditMapList();
    XXAuditMapDao xXAuditMapDao = Mockito.mock(XXAuditMapDao.class);
    Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria) Mockito.any())).thenReturn(vXAuditMapList);
    Mockito.when(daoManager.getXXAuditMap()).thenReturn(xXAuditMapDao);
    // XXGroupGroup
    XXGroupGroupDao xXGroupGroupDao = Mockito.mock(XXGroupGroupDao.class);
    List<XXGroupGroup> xXGroupGroups = new ArrayList<XXGroupGroup>();
    Mockito.when(daoManager.getXXGroupGroup()).thenReturn(xXGroupGroupDao);
    Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(xXGroupGroups);
    // update XXGroupPermission
    XXGroupPermissionDao xXGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
    Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xXGroupPermissionDao);
    List<XXGroupPermission> xXGroupPermissions = new ArrayList<XXGroupPermission>();
    Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupPermissions);
    // update XXPolicyItemUserPerm
    XXPolicyDao xXPolicyDao = Mockito.mock(XXPolicyDao.class);
    List<XXPolicy> xXPolicyList = new ArrayList<XXPolicy>();
    Mockito.when(daoManager.getXXPolicy()).thenReturn(xXPolicyDao);
    Mockito.when(xXPolicyDao.findByGroupId(userId)).thenReturn(xXPolicyList);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito.any());
}
Also used : VXGroupUserList(org.apache.ranger.view.VXGroupUserList) XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) XXAuditMapDao(org.apache.ranger.db.XXAuditMapDao) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) ArrayList(java.util.ArrayList) VXGroupUser(org.apache.ranger.view.VXGroupUser) VXAuditMapList(org.apache.ranger.view.VXAuditMapList) XXPolicy(org.apache.ranger.entity.XXPolicy) XXGroupUserDao(org.apache.ranger.db.XXGroupUserDao) XXGroup(org.apache.ranger.entity.XXGroup) XXPermMapDao(org.apache.ranger.db.XXPermMapDao) XXPolicyDao(org.apache.ranger.db.XXPolicyDao) VXPermMapList(org.apache.ranger.view.VXPermMapList) VXGroup(org.apache.ranger.view.VXGroup) XXGroupGroupDao(org.apache.ranger.db.XXGroupGroupDao) XXGroupDao(org.apache.ranger.db.XXGroupDao) XXGroupGroup(org.apache.ranger.entity.XXGroupGroup) Test(org.junit.Test)

Example 3 with XXGroupDao

use of org.apache.ranger.db.XXGroupDao in project ranger by apache.

the class XUserMgr method deleteXGroup.

public void deleteXGroup(Long id, boolean force) {
    checkAdminAccess();
    blockIfZoneGroup(id);
    this.blockIfRoleGroup(id);
    xaBizUtil.blockAuditorRoleUser();
    XXGroupDao xXGroupDao = daoManager.getXXGroup();
    XXGroup xXGroup = xXGroupDao.getById(id);
    VXGroup vXGroup = xGroupService.populateViewBean(xXGroup);
    if (vXGroup == null || StringUtils.isEmpty(vXGroup.getName())) {
        throw restErrorUtil.createRESTException("Group ID doesn't exist.", MessageEnums.INVALID_INPUT_DATA);
    }
    if (logger.isDebugEnabled()) {
        logger.info("Force delete status=" + force + " for group=" + vXGroup.getName());
    }
    SearchCriteria searchCriteria = new SearchCriteria();
    searchCriteria.addParam("xGroupId", id);
    VXGroupUserList vxGroupUserList = searchXGroupUsers(searchCriteria);
    searchCriteria = new SearchCriteria();
    searchCriteria.addParam("groupId", id);
    VXPermMapList vXPermMapList = searchXPermMaps(searchCriteria);
    searchCriteria = new SearchCriteria();
    searchCriteria.addParam("groupId", id);
    VXAuditMapList vXAuditMapList = searchXAuditMaps(searchCriteria);
    XXGroupPermissionDao xXGroupPermissionDao = daoManager.getXXGroupPermission();
    List<XXGroupPermission> xXGroupPermissions = xXGroupPermissionDao.findByGroupId(id);
    XXGroupGroupDao xXGroupGroupDao = daoManager.getXXGroupGroup();
    List<XXGroupGroup> xXGroupGroups = xXGroupGroupDao.findByGroupId(id);
    XXPolicyDao xXPolicyDao = daoManager.getXXPolicy();
    List<XXPolicy> xXPolicyList = xXPolicyDao.findByGroupId(id);
    logger.warn("Deleting GROUP : " + vXGroup.getName());
    if (force) {
        // delete XXGroupUser records of matching group
        XXGroupUserDao xGroupUserDao = daoManager.getXXGroupUser();
        XXUserDao xXUserDao = daoManager.getXXUser();
        XXUser xXUser = null;
        for (VXGroupUser groupUser : vxGroupUserList.getList()) {
            if (groupUser != null) {
                xXUser = xXUserDao.getById(groupUser.getUserId());
                if (xXUser != null) {
                    logger.warn("Removing user '" + xXUser.getName() + "' from group '" + groupUser.getName() + "'");
                }
                xGroupUserDao.remove(groupUser.getId());
            }
        }
        // delete XXPermMap records of matching group
        XXPermMapDao xXPermMapDao = daoManager.getXXPermMap();
        XXResourceDao xXResourceDao = daoManager.getXXResource();
        XXResource xXResource = null;
        for (VXPermMap vXPermMap : vXPermMapList.getList()) {
            if (vXPermMap != null) {
                xXResource = xXResourceDao.getById(vXPermMap.getResourceId());
                if (xXResource != null) {
                    logger.warn("Deleting '" + AppConstants.getLabelFor_XAPermType(vXPermMap.getPermType()) + "' permission from policy ID='" + vXPermMap.getResourceId() + "' for group '" + vXPermMap.getGroupName() + "'");
                }
                xXPermMapDao.remove(vXPermMap.getId());
            }
        }
        // delete XXAuditMap records of matching group
        XXAuditMapDao xXAuditMapDao = daoManager.getXXAuditMap();
        for (VXAuditMap vXAuditMap : vXAuditMapList.getList()) {
            if (vXAuditMap != null) {
                xXResource = xXResourceDao.getById(vXAuditMap.getResourceId());
                xXAuditMapDao.remove(vXAuditMap.getId());
            }
        }
        // delete XXGroupGroupDao records of group-group mapping
        for (XXGroupGroup xXGroupGroup : xXGroupGroups) {
            if (xXGroupGroup != null) {
                XXGroup xXGroupParent = xXGroupDao.getById(xXGroupGroup.getParentGroupId());
                XXGroup xXGroupChild = xXGroupDao.getById(xXGroupGroup.getGroupId());
                if (xXGroupParent != null && xXGroupChild != null) {
                    logger.warn("Removing group '" + xXGroupChild.getName() + "' from group '" + xXGroupParent.getName() + "'");
                }
                xXGroupGroupDao.remove(xXGroupGroup.getId());
            }
        }
        // delete XXPolicyItemGroupPerm records of group
        for (XXPolicy xXPolicy : xXPolicyList) {
            RangerPolicy rangerPolicy = policyService.getPopulatedViewObject(xXPolicy);
            List<RangerPolicyItem> policyItems = rangerPolicy.getPolicyItems();
            removeUserGroupReferences(policyItems, null, vXGroup.getName());
            rangerPolicy.setPolicyItems(policyItems);
            List<RangerPolicyItem> denyPolicyItems = rangerPolicy.getDenyPolicyItems();
            removeUserGroupReferences(denyPolicyItems, null, vXGroup.getName());
            rangerPolicy.setDenyPolicyItems(denyPolicyItems);
            List<RangerPolicyItem> allowExceptions = rangerPolicy.getAllowExceptions();
            removeUserGroupReferences(allowExceptions, null, vXGroup.getName());
            rangerPolicy.setAllowExceptions(allowExceptions);
            List<RangerPolicyItem> denyExceptions = rangerPolicy.getDenyExceptions();
            removeUserGroupReferences(denyExceptions, null, vXGroup.getName());
            rangerPolicy.setDenyExceptions(denyExceptions);
            List<RangerDataMaskPolicyItem> dataMaskItems = rangerPolicy.getDataMaskPolicyItems();
            removeUserGroupReferences(dataMaskItems, null, vXGroup.getName());
            rangerPolicy.setDataMaskPolicyItems(dataMaskItems);
            List<RangerRowFilterPolicyItem> rowFilterItems = rangerPolicy.getRowFilterPolicyItems();
            removeUserGroupReferences(rowFilterItems, null, vXGroup.getName());
            rangerPolicy.setRowFilterPolicyItems(rowFilterItems);
            try {
                svcStore.updatePolicy(rangerPolicy);
            } catch (Throwable excp) {
                logger.error("updatePolicy(" + rangerPolicy + ") failed", excp);
                restErrorUtil.createRESTException(excp.getMessage());
            }
        }
        if (CollectionUtils.isNotEmpty(xXGroupPermissions)) {
            for (XXGroupPermission xXGroupPermission : xXGroupPermissions) {
                if (xXGroupPermission != null) {
                    XXModuleDef xXModuleDef = daoManager.getXXModuleDef().findByModuleId(xXGroupPermission.getModuleId());
                    if (xXModuleDef != null) {
                        logger.warn("Deleting '" + xXModuleDef.getModule() + "' module permission for group '" + xXGroup.getName() + "'");
                    }
                    xXGroupPermissionDao.remove(xXGroupPermission.getId());
                }
            }
        }
        // delete group from audit filter configs
        svcStore.updateServiceAuditConfig(vXGroup.getName(), REMOVE_REF_TYPE.GROUP);
        // delete XXGroup
        xXGroupDao.remove(id);
        // Create XXTrxLog
        List<XXTrxLog> xXTrxLogsXXGroup = xGroupService.getTransactionLog(xGroupService.populateViewBean(xXGroup), "delete");
        xaBizUtil.createTrxLog(xXTrxLogsXXGroup);
    } else {
        boolean hasReferences = false;
        if (vxGroupUserList.getListSize() > 0) {
            hasReferences = true;
        }
        if (hasReferences == false && CollectionUtils.isNotEmpty(xXPolicyList)) {
            hasReferences = true;
        }
        if (hasReferences == false && vXPermMapList.getListSize() > 0) {
            hasReferences = true;
        }
        if (hasReferences == false && vXAuditMapList.getListSize() > 0) {
            hasReferences = true;
        }
        if (hasReferences == false && CollectionUtils.isNotEmpty(xXGroupGroups)) {
            hasReferences = true;
        }
        if (hasReferences == false && CollectionUtils.isNotEmpty(xXGroupPermissions)) {
            hasReferences = true;
        }
        if (hasReferences) {
            // change visibility to Hidden
            if (vXGroup.getIsVisible() == RangerCommonEnums.IS_VISIBLE) {
                vXGroup.setIsVisible(RangerCommonEnums.IS_HIDDEN);
                xGroupService.updateResource(vXGroup);
            }
        } else {
            // delete XXGroup
            xXGroupDao.remove(id);
            // Create XXTrxLog
            List<XXTrxLog> xXTrxLogsXXGroup = xGroupService.getTransactionLog(xGroupService.populateViewBean(xXGroup), "delete");
            xaBizUtil.createTrxLog(xXTrxLogsXXGroup);
        }
    }
}
Also used : XXUser(org.apache.ranger.entity.XXUser) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) XXUserDao(org.apache.ranger.db.XXUserDao) XXPolicy(org.apache.ranger.entity.XXPolicy) XXGroupUserDao(org.apache.ranger.db.XXGroupUserDao) RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) XXModuleDef(org.apache.ranger.entity.XXModuleDef) XXPermMapDao(org.apache.ranger.db.XXPermMapDao) XXGroupGroupDao(org.apache.ranger.db.XXGroupGroupDao) XXResourceDao(org.apache.ranger.db.XXResourceDao) XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) XXResource(org.apache.ranger.entity.XXResource) XXAuditMapDao(org.apache.ranger.db.XXAuditMapDao) RangerRowFilterPolicyItem(org.apache.ranger.plugin.model.RangerPolicy.RangerRowFilterPolicyItem) XXTrxLog(org.apache.ranger.entity.XXTrxLog) RangerPolicyItem(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem) XXGroup(org.apache.ranger.entity.XXGroup) RangerDataMaskPolicyItem(org.apache.ranger.plugin.model.RangerPolicy.RangerDataMaskPolicyItem) XXPolicyDao(org.apache.ranger.db.XXPolicyDao) XXGroupDao(org.apache.ranger.db.XXGroupDao) XXGroupGroup(org.apache.ranger.entity.XXGroupGroup)

Example 4 with XXGroupDao

use of org.apache.ranger.db.XXGroupDao in project ranger by apache.

the class TestXUserMgr method test13ModifyGroupsVisibilitySetEmpty.

@Test
public void test13ModifyGroupsVisibilitySetEmpty() {
    setup();
    XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
    VXGroup vXGroup = vxGroup();
    XXGroup xxGroup = new XXGroup();
    HashMap<Long, Integer> groupVisibilityMap = new HashMap<Long, Integer>();
    groupVisibilityMap.put(userId, emptyValue);
    Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
    Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
    Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vXGroup);
    Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
    xUserMgr.modifyGroupsVisibility(groupVisibilityMap);
    Assert.assertEquals(emptyValue, vXGroup.getIsVisible());
    Assert.assertEquals(userId, vXGroup.getId());
    Mockito.verify(daoManager).getXXGroup();
    Mockito.verify(xGroupService).populateViewBean(xxGroup);
    Mockito.verify(xGroupService).updateResource(vXGroup);
}
Also used : XXGroup(org.apache.ranger.entity.XXGroup) HashMap(java.util.HashMap) VXLong(org.apache.ranger.view.VXLong) VXGroup(org.apache.ranger.view.VXGroup) XXGroupDao(org.apache.ranger.db.XXGroupDao) Test(org.junit.Test)

Example 5 with XXGroupDao

use of org.apache.ranger.db.XXGroupDao in project ranger by apache.

the class TestXUserMgr method test95DeleteXGroup.

@Test
public void test95DeleteXGroup() {
    setup();
    boolean force = false;
    VXGroup vXGroup = vxGroup();
    XXGroupDao xXGroupDao = Mockito.mock(XXGroupDao.class);
    XXGroup xXGroup = new XXGroup();
    Mockito.when(daoManager.getXXGroup()).thenReturn(xXGroupDao);
    Mockito.when(xXGroupDao.getById(vXGroup.getId())).thenReturn(xXGroup);
    Mockito.when(xGroupService.populateViewBean(xXGroup)).thenReturn(vXGroup);
    VXGroupUserList vxGroupUserList = vxGroupUserList();
    Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
    VXPermMapList vXPermMapList = new VXPermMapList();
    VXPermMap vXPermMap1 = getVXPermMap();
    List<VXPermMap> vXPermMaps = new ArrayList<VXPermMap>();
    vXPermMaps.add(vXPermMap1);
    VXAuditMapList vXAuditMapList = new VXAuditMapList();
    List<VXAuditMap> vXAuditMaps = new ArrayList<VXAuditMap>();
    VXAuditMap vXAuditMap = getVXAuditMap();
    vXAuditMaps.add(vXAuditMap);
    XXGroupGroupDao xXGroupGroupDao = Mockito.mock(XXGroupGroupDao.class);
    List<XXGroupGroup> xXGroupGroups = new ArrayList<XXGroupGroup>();
    Mockito.when(daoManager.getXXGroupGroup()).thenReturn(xXGroupGroupDao);
    Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(xXGroupGroups);
    XXGroupPermissionDao xXGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
    Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xXGroupPermissionDao);
    List<XXGroupPermission> xXGroupPermissions = new ArrayList<XXGroupPermission>();
    Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupPermissions);
    XXPolicyDao xXPolicyDao = Mockito.mock(XXPolicyDao.class);
    List<XXPolicy> xXPolicyList = new ArrayList<XXPolicy>();
    Mockito.when(daoManager.getXXPolicy()).thenReturn(xXPolicyDao);
    List<XXResource> xResourceList = new ArrayList<XXResource>();
    List<XXSecurityZoneRefGroup> zoneSecRefGroup = new ArrayList<XXSecurityZoneRefGroup>();
    XXSecurityZoneRefGroupDao zoneSecRefGroupDao = Mockito.mock(XXSecurityZoneRefGroupDao.class);
    Mockito.when(daoManager.getXXSecurityZoneRefGroup()).thenReturn(zoneSecRefGroupDao);
    List<XXRoleRefGroup> roleRefGroup = new ArrayList<XXRoleRefGroup>();
    XXRoleRefGroupDao roleRefGroupDao = Mockito.mock(XXRoleRefGroupDao.class);
    Mockito.when(daoManager.getXXRoleRefGroup()).thenReturn(roleRefGroupDao);
    Mockito.when(zoneSecRefGroupDao.findByGroupId(userId)).thenReturn(zoneSecRefGroup);
    Mockito.when(roleRefGroupDao.findByGroupId(userId)).thenReturn(roleRefGroup);
    XXResource xXResource = new XXResource();
    xXResource.setId(userId);
    xXResource.setName("hadoopdev");
    xXResource.setIsRecursive(AppConstants.BOOL_TRUE);
    xXResource.setResourceStatus(AppConstants.STATUS_ENABLED);
    xResourceList.add(xXResource);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(new VXGroupUserList());
    XXPolicy xXPolicy = getXXPolicy();
    xXPolicyList.add(xXPolicy);
    Mockito.when(xXPolicyDao.findByGroupId(userId)).thenReturn(xXPolicyList);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xXPolicyDao.findByGroupId(userId)).thenReturn(new ArrayList<XXPolicy>());
    vXPermMapList.setVXPermMaps(vXPermMaps);
    Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(vXPermMapList);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(new VXPermMapList());
    vXAuditMapList.setVXAuditMaps(vXAuditMaps);
    Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria) Mockito.any())).thenReturn(vXAuditMapList);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria) Mockito.any())).thenReturn(new VXAuditMapList());
    XXGroupGroup xXGroupGroup = xxGroupGroup();
    xXGroupGroups.add(xXGroupGroup);
    Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(xXGroupGroups);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(new ArrayList<XXGroupGroup>());
    XXGroupPermission xGroupPermissionObj = xxGroupPermission();
    xXGroupPermissions.add(xGroupPermissionObj);
    Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupPermissions);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(new ArrayList<XXGroupPermission>());
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.when(xGroupService.populateViewBean(xXGroup)).thenReturn(null);
    Mockito.when(restErrorUtil.createRESTException("Group ID doesn't exist.", MessageEnums.INVALID_INPUT_DATA)).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
}
Also used : XXSecurityZoneRefGroup(org.apache.ranger.entity.XXSecurityZoneRefGroup) VXGroupUserList(org.apache.ranger.view.VXGroupUserList) VXPermMap(org.apache.ranger.view.VXPermMap) WebApplicationException(javax.ws.rs.WebApplicationException) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) ArrayList(java.util.ArrayList) XXSecurityZoneRefGroupDao(org.apache.ranger.db.XXSecurityZoneRefGroupDao) XXPolicy(org.apache.ranger.entity.XXPolicy) XXRoleRefGroupDao(org.apache.ranger.db.XXRoleRefGroupDao) XXRoleRefGroup(org.apache.ranger.entity.XXRoleRefGroup) VXAuditMap(org.apache.ranger.view.VXAuditMap) VXPermMapList(org.apache.ranger.view.VXPermMapList) XXGroupGroupDao(org.apache.ranger.db.XXGroupGroupDao) XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) XXResource(org.apache.ranger.entity.XXResource) VXAuditMapList(org.apache.ranger.view.VXAuditMapList) XXGroup(org.apache.ranger.entity.XXGroup) XXPolicyDao(org.apache.ranger.db.XXPolicyDao) VXGroup(org.apache.ranger.view.VXGroup) XXGroupDao(org.apache.ranger.db.XXGroupDao) XXGroupGroup(org.apache.ranger.entity.XXGroupGroup) Test(org.junit.Test)

Aggregations

XXGroupDao (org.apache.ranger.db.XXGroupDao)16 XXGroup (org.apache.ranger.entity.XXGroup)16 VXGroup (org.apache.ranger.view.VXGroup)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)5 XXGroupGroupDao (org.apache.ranger.db.XXGroupGroupDao)4 XXGroupPermissionDao (org.apache.ranger.db.XXGroupPermissionDao)4 XXPolicyDao (org.apache.ranger.db.XXPolicyDao)4 XXGroupGroup (org.apache.ranger.entity.XXGroupGroup)4 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)4 XXPolicy (org.apache.ranger.entity.XXPolicy)4 VXGroupUserList (org.apache.ranger.view.VXGroupUserList)4 XXAuditMapDao (org.apache.ranger.db.XXAuditMapDao)3 XXPermMapDao (org.apache.ranger.db.XXPermMapDao)3 XXUserDao (org.apache.ranger.db.XXUserDao)3 XXResource (org.apache.ranger.entity.XXResource)3 XXUser (org.apache.ranger.entity.XXUser)3 VXLong (org.apache.ranger.view.VXLong)3