Search in sources :

Example 1 with VXGroupUser

use of org.apache.ranger.view.VXGroupUser 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 2 with VXGroupUser

use of org.apache.ranger.view.VXGroupUser 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 3 with VXGroupUser

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

the class TestXUserREST method test27createXGroupUser.

@Test
public void test27createXGroupUser() {
    VXGroupUser testVXGroupUser = createVXGroupUser();
    Mockito.when(xUserMgr.createXGroupUser(testVXGroupUser)).thenReturn(testVXGroupUser);
    VXGroupUser retVxGroupUser = xUserRest.createXGroupUser(testVXGroupUser);
    assertNotNull(retVxGroupUser);
    assertEquals(testVXGroupUser.getClass(), retVxGroupUser.getClass());
    assertEquals(testVXGroupUser.getId(), retVxGroupUser.getId());
    Mockito.verify(xUserMgr).createXGroupUser(testVXGroupUser);
}
Also used : VXGroupUser(org.apache.ranger.view.VXGroupUser) Test(org.junit.Test)

Example 4 with VXGroupUser

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

the class TestXUserREST method test26getXGroupUser.

@Test
public void test26getXGroupUser() {
    VXGroupUser testVXGroupUser = createVXGroupUser();
    Mockito.when(xUserMgr.getXGroupUser(id)).thenReturn(testVXGroupUser);
    VXGroupUser retVxGroupUser = xUserRest.getXGroupUser(id);
    assertNotNull(retVxGroupUser);
    assertEquals(testVXGroupUser.getClass(), retVxGroupUser.getClass());
    assertEquals(testVXGroupUser.getId(), retVxGroupUser.getId());
    Mockito.verify(xUserMgr).getXGroupUser(id);
}
Also used : VXGroupUser(org.apache.ranger.view.VXGroupUser) Test(org.junit.Test)

Example 5 with VXGroupUser

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

the class TestXUserREST method createVXGroupUser.

private VXGroupUser createVXGroupUser() {
    VXGroupUser testVXGroupUser = new VXGroupUser();
    testVXGroupUser.setId(id);
    testVXGroupUser.setCreateDate(new Date());
    testVXGroupUser.setUpdateDate(new Date());
    testVXGroupUser.setOwner("Admin");
    testVXGroupUser.setUpdatedBy("Admin");
    testVXGroupUser.setName("finance");
    testVXGroupUser.setParentGroupId(id);
    testVXGroupUser.setUserId(id);
    return testVXGroupUser;
}
Also used : VXGroupUser(org.apache.ranger.view.VXGroupUser) Date(java.util.Date)

Aggregations

VXGroupUser (org.apache.ranger.view.VXGroupUser)11 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)5 VXGroupUserList (org.apache.ranger.view.VXGroupUserList)4 VXGroup (org.apache.ranger.view.VXGroup)3 XXAuditMapDao (org.apache.ranger.db.XXAuditMapDao)2 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)2 XXPermMapDao (org.apache.ranger.db.XXPermMapDao)2 XXPolicyDao (org.apache.ranger.db.XXPolicyDao)2 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)2 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)2 XXPolicy (org.apache.ranger.entity.XXPolicy)2 XXPortalUser (org.apache.ranger.entity.XXPortalUser)2 VXAuditMapList (org.apache.ranger.view.VXAuditMapList)2 VXPermMapList (org.apache.ranger.view.VXPermMapList)2 VXUser (org.apache.ranger.view.VXUser)2 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 SortField (org.apache.ranger.common.SortField)1