use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestXUserMgr method test47getUserRolesByExternalID.
@Test
public void test47getUserRolesByExternalID() {
setup();
XXPortalUserRoleDao xPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class);
VXUser vXUser = vxUser();
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(xPortalUserRoleDao.findByUserId(userId)).thenReturn(xPortalUserRoleList);
Mockito.when(xUserMgr.getXUser(userId)).thenReturn(vXUser);
Mockito.when(userMgr.getUserProfileByLoginId(vXUser.getName())).thenReturn(userProfile);
VXStringList vXStringList = xUserMgr.getUserRolesByExternalID(userId);
Assert.assertNotNull(vXStringList);
}
use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestXUserMgr method test41updateXGroupPermission.
@Test
public void test41updateXGroupPermission() {
VXGroupPermission vXGroupPermission = vXGroupPermission();
XXGroupUserDao xGrpUserDao = Mockito.mock(XXGroupUserDao.class);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGrpUserDao);
Mockito.when(xGroupPermissionService.updateResource(vXGroupPermission)).thenReturn(vXGroupPermission);
VXGroupPermission dbGroupPermission = xUserMgr.updateXGroupPermission(vXGroupPermission);
Assert.assertNotNull(dbGroupPermission);
Assert.assertEquals(dbGroupPermission, vXGroupPermission);
Assert.assertEquals(dbGroupPermission.getId(), vXGroupPermission.getId());
Assert.assertEquals(dbGroupPermission.getGroupName(), vXGroupPermission.getGroupName());
Assert.assertEquals(dbGroupPermission.getOwner(), vXGroupPermission.getOwner());
Assert.assertEquals(dbGroupPermission.getUpdatedBy(), vXGroupPermission.getUpdatedBy());
Assert.assertEquals(dbGroupPermission.getCreateDate(), vXGroupPermission.getCreateDate());
Assert.assertEquals(dbGroupPermission.getGroupId(), vXGroupPermission.getGroupId());
Assert.assertEquals(dbGroupPermission.getIsAllowed(), vXGroupPermission.getIsAllowed());
Assert.assertEquals(dbGroupPermission.getModuleId(), vXGroupPermission.getModuleId());
Assert.assertEquals(dbGroupPermission.getUpdateDate(), vXGroupPermission.getUpdateDate());
Mockito.verify(xGroupPermissionService).updateResource(vXGroupPermission);
}
use of org.apache.ranger.view.VXGroupPermission 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;
}
use of org.apache.ranger.view.VXGroupPermission 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;
}
use of org.apache.ranger.view.VXGroupPermission in project ranger by apache.
the class TestXUserREST method test89getXGroupPermission.
@Test
public void test89getXGroupPermission() {
VXGroupPermission testVXGroupPermission = createVXGroupPermission();
Mockito.when(xUserMgr.getXGroupPermission(testVXGroupPermission.getId())).thenReturn(testVXGroupPermission);
VXGroupPermission retVXGroupPermission = xUserRest.getXGroupPermission(testVXGroupPermission.getId());
Mockito.verify(xUserMgr).getXGroupPermission(testVXGroupPermission.getId());
assertNotNull(retVXGroupPermission);
assertEquals(retVXGroupPermission.getId(), testVXGroupPermission.getId());
assertEquals(retVXGroupPermission.getClass(), testVXGroupPermission.getClass());
}
Aggregations