use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class TestXUserMgr method test82updateXgroupUserForGroupUpdate.
@Test
public void test82updateXgroupUserForGroupUpdate() {
setup();
XXGroupUserDao xxGroupUserDao = Mockito.mock(XXGroupUserDao.class);
VXGroup vXGroup = vxGroup();
List<XXGroupUser> xXGroupUserList = new ArrayList<XXGroupUser>();
VXGroupUser vxGroupUser = vxGroupUser();
XXGroupUser xXGroupUser = new XXGroupUser();
xXGroupUser.setId(vxGroupUser.getId());
xXGroupUser.setName(vxGroupUser.getName());
xXGroupUser.setParentGroupId(vxGroupUser.getParentGroupId());
xXGroupUser.setUserId(vxGroupUser.getUserId());
xXGroupUserList.add(xXGroupUser);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupUserDao);
Mockito.when(xxGroupUserDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupUserList);
Mockito.when(xGroupUserService.populateViewBean(xXGroupUser)).thenReturn(vxGroupUser);
xUserMgr.updateXgroupUserForGroupUpdate(vXGroup);
Mockito.verify(daoManager).getXXGroupUser();
Mockito.verify(xxGroupUserDao).findByGroupId(vXGroup.getId());
}
use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class TestXUserMgr method test10UpdateXGroup.
@Test
public void test10UpdateXGroup() {
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
XXGroupUserDao xxGroupUserDao = Mockito.mock(XXGroupUserDao.class);
List<XXGroupUser> grpUsers = new ArrayList<XXGroupUser>();
setup();
VXGroup vXGroup = vxGroup();
XXGroup xxGroup = new XXGroup();
xxGroup.setName(groupName);
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupUserDao);
Mockito.when(xxGroupUserDao.findByGroupId(vXGroup.getId())).thenReturn(grpUsers);
VXGroup dbvxGroup = xUserMgr.updateXGroup(vXGroup);
Assert.assertNotNull(dbvxGroup);
userId = dbvxGroup.getId();
Assert.assertEquals(userId, dbvxGroup.getId());
Assert.assertEquals(vXGroup.getDescription(), dbvxGroup.getDescription());
Assert.assertEquals(vXGroup.getName(), dbvxGroup.getName());
Mockito.verify(daoManager).getXXGroup();
Mockito.verify(daoManager).getXXGroupUser();
Mockito.verify(xGroupService).updateResource(vXGroup);
Mockito.verify(xxGroupUserDao).findByGroupId(vXGroup.getId());
Mockito.when(restErrorUtil.createRESTException("group name updates are not allowed.", MessageEnums.INVALID_INPUT_DATA)).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
vXGroup.setName("UnknownGroup");
xUserMgr.updateXGroup(vXGroup);
}
use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class XUserMgr method createXGroupPermission.
// Group permission
public VXGroupPermission createXGroupPermission(VXGroupPermission vXGroupPermission) {
vXGroupPermission = xGroupPermissionService.createResource(vXGroupPermission);
List<XXGroupUser> grpUsers = daoManager.getXXGroupUser().findByGroupId(vXGroupPermission.getGroupId());
for (XXGroupUser xGrpUser : grpUsers) {
Set<UserSessionBase> userSessions = sessionMgr.getActiveUserSessionsForXUserId(xGrpUser.getUserId());
if (!CollectionUtils.isEmpty(userSessions)) {
for (UserSessionBase userSession : userSessions) {
logger.info("Assigning permission to group, one of the user belongs to that group found logged in into system, so updating permission in session of that user");
sessionMgr.resetUserModulePermission(userSession);
}
}
}
return vXGroupPermission;
}
use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class XUserMgr method updateXgroupUserForGroupUpdate.
protected void updateXgroupUserForGroupUpdate(VXGroup vXGroup) {
List<XXGroupUser> grpUsers = daoManager.getXXGroupUser().findByGroupId(vXGroup.getId());
if (CollectionUtils.isNotEmpty(grpUsers)) {
for (XXGroupUser grpUser : grpUsers) {
VXGroupUser vXGroupUser = xGroupUserService.populateViewBean(grpUser);
vXGroupUser.setName(vXGroup.getName());
updateXGroupUser(vXGroupUser);
}
}
}
use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class XUserMgr method updateXGroupPermission.
public VXGroupPermission updateXGroupPermission(VXGroupPermission vXGroupPermission) {
vXGroupPermission = xGroupPermissionService.updateResource(vXGroupPermission);
List<XXGroupUser> grpUsers = daoManager.getXXGroupUser().findByGroupId(vXGroupPermission.getGroupId());
for (XXGroupUser xGrpUser : grpUsers) {
Set<UserSessionBase> userSessions = sessionMgr.getActiveUserSessionsForXUserId(xGrpUser.getUserId());
if (!CollectionUtils.isEmpty(userSessions)) {
for (UserSessionBase userSession : userSessions) {
logger.info("Assigning permission to group whose one of the user found logged in into system, so updating permission in session of that user");
sessionMgr.resetUserModulePermission(userSession);
}
}
}
return vXGroupPermission;
}
Aggregations