Search in sources :

Example 11 with XXGroupPermissionDao

use of org.apache.ranger.db.XXGroupPermissionDao in project ranger by apache.

the class TestXUserMgr method test42deleteXGroupPermission.

@Test
public void test42deleteXGroupPermission() {
    XXGroupPermissionDao xGrpPermDao = Mockito.mock(XXGroupPermissionDao.class);
    XXGroupPermission xGrpPerm = Mockito.mock(XXGroupPermission.class);
    Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGrpPermDao);
    Mockito.when(daoManager.getXXGroupPermission().getById(1L)).thenReturn(xGrpPerm);
    XXGroupUserDao xGrpUserDao = Mockito.mock(XXGroupUserDao.class);
    Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGrpUserDao);
    Mockito.when(xGroupPermissionService.deleteResource(1L)).thenReturn(true);
    xUserMgr.deleteXGroupPermission(1L, true);
    Mockito.verify(xGroupPermissionService).deleteResource(1L);
}
Also used : XXGroupUserDao(org.apache.ranger.db.XXGroupUserDao) XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) Test(org.junit.Test)

Example 12 with XXGroupPermissionDao

use of org.apache.ranger.db.XXGroupPermissionDao in project ranger by apache.

the class TestXUserMgr method test33updateXModuleDefPermission.

@Test
public void test33updateXModuleDefPermission() {
    XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class);
    XXModuleDef xModuleDef = Mockito.mock(XXModuleDef.class);
    XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class);
    XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
    VXUserPermission vXUserPermission = vXUserPermission();
    VXGroupPermission vXGroupPermission = vXGroupPermission();
    VXModuleDef vXModuleDef = vXModuleDef();
    Mockito.when(xModuleDefService.updateResource(vXModuleDef)).thenReturn(vXModuleDef);
    Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
    Mockito.when(xModuleDefDao.getById(userId)).thenReturn(xModuleDef);
    Mockito.when(xModuleDefService.populateViewBean(xModuleDef)).thenReturn(vXModuleDef);
    Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao);
    Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao);
    XXGroupUserDao xGrpUserDao = Mockito.mock(XXGroupUserDao.class);
    Mockito.when(daoManager.getXXGroupUser()).thenReturn(xGrpUserDao);
    UserSessionBase userSession = Mockito.mock(UserSessionBase.class);
    Set<UserSessionBase> userSessions = new HashSet<UserSessionBase>();
    userSessions.add(userSession);
    Mockito.when(xGroupPermissionService.createResource((VXGroupPermission) Mockito.any())).thenReturn(vXGroupPermission);
    Mockito.when(xUserPermissionService.createResource((VXUserPermission) Mockito.any())).thenReturn(vXUserPermission);
    Mockito.when(sessionMgr.getActiveUserSessionsForPortalUserId(userId)).thenReturn(userSessions);
    VXModuleDef dbMuduleDef = xUserMgr.updateXModuleDefPermission(vXModuleDef);
    Assert.assertEquals(dbMuduleDef, vXModuleDef);
    Assert.assertNotNull(dbMuduleDef);
    Assert.assertEquals(dbMuduleDef, vXModuleDef);
    Assert.assertEquals(dbMuduleDef.getId(), vXModuleDef.getId());
    Assert.assertEquals(dbMuduleDef.getOwner(), vXModuleDef.getOwner());
    Assert.assertEquals(dbMuduleDef.getUpdatedBy(), vXModuleDef.getUpdatedBy());
    Assert.assertEquals(dbMuduleDef.getUrl(), vXModuleDef.getUrl());
    Assert.assertEquals(dbMuduleDef.getAddedById(), vXModuleDef.getAddedById());
    Assert.assertEquals(dbMuduleDef.getCreateDate(), vXModuleDef.getCreateDate());
    Assert.assertEquals(dbMuduleDef.getCreateTime(), vXModuleDef.getCreateTime());
    Assert.assertEquals(dbMuduleDef.getUserPermList(), vXModuleDef.getUserPermList());
    Assert.assertEquals(dbMuduleDef.getGroupPermList(), vXModuleDef.getGroupPermList());
    Mockito.verify(xModuleDefService).updateResource(vXModuleDef);
    Mockito.verify(daoManager).getXXModuleDef();
    Mockito.verify(xModuleDefService).populateViewBean(xModuleDef);
    Mockito.verify(daoManager).getXXUserPermission();
    Mockito.verify(daoManager).getXXGroupPermission();
}
Also used : XXGroupUserDao(org.apache.ranger.db.XXGroupUserDao) XXModuleDef(org.apache.ranger.entity.XXModuleDef) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) VXModuleDef(org.apache.ranger.view.VXModuleDef) XXUserPermissionDao(org.apache.ranger.db.XXUserPermissionDao) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) XXModuleDefDao(org.apache.ranger.db.XXModuleDefDao) VXUserPermission(org.apache.ranger.view.VXUserPermission) UserSessionBase(org.apache.ranger.common.UserSessionBase) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

XXGroupPermissionDao (org.apache.ranger.db.XXGroupPermissionDao)12 Test (org.junit.Test)11 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)10 XXUserPermissionDao (org.apache.ranger.db.XXUserPermissionDao)9 ArrayList (java.util.ArrayList)8 Date (java.util.Date)7 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)7 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)7 XXModuleDef (org.apache.ranger.entity.XXModuleDef)7 XXPortalUser (org.apache.ranger.entity.XXPortalUser)7 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)7 XXUserPermission (org.apache.ranger.entity.XXUserPermission)7 VXPortalUser (org.apache.ranger.view.VXPortalUser)7 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)6 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)6 VXUserPermission (org.apache.ranger.view.VXUserPermission)5 XXGroupUserDao (org.apache.ranger.db.XXGroupUserDao)4 VXString (org.apache.ranger.view.VXString)4 VXPasswordChange (org.apache.ranger.view.VXPasswordChange)3 XXAuditMapDao (org.apache.ranger.db.XXAuditMapDao)2