Search in sources :

Example 1 with VXGroup

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

the class TestXUserMgr method test26CreateXGroupWithoutLogin.

@Test
public void test26CreateXGroupWithoutLogin() {
    setup();
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    Mockito.when(xGroupService.createXGroupWithOutLogin(vXGroup)).thenReturn(vXGroup);
    VXGroup dbVXGroup = xUserMgr.createXGroupWithoutLogin(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(xGroupService).createXGroupWithOutLogin(vXGroup);
}
Also used : VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Example 2 with VXGroup

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

the class TestXUserMgr method test21createXGroupUser.

@Test
public void test21createXGroupUser() {
    setup();
    VXGroupUser vxGroupUser = new VXGroupUser();
    vxGroupUser.setId(userId);
    vxGroupUser.setName("group user test");
    vxGroupUser.setOwner("Admin");
    vxGroupUser.setUserId(userId);
    vxGroupUser.setUpdatedBy("User");
    Mockito.when(xGroupUserService.createXGroupUserWithOutLogin(vxGroupUser)).thenReturn(vxGroupUser);
    VXGroupUser dbVXGroupUser = xUserMgr.createXGroupUser(vxGroupUser);
    Assert.assertNotNull(dbVXGroupUser);
    userId = dbVXGroupUser.getId();
    Assert.assertEquals(userId, dbVXGroupUser.getId());
    Assert.assertEquals(dbVXGroupUser.getOwner(), vxGroupUser.getOwner());
    Assert.assertEquals(dbVXGroupUser.getName(), vxGroupUser.getName());
    Assert.assertEquals(dbVXGroupUser.getUserId(), vxGroupUser.getUserId());
    Assert.assertEquals(dbVXGroupUser.getUpdatedBy(), vxGroupUser.getUpdatedBy());
    Mockito.verify(xGroupUserService).createXGroupUserWithOutLogin(vxGroupUser);
    Mockito.when(xGroupUserService.readResourceWithOutLogin(userId)).thenReturn(vxGroupUser);
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    VXGroupUser dbvxGroupUser = xUserMgr.getXGroupUser(userId);
    Assert.assertNotNull(dbvxGroupUser);
    userId = dbvxGroupUser.getId();
    Assert.assertEquals(userId, dbvxGroupUser.getId());
    Assert.assertEquals(dbvxGroupUser.getOwner(), vxGroupUser.getOwner());
    Assert.assertEquals(dbvxGroupUser.getName(), vxGroupUser.getName());
    Assert.assertEquals(dbvxGroupUser.getUserId(), vxGroupUser.getUserId());
    Assert.assertEquals(dbvxGroupUser.getUpdatedBy(), vxGroupUser.getUpdatedBy());
    Mockito.verify(xGroupUserService).readResourceWithOutLogin(userId);
}
Also used : VXGroupUser(org.apache.ranger.view.VXGroupUser) VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Example 3 with VXGroup

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

the class TestXUserMgr method test18ModifyGroupsVisibilitySetOne.

@Test
public void test18ModifyGroupsVisibilitySetOne() {
    XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    XXGroup xxGroup = new XXGroup();
    HashMap<Long, Integer> groupVisibilityMap = new HashMap<Long, Integer>();
    Integer value = 1;
    groupVisibilityMap.put(userId, value);
    Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
    Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
    Mockito.when(xGroupService.populateViewBean(xxGroup)).thenReturn(vXGroup);
    Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
    xUserMgr.modifyGroupsVisibility(groupVisibilityMap);
    Assert.assertEquals(value, vXGroup.getIsVisible());
    Assert.assertEquals(userId, vXGroup.getId());
    Mockito.verify(daoManager).getXXGroup();
    Mockito.verify(xGroupService).populateViewBean(xxGroup);
    Mockito.verify(xGroupService).updateResource(vXGroup);
}
Also used : XXGroup(org.apache.ranger.entity.XXGroup) HashMap(java.util.HashMap) VXGroup(org.apache.ranger.view.VXGroup) XXGroupDao(org.apache.ranger.db.XXGroupDao) Test(org.junit.Test)

Example 4 with VXGroup

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

the class TestXUserMgr method test27DeleteXGroup.

@Test
public void test27DeleteXGroup() {
    setup();
    boolean force = true;
    VXGroup vXGroup = new VXGroup();
    vXGroup.setId(userId);
    vXGroup.setDescription("group test");
    vXGroup.setName("grouptest");
    // XXGroup
    XXGroupDao xXGroupDao = Mockito.mock(XXGroupDao.class);
    XXGroup xXGroup = new XXGroup();
    Mockito.when(daoManager.getXXGroup()).thenReturn(xXGroupDao);
    Mockito.when(xXGroupDao.getById(vXGroup.getId())).thenReturn(xXGroup);
    Mockito.when(xGroupService.populateViewBean(xXGroup)).thenReturn(vXGroup);
    // VXGroupUser
    VXGroupUserList vxGroupUserList = new VXGroupUserList();
    XXGroupUserDao xGroupUserDao = Mockito.mock(XXGroupUserDao.class);
    VXGroupUser vxGroupUser = new VXGroupUser();
    vxGroupUser.setId(userId);
    vxGroupUser.setName("group user test");
    vxGroupUser.setOwner("Admin");
    vxGroupUser.setUserId(userId);
    vxGroupUser.setUpdatedBy("User");
    Mockito.when(xGroupUserService.searchXGroupUsers((SearchCriteria) Mockito.any())).thenReturn(vxGroupUserList);
    Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGroupUserDao);
    // VXPermMap
    VXPermMapList vXPermMapList = new VXPermMapList();
    XXPermMapDao xXPermMapDao = Mockito.mock(XXPermMapDao.class);
    Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(vXPermMapList);
    Mockito.when(daoManager.getXXPermMap()).thenReturn(xXPermMapDao);
    // VXAuditMap
    VXAuditMapList vXAuditMapList = new VXAuditMapList();
    XXAuditMapDao xXAuditMapDao = Mockito.mock(XXAuditMapDao.class);
    Mockito.when(xAuditMapService.searchXAuditMaps((SearchCriteria) Mockito.any())).thenReturn(vXAuditMapList);
    Mockito.when(daoManager.getXXAuditMap()).thenReturn(xXAuditMapDao);
    // XXGroupGroup
    XXGroupGroupDao xXGroupGroupDao = Mockito.mock(XXGroupGroupDao.class);
    List<XXGroupGroup> xXGroupGroups = new ArrayList<XXGroupGroup>();
    Mockito.when(daoManager.getXXGroupGroup()).thenReturn(xXGroupGroupDao);
    Mockito.when(xXGroupGroupDao.findByGroupId(userId)).thenReturn(xXGroupGroups);
    // update XXGroupPermission
    XXGroupPermissionDao xXGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
    Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xXGroupPermissionDao);
    List<XXGroupPermission> xXGroupPermissions = new ArrayList<XXGroupPermission>();
    Mockito.when(xXGroupPermissionDao.findByGroupId(vXGroup.getId())).thenReturn(xXGroupPermissions);
    // update XXPolicyItemUserPerm
    XXPolicyDao xXPolicyDao = Mockito.mock(XXPolicyDao.class);
    List<XXPolicy> xXPolicyList = new ArrayList<XXPolicy>();
    Mockito.when(daoManager.getXXPolicy()).thenReturn(xXPolicyDao);
    Mockito.when(xXPolicyDao.findByGroupId(userId)).thenReturn(xXPolicyList);
    xUserMgr.deleteXGroup(vXGroup.getId(), force);
    Mockito.verify(xGroupUserService).searchXGroupUsers((SearchCriteria) Mockito.any());
}
Also used : VXGroupUserList(org.apache.ranger.view.VXGroupUserList) XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) XXAuditMapDao(org.apache.ranger.db.XXAuditMapDao) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) ArrayList(java.util.ArrayList) VXGroupUser(org.apache.ranger.view.VXGroupUser) VXAuditMapList(org.apache.ranger.view.VXAuditMapList) XXPolicy(org.apache.ranger.entity.XXPolicy) XXGroupUserDao(org.apache.ranger.db.XXGroupUserDao) XXGroup(org.apache.ranger.entity.XXGroup) XXPermMapDao(org.apache.ranger.db.XXPermMapDao) XXPolicyDao(org.apache.ranger.db.XXPolicyDao) VXPermMapList(org.apache.ranger.view.VXPermMapList) VXGroup(org.apache.ranger.view.VXGroup) XXGroupGroupDao(org.apache.ranger.db.XXGroupGroupDao) XXGroupDao(org.apache.ranger.db.XXGroupDao) XXGroupGroup(org.apache.ranger.entity.XXGroupGroup) Test(org.junit.Test)

Example 5 with VXGroup

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

the class TestXUserREST method test3createXGroup.

@Test
public void test3createXGroup() {
    VXGroup compareTestVXGroup = createVXGroup();
    Mockito.when(xUserMgr.createXGroupWithoutLogin(compareTestVXGroup)).thenReturn(compareTestVXGroup);
    VXGroup retVxGroup = xUserRest.createXGroup(compareTestVXGroup);
    assertNotNull(retVxGroup);
    assertEquals(compareTestVXGroup.getId(), retVxGroup.getId());
    assertEquals(compareTestVXGroup.getName(), retVxGroup.getName());
    Mockito.verify(xUserMgr).createXGroupWithoutLogin(compareTestVXGroup);
}
Also used : VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Aggregations

VXGroup (org.apache.ranger.view.VXGroup)32 Test (org.junit.Test)26 VXString (org.apache.ranger.view.VXString)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 XXGroup (org.apache.ranger.entity.XXGroup)7 ArrayList (java.util.ArrayList)5 XXGroupDao (org.apache.ranger.db.XXGroupDao)5 VXStringList (org.apache.ranger.view.VXStringList)4 HashMap (java.util.HashMap)3 VXGroupUser (org.apache.ranger.view.VXGroupUser)3 VXUser (org.apache.ranger.view.VXUser)3 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)2 VXGroupList (org.apache.ranger.view.VXGroupList)2 VXGroupUserList (org.apache.ranger.view.VXGroupUserList)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 UserSessionBase (org.apache.ranger.common.UserSessionBase)1 XXAuditMapDao (org.apache.ranger.db.XXAuditMapDao)1