use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestXUserREST method test90updateXGroupPermission.
@Test
public void test90updateXGroupPermission() {
VXGroupPermission testVXGroupPermission = createVXGroupPermission();
Mockito.doNothing().when(xUserMgr).checkAdminAccess();
Mockito.when(xUserMgr.updateXGroupPermission(testVXGroupPermission)).thenReturn(testVXGroupPermission);
VXGroupPermission retVXGroupPermission = xUserRest.updateXGroupPermission(testVXGroupPermission);
Mockito.verify(xUserMgr).updateXGroupPermission(testVXGroupPermission);
Mockito.verify(xUserMgr).checkAdminAccess();
assertNotNull(retVXGroupPermission);
assertEquals(retVXGroupPermission.getId(), testVXGroupPermission.getId());
assertEquals(retVXGroupPermission.getClass(), testVXGroupPermission.getClass());
}
use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestXUserREST method test88createXGroupPermission.
@Test
public void test88createXGroupPermission() {
VXGroupPermission testVXGroupPermission = createVXGroupPermission();
Mockito.doNothing().when(xUserMgr).checkAdminAccess();
Mockito.when(xUserMgr.createXGroupPermission(testVXGroupPermission)).thenReturn(testVXGroupPermission);
VXGroupPermission retVXGroupPermission = xUserRest.createXGroupPermission(testVXGroupPermission);
Mockito.verify(xUserMgr).createXGroupPermission(testVXGroupPermission);
Mockito.verify(xUserMgr).checkAdminAccess();
assertNotNull(retVXGroupPermission);
assertEquals(retVXGroupPermission.getId(), testVXGroupPermission.getId());
assertEquals(retVXGroupPermission.getClass(), testVXGroupPermission.getClass());
}
use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestXUserREST method createVXGroupPermission.
private VXGroupPermission createVXGroupPermission() {
VXGroupPermission testVXGroupPermission = new VXGroupPermission();
testVXGroupPermission.setCreateDate(new Date());
testVXGroupPermission.setGroupId(id);
testVXGroupPermission.setGroupName("testVXGroup");
testVXGroupPermission.setId(id);
testVXGroupPermission.setIsAllowed(1);
testVXGroupPermission.setModuleId(id);
testVXGroupPermission.setModuleName("testModule");
testVXGroupPermission.setOwner("Admin");
testVXGroupPermission.setUpdateDate(new Date());
testVXGroupPermission.setUpdatedBy("Admin");
return testVXGroupPermission;
}
use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestUserMgr method test33setUserRoles.
@Test
public void test33setUserRoles() {
setup();
XXPortalUserRoleDao xPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class);
XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class);
XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class);
VXPortalUser userProfile = userProfile();
XXPortalUser user = new XXPortalUser();
user.setEmailAddress(userProfile.getEmailAddress());
user.setFirstName(userProfile.getFirstName());
user.setLastName(userProfile.getLastName());
user.setLoginId(userProfile.getLoginId());
user.setPassword(userProfile.getPassword());
user.setUserSource(userProfile.getUserSource());
user.setPublicScreenName(userProfile.getPublicScreenName());
user.setId(userProfile.getId());
List<VXString> vStringRolesList = new ArrayList<VXString>();
VXString vXStringObj = new VXString();
vXStringObj.setValue("ROLE_USER");
vStringRolesList.add(vXStringObj);
List<XXPortalUserRole> xPortalUserRoleList = new ArrayList<XXPortalUserRole>();
XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
XXPortalUserRole.setId(userId);
XXPortalUserRole.setUserId(userId);
XXPortalUserRole.setUserRole("ROLE_USER");
xPortalUserRoleList.add(XXPortalUserRole);
List<XXUserPermission> xUserPermissionsList = new ArrayList<XXUserPermission>();
XXUserPermission xUserPermissionObj = new XXUserPermission();
xUserPermissionObj.setAddedByUserId(userId);
xUserPermissionObj.setCreateTime(new Date());
xUserPermissionObj.setId(userId);
xUserPermissionObj.setIsAllowed(1);
xUserPermissionObj.setModuleId(1L);
xUserPermissionObj.setUpdatedByUserId(userId);
xUserPermissionObj.setUpdateTime(new Date());
xUserPermissionObj.setUserId(userId);
xUserPermissionsList.add(xUserPermissionObj);
List<XXGroupPermission> xGroupPermissionList = new ArrayList<XXGroupPermission>();
XXGroupPermission xGroupPermissionObj = new XXGroupPermission();
xGroupPermissionObj.setAddedByUserId(userId);
xGroupPermissionObj.setCreateTime(new Date());
xGroupPermissionObj.setId(userId);
xGroupPermissionObj.setIsAllowed(1);
xGroupPermissionObj.setModuleId(1L);
xGroupPermissionObj.setUpdatedByUserId(userId);
xGroupPermissionObj.setUpdateTime(new Date());
xGroupPermissionObj.setGroupId(userId);
xGroupPermissionList.add(xGroupPermissionObj);
List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
VXGroupPermission groupPermission = new VXGroupPermission();
groupPermission.setId(1L);
groupPermission.setIsAllowed(1);
groupPermission.setModuleId(1L);
groupPermission.setGroupId(userId);
groupPermission.setGroupName("xyz");
groupPermission.setOwner("admin");
groupPermList.add(groupPermission);
XXModuleDef xModuleDef = new XXModuleDef();
xModuleDef.setUpdatedByUserId(userId);
xModuleDef.setAddedByUserId(userId);
xModuleDef.setCreateTime(new Date());
xModuleDef.setId(userId);
xModuleDef.setModule("Policy manager");
xModuleDef.setUpdateTime(new Date());
xModuleDef.setUrl("/policy manager");
VXUserPermission userPermission = new VXUserPermission();
userPermission.setId(1L);
userPermission.setIsAllowed(1);
userPermission.setModuleId(1L);
userPermission.setUserId(userId);
userPermission.setUserName("xyz");
userPermission.setOwner("admin");
Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(xPortalUserRoleDao);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
Mockito.when(userDao.getById(userId)).thenReturn(user);
Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao);
Mockito.when(xUserPermissionDao.findByUserPermissionIdAndIsAllowed(userProfile.getId())).thenReturn(xUserPermissionsList);
Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao);
Mockito.when(xGroupPermissionDao.findbyVXPortalUserId(userProfile.getId())).thenReturn(xGroupPermissionList);
Mockito.when(xGroupPermissionService.populateViewBean(xGroupPermissionObj)).thenReturn(groupPermission);
Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
Mockito.when(xModuleDefDao.findByModuleId(Mockito.anyLong())).thenReturn(xModuleDef);
Mockito.when(xUserPermissionService.populateViewBean(xUserPermissionObj)).thenReturn(userPermission);
Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
Mockito.when(xModuleDefDao.findByModuleId(Mockito.anyLong())).thenReturn(xModuleDef);
Mockito.doNothing().when(rangerBizUtil).blockAuditorRoleUser();
userMgr.checkAccess(userId);
userMgr.setUserRoles(userId, vStringRolesList);
Mockito.verify(daoManager).getXXUserPermission();
Mockito.verify(daoManager).getXXGroupPermission();
Mockito.verify(xGroupPermissionService).populateViewBean(xGroupPermissionObj);
Mockito.verify(xUserPermissionService).populateViewBean(xUserPermissionObj);
}
use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class XGroupPermissionService method getPopulatedVXGroupPermissionList.
public List<VXGroupPermission> getPopulatedVXGroupPermissionList(List<XXGroupPermission> xgroupPermissionList, Map<Long, XXGroup> xXGroupMap, VXModuleDef vModuleDef) {
List<VXGroupPermission> vXGroupPermissionList = new ArrayList<VXGroupPermission>();
XXGroup xXGroup = null;
for (XXGroupPermission xgroupPermission : xgroupPermissionList) {
if (xXGroupMap.containsKey(xgroupPermission.getGroupId())) {
xXGroup = xXGroupMap.get(xgroupPermission.getGroupId());
VXGroupPermission vXGrpPerm = new VXGroupPermission();
vXGrpPerm.setId(xgroupPermission.getId());
vXGrpPerm.setGroupId(xgroupPermission.getGroupId());
vXGrpPerm.setModuleId(xgroupPermission.getModuleId());
vXGrpPerm.setIsAllowed(xgroupPermission.getIsAllowed());
vXGrpPerm.setCreateDate(xgroupPermission.getCreateTime());
vXGrpPerm.setUpdateDate(xgroupPermission.getUpdateTime());
vXGrpPerm.setGroupName(xXGroup.getName());
vXGrpPerm.setModuleName(vModuleDef.getModule());
vXGroupPermissionList.add(vXGrpPerm);
}
}
return vXGroupPermissionList;
}
Aggregations