Search in sources :

Example 1 with VXModuleDef

use of org.apache.ranger.view.VXModuleDef in project ranger by apache.

the class TestXUserMgr method test32getXModuleDefPermission.

@Test
public void test32getXModuleDefPermission() {
    VXModuleDef vXModuleDef = vXModuleDef();
    Mockito.when(xModuleDefService.readResource(1L)).thenReturn(vXModuleDef);
    VXModuleDef dbMuduleDef = xUserMgr.getXModuleDefPermission(1L);
    Assert.assertNotNull(dbMuduleDef);
    Assert.assertEquals(dbMuduleDef, vXModuleDef);
    Assert.assertEquals(dbMuduleDef.getId(), vXModuleDef.getId());
    Assert.assertEquals(dbMuduleDef.getOwner(), vXModuleDef.getOwner());
    Assert.assertEquals(dbMuduleDef.getUpdatedBy(), vXModuleDef.getUpdatedBy());
    Assert.assertEquals(dbMuduleDef.getUrl(), vXModuleDef.getUrl());
    Assert.assertEquals(dbMuduleDef.getAddedById(), vXModuleDef.getAddedById());
    Assert.assertEquals(dbMuduleDef.getCreateDate(), vXModuleDef.getCreateDate());
    Assert.assertEquals(dbMuduleDef.getCreateTime(), vXModuleDef.getCreateTime());
    Assert.assertEquals(dbMuduleDef.getUserPermList(), vXModuleDef.getUserPermList());
    Assert.assertEquals(dbMuduleDef.getGroupPermList(), vXModuleDef.getGroupPermList());
    Mockito.verify(xModuleDefService).readResource(1L);
}
Also used : VXModuleDef(org.apache.ranger.view.VXModuleDef) Test(org.junit.Test)

Example 2 with VXModuleDef

use of org.apache.ranger.view.VXModuleDef in project ranger by apache.

the class TestXUserMgr method vXModuleDef.

private VXModuleDef vXModuleDef() {
    VXUserPermission userPermission = vXUserPermission();
    List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
    userPermList.add(userPermission);
    VXGroupPermission groupPermission = vXGroupPermission();
    List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
    groupPermList.add(groupPermission);
    VXModuleDef vxModuleDef = new VXModuleDef();
    vxModuleDef.setAddedById(userId);
    vxModuleDef.setCreateDate(new Date());
    vxModuleDef.setCreateTime(new Date());
    vxModuleDef.setId(userId);
    vxModuleDef.setModule("Policy manager");
    vxModuleDef.setOwner("admin");
    vxModuleDef.setUpdateDate(new Date());
    vxModuleDef.setUpdatedBy("admin");
    vxModuleDef.setUpdatedById(userId);
    vxModuleDef.setUpdateTime(new Date());
    vxModuleDef.setUrl("/policy manager");
    vxModuleDef.setUserPermList(userPermList);
    vxModuleDef.setGroupPermList(groupPermList);
    return vxModuleDef;
}
Also used : VXGroupPermission(org.apache.ranger.view.VXGroupPermission) VXModuleDef(org.apache.ranger.view.VXModuleDef) ArrayList(java.util.ArrayList) VXUserPermission(org.apache.ranger.view.VXUserPermission) Date(java.util.Date)

Example 3 with VXModuleDef

use of org.apache.ranger.view.VXModuleDef in project ranger by apache.

the class TestXUserREST method createVXModuleDef.

private VXModuleDef createVXModuleDef() {
    VXModuleDef testVXModuleDef = new VXModuleDef();
    testVXModuleDef.setAddedById(id);
    testVXModuleDef.setCreateDate(new Date());
    testVXModuleDef.setCreateTime(new Date());
    VXGroupPermission testVXGroupPermission = createVXGroupPermission();
    List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
    groupPermList.add(testVXGroupPermission);
    testVXModuleDef.setGroupPermList(groupPermList);
    testVXModuleDef.setId(id);
    testVXModuleDef.setModule("testModule");
    testVXModuleDef.setOwner("Admin");
    testVXModuleDef.setUpdateDate(new Date());
    testVXModuleDef.setUpdatedBy("Admin");
    testVXModuleDef.setUpdatedById(id);
    testVXModuleDef.setUpdateTime(new Date());
    testVXModuleDef.setUrl("testUrrl");
    List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
    VXUserPermission testVXUserPermission = createVXUserPermission();
    userPermList.add(testVXUserPermission);
    testVXModuleDef.setUserPermList(userPermList);
    return testVXModuleDef;
}
Also used : VXGroupPermission(org.apache.ranger.view.VXGroupPermission) VXModuleDef(org.apache.ranger.view.VXModuleDef) ArrayList(java.util.ArrayList) Date(java.util.Date) VXUserPermission(org.apache.ranger.view.VXUserPermission)

Example 4 with VXModuleDef

use of org.apache.ranger.view.VXModuleDef in project ranger by apache.

the class TestXUserREST method test77getXModuleDefPermission.

@Test
public void test77getXModuleDefPermission() {
    VXModuleDef testVXModuleDef = createVXModuleDef();
    Mockito.when(xUserMgr.getXModuleDefPermission(testVXModuleDef.getId())).thenReturn(testVXModuleDef);
    VXModuleDef retVxModuleDef = xUserRest.getXModuleDefPermission(testVXModuleDef.getId());
    assertNotNull(retVxModuleDef);
    assertEquals(testVXModuleDef.getId(), retVxModuleDef.getId());
    assertEquals(testVXModuleDef.getOwner(), retVxModuleDef.getOwner());
    Mockito.verify(xUserMgr).getXModuleDefPermission(testVXModuleDef.getId());
}
Also used : VXModuleDef(org.apache.ranger.view.VXModuleDef) Test(org.junit.Test)

Example 5 with VXModuleDef

use of org.apache.ranger.view.VXModuleDef in project ranger by apache.

the class XModuleDefService method populateViewBean.

@Override
public VXModuleDef populateViewBean(XXModuleDef xObj) {
    VXModuleDef vModuleDef = super.populateViewBean(xObj);
    Map<Long, XXUser> xXPortalUserIdXXUserMap = xUserService.getXXPortalUserIdXXUserMap();
    Map<Long, XXGroup> xXGroupMap = xGroupService.getXXGroupIdXXGroupMap();
    List<VXUserPermission> vXUserPermissionList = new ArrayList<VXUserPermission>();
    List<VXGroupPermission> vXGroupPermissionList = new ArrayList<VXGroupPermission>();
    List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(xObj.getId(), false);
    List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(xObj.getId(), false);
    if (CollectionUtils.isEmpty(xXPortalUserIdXXUserMap)) {
        for (XXUserPermission xUserPerm : xuserPermissionList) {
            VXUserPermission vXUserPerm = xUserPermService.populateViewBean(xUserPerm);
            vXUserPermissionList.add(vXUserPerm);
        }
    } else {
        vXUserPermissionList = xUserPermService.getPopulatedVXUserPermissionList(xuserPermissionList, xXPortalUserIdXXUserMap, vModuleDef);
    }
    if (CollectionUtils.isEmpty(xXGroupMap)) {
        for (XXGroupPermission xGrpPerm : xgroupPermissionList) {
            VXGroupPermission vXGrpPerm = xGrpPermService.populateViewBean(xGrpPerm);
            vXGroupPermissionList.add(vXGrpPerm);
        }
    } else {
        vXGroupPermissionList = xGrpPermService.getPopulatedVXGroupPermissionList(xgroupPermissionList, xXGroupMap, vModuleDef);
    }
    vModuleDef.setUserPermList(vXUserPermissionList);
    vModuleDef.setGroupPermList(vXGroupPermissionList);
    return vModuleDef;
}
Also used : XXUser(org.apache.ranger.entity.XXUser) XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) ArrayList(java.util.ArrayList) XXUserPermission(org.apache.ranger.entity.XXUserPermission) VXUserPermission(org.apache.ranger.view.VXUserPermission) XXGroup(org.apache.ranger.entity.XXGroup) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) VXModuleDef(org.apache.ranger.view.VXModuleDef)

Aggregations

VXModuleDef (org.apache.ranger.view.VXModuleDef)11 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)4 VXUserPermission (org.apache.ranger.view.VXUserPermission)4 Date (java.util.Date)2 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)2 VXModuleDefList (org.apache.ranger.view.VXModuleDefList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 SortField (org.apache.ranger.common.SortField)1 UserSessionBase (org.apache.ranger.common.UserSessionBase)1 XXGroupPermissionDao (org.apache.ranger.db.XXGroupPermissionDao)1 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)1 XXUserPermissionDao (org.apache.ranger.db.XXUserPermissionDao)1 XXGroup (org.apache.ranger.entity.XXGroup)1 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)1 XXModuleDef (org.apache.ranger.entity.XXModuleDef)1