use of org.apache.ranger.db.XXPortalUserRoleDao in project ranger by apache.
the class XUserMgr method deleteXUser.
public synchronized void deleteXUser(Long id, boolean force) {
checkAdminAccess();
xaBizUtil.blockAuditorRoleUser();
XXUserDao xXUserDao = daoManager.getXXUser();
XXUser xXUser = xXUserDao.getById(id);
VXUser vXUser = xUserService.populateViewBean(xXUser);
if (vXUser == null || StringUtil.isEmpty(vXUser.getName())) {
throw restErrorUtil.createRESTException("No user found with id=" + id);
}
XXPortalUserDao xXPortalUserDao = daoManager.getXXPortalUser();
XXPortalUser xXPortalUser = xXPortalUserDao.findByLoginId(vXUser.getName().trim());
VXPortalUser vXPortalUser = null;
if (xXPortalUser != null) {
vXPortalUser = xPortalUserService.populateViewBean(xXPortalUser);
}
if (vXPortalUser == null || StringUtil.isEmpty(vXPortalUser.getLoginId())) {
throw restErrorUtil.createRESTException("No user found with id=" + id);
}
if (logger.isDebugEnabled()) {
logger.debug("Force delete status=" + force + " for user=" + vXUser.getName());
}
restrictSelfAccountDeletion(vXUser.getName().trim());
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.addParam("xUserId", id);
VXGroupUserList vxGroupUserList = searchXGroupUsers(searchCriteria);
searchCriteria = new SearchCriteria();
searchCriteria.addParam("userId", id);
VXPermMapList vXPermMapList = searchXPermMaps(searchCriteria);
searchCriteria = new SearchCriteria();
searchCriteria.addParam("userId", id);
VXAuditMapList vXAuditMapList = searchXAuditMaps(searchCriteria);
long xXPortalUserId = 0;
xXPortalUserId = vXPortalUser.getId();
XXAuthSessionDao xXAuthSessionDao = daoManager.getXXAuthSession();
XXUserPermissionDao xXUserPermissionDao = daoManager.getXXUserPermission();
XXPortalUserRoleDao xXPortalUserRoleDao = daoManager.getXXPortalUserRole();
List<XXAuthSession> xXAuthSessions = xXAuthSessionDao.getAuthSessionByUserId(xXPortalUserId);
List<XXUserPermission> xXUserPermissions = xXUserPermissionDao.findByUserPermissionId(xXPortalUserId);
List<XXPortalUserRole> xXPortalUserRoles = xXPortalUserRoleDao.findByUserId(xXPortalUserId);
XXPolicyDao xXPolicyDao = daoManager.getXXPolicy();
List<XXPolicy> xXPolicyList = xXPolicyDao.findByUserId(id);
logger.warn("Deleting User : " + vXUser.getName());
if (force) {
// delete XXGroupUser mapping
XXGroupUserDao xGroupUserDao = daoManager.getXXGroupUser();
for (VXGroupUser groupUser : vxGroupUserList.getList()) {
if (groupUser != null) {
logger.warn("Removing user '" + vXUser.getName() + "' from group '" + groupUser.getName() + "'");
xGroupUserDao.remove(groupUser.getId());
}
}
// delete XXPermMap records of user
XXPermMapDao xXPermMapDao = daoManager.getXXPermMap();
for (VXPermMap vXPermMap : vXPermMapList.getList()) {
if (vXPermMap != null) {
logger.warn("Deleting '" + AppConstants.getLabelFor_XAPermType(vXPermMap.getPermType()) + "' permission from policy ID='" + vXPermMap.getResourceId() + "' for user '" + vXPermMap.getUserName() + "'");
xXPermMapDao.remove(vXPermMap.getId());
}
}
// delete XXAuditMap records of user
XXAuditMapDao xXAuditMapDao = daoManager.getXXAuditMap();
for (VXAuditMap vXAuditMap : vXAuditMapList.getList()) {
if (vXAuditMap != null) {
xXAuditMapDao.remove(vXAuditMap.getId());
}
}
// delete XXPortalUser references
if (vXPortalUser != null) {
xPortalUserService.updateXXPortalUserReferences(xXPortalUserId);
if (xXAuthSessions != null && xXAuthSessions.size() > 0) {
logger.warn("Deleting " + xXAuthSessions.size() + " login session records for user '" + vXPortalUser.getLoginId() + "'");
}
for (XXAuthSession xXAuthSession : xXAuthSessions) {
xXAuthSessionDao.remove(xXAuthSession.getId());
}
for (XXUserPermission xXUserPermission : xXUserPermissions) {
if (xXUserPermission != null) {
XXModuleDef xXModuleDef = daoManager.getXXModuleDef().findByModuleId(xXUserPermission.getModuleId());
if (xXModuleDef != null) {
logger.warn("Deleting '" + xXModuleDef.getModule() + "' module permission for user '" + vXPortalUser.getLoginId() + "'");
}
xXUserPermissionDao.remove(xXUserPermission.getId());
}
}
for (XXPortalUserRole xXPortalUserRole : xXPortalUserRoles) {
if (xXPortalUserRole != null) {
logger.warn("Deleting '" + xXPortalUserRole.getUserRole() + "' role for user '" + vXPortalUser.getLoginId() + "'");
xXPortalUserRoleDao.remove(xXPortalUserRole.getId());
}
}
}
// delete XXPolicyItemUserPerm records of user
for (XXPolicy xXPolicy : xXPolicyList) {
RangerPolicy rangerPolicy = policyService.getPopulatedViewObject(xXPolicy);
List<RangerPolicyItem> policyItems = rangerPolicy.getPolicyItems();
removeUserGroupReferences(policyItems, vXUser.getName(), null);
rangerPolicy.setPolicyItems(policyItems);
List<RangerPolicyItem> denyPolicyItems = rangerPolicy.getDenyPolicyItems();
removeUserGroupReferences(denyPolicyItems, vXUser.getName(), null);
rangerPolicy.setDenyPolicyItems(denyPolicyItems);
List<RangerPolicyItem> allowExceptions = rangerPolicy.getAllowExceptions();
removeUserGroupReferences(allowExceptions, vXUser.getName(), null);
rangerPolicy.setAllowExceptions(allowExceptions);
List<RangerPolicyItem> denyExceptions = rangerPolicy.getDenyExceptions();
removeUserGroupReferences(denyExceptions, vXUser.getName(), null);
rangerPolicy.setDenyExceptions(denyExceptions);
List<RangerDataMaskPolicyItem> dataMaskItems = rangerPolicy.getDataMaskPolicyItems();
removeUserGroupReferences(dataMaskItems, vXUser.getName(), null);
rangerPolicy.setDataMaskPolicyItems(dataMaskItems);
List<RangerRowFilterPolicyItem> rowFilterItems = rangerPolicy.getRowFilterPolicyItems();
removeUserGroupReferences(rowFilterItems, vXUser.getName(), null);
rangerPolicy.setRowFilterPolicyItems(rowFilterItems);
try {
svcStore.updatePolicy(rangerPolicy);
} catch (Throwable excp) {
logger.error("updatePolicy(" + rangerPolicy + ") failed", excp);
throw restErrorUtil.createRESTException(excp.getMessage());
}
}
// delete XXUser entry of user
xXUserDao.remove(id);
// delete XXPortal entry of user
logger.warn("Deleting Portal User : " + vXPortalUser.getLoginId());
xXPortalUserDao.remove(xXPortalUserId);
List<XXTrxLog> trxLogList = xUserService.getTransactionLog(xUserService.populateViewBean(xXUser), "delete");
xaBizUtil.createTrxLog(trxLogList);
if (xXPortalUser != null) {
trxLogList = xPortalUserService.getTransactionLog(xPortalUserService.populateViewBean(xXPortalUser), "delete");
xaBizUtil.createTrxLog(trxLogList);
}
} else {
boolean hasReferences = false;
if (vxGroupUserList != null && vxGroupUserList.getListSize() > 0) {
hasReferences = true;
}
if (hasReferences == false && xXPolicyList != null && xXPolicyList.size() > 0) {
hasReferences = true;
}
if (hasReferences == false && vXPermMapList != null && vXPermMapList.getListSize() > 0) {
hasReferences = true;
}
if (hasReferences == false && vXAuditMapList != null && vXAuditMapList.getListSize() > 0) {
hasReferences = true;
}
if (hasReferences == false && xXAuthSessions != null && xXAuthSessions.size() > 0) {
hasReferences = true;
}
if (hasReferences == false && xXUserPermissions != null && xXUserPermissions.size() > 0) {
hasReferences = true;
}
if (hasReferences == false && xXPortalUserRoles != null && xXPortalUserRoles.size() > 0) {
hasReferences = true;
}
if (hasReferences) {
if (vXUser.getIsVisible() != RangerCommonEnums.IS_HIDDEN) {
logger.info("Updating visibility of user '" + vXUser.getName() + "' to Hidden!");
vXUser.setIsVisible(RangerCommonEnums.IS_HIDDEN);
xUserService.updateResource(vXUser);
}
} else {
xPortalUserService.updateXXPortalUserReferences(xXPortalUserId);
// delete XXUser entry of user
xXUserDao.remove(id);
// delete XXPortal entry of user
logger.warn("Deleting Portal User : " + vXPortalUser.getLoginId());
xXPortalUserDao.remove(xXPortalUserId);
List<XXTrxLog> trxLogList = xUserService.getTransactionLog(xUserService.populateViewBean(xXUser), "delete");
xaBizUtil.createTrxLog(trxLogList);
trxLogList = xPortalUserService.getTransactionLog(xPortalUserService.populateViewBean(xXPortalUser), "delete");
xaBizUtil.createTrxLog(trxLogList);
}
}
}
use of org.apache.ranger.db.XXPortalUserRoleDao in project ranger by apache.
the class TestXUserMgr method test46setUserRolesByName.
@Test
public void test46setUserRolesByName() {
setup();
XXPortalUserRoleDao xPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.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(xPortalUserRoleDao.findByUserId(userId)).thenReturn(xPortalUserRoleList);
Mockito.when(userMgr.getUserProfileByLoginId(userProfile.getLoginId())).thenReturn(userProfile);
VXStringList vXStringList = xUserMgr.setUserRolesByName(userProfile.getLoginId(), vStringRolesList);
Assert.assertNotNull(vXStringList);
}
use of org.apache.ranger.db.XXPortalUserRoleDao in project ranger by apache.
the class TestXUserMgr method test48getUserRolesByName.
@Test
public void test48getUserRolesByName() {
setup();
XXPortalUserRoleDao xPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class);
VXPortalUser userProfile = userProfile();
Collection<String> userRoleList = new ArrayList<String>();
userRoleList.add("ROLE_USER");
userProfile.setUserRoleList(userRoleList);
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(userMgr.getUserProfileByLoginId(userProfile.getLoginId())).thenReturn(userProfile);
VXStringList vXStringList = xUserMgr.getUserRolesByName(userProfile.getLoginId());
Assert.assertNotNull(vXStringList);
}
use of org.apache.ranger.db.XXPortalUserRoleDao in project ranger by apache.
the class TestXUserMgr method test45setUserRolesByExternalID.
@Test
public void test45setUserRolesByExternalID() {
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.setUserRolesByExternalID(userId, vStringRolesList);
Assert.assertNotNull(vXStringList);
}
use of org.apache.ranger.db.XXPortalUserRoleDao 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);
}
Aggregations