Search in sources :

Example 21 with VXUserPermission

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

the class TestXUserMgr method test37updateXUserPermission.

@Test
public void test37updateXUserPermission() {
    VXUserPermission vXUserPermission = vXUserPermission();
    Mockito.when(xUserPermissionService.updateResource(vXUserPermission)).thenReturn(vXUserPermission);
    VXUserPermission dbUserPermission = xUserMgr.updateXUserPermission(vXUserPermission);
    Assert.assertNotNull(dbUserPermission);
    Assert.assertEquals(dbUserPermission, vXUserPermission);
    Assert.assertEquals(dbUserPermission.getId(), vXUserPermission.getId());
    Assert.assertEquals(dbUserPermission.getOwner(), vXUserPermission.getOwner());
    Assert.assertEquals(dbUserPermission.getUpdatedBy(), vXUserPermission.getUpdatedBy());
    Assert.assertEquals(dbUserPermission.getUserName(), vXUserPermission.getUserName());
    Assert.assertEquals(dbUserPermission.getCreateDate(), vXUserPermission.getCreateDate());
    Assert.assertEquals(dbUserPermission.getIsAllowed(), vXUserPermission.getIsAllowed());
    Assert.assertEquals(dbUserPermission.getModuleId(), vXUserPermission.getModuleId());
    Assert.assertEquals(dbUserPermission.getUpdateDate(), vXUserPermission.getUpdateDate());
    Assert.assertEquals(dbUserPermission.getUserId(), vXUserPermission.getUserId());
    Mockito.verify(xUserPermissionService).updateResource(vXUserPermission);
}
Also used : VXUserPermission(org.apache.ranger.view.VXUserPermission) Test(org.junit.Test)

Example 22 with VXUserPermission

use of org.apache.ranger.view.VXUserPermission 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)

Example 23 with VXUserPermission

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

the class TestXUserMgr method test35createXUserPermission.

@Test
public void test35createXUserPermission() {
    VXUserPermission vXUserPermission = vXUserPermission();
    Mockito.when(xUserPermissionService.createResource(vXUserPermission)).thenReturn(vXUserPermission);
    VXUserPermission dbUserPermission = xUserMgr.createXUserPermission(vXUserPermission);
    Assert.assertNotNull(dbUserPermission);
    Assert.assertEquals(dbUserPermission, vXUserPermission);
    Assert.assertEquals(dbUserPermission.getId(), vXUserPermission.getId());
    Assert.assertEquals(dbUserPermission.getOwner(), vXUserPermission.getOwner());
    Assert.assertEquals(dbUserPermission.getUpdatedBy(), vXUserPermission.getUpdatedBy());
    Assert.assertEquals(dbUserPermission.getUserName(), vXUserPermission.getUserName());
    Assert.assertEquals(dbUserPermission.getCreateDate(), vXUserPermission.getCreateDate());
    Assert.assertEquals(dbUserPermission.getIsAllowed(), vXUserPermission.getIsAllowed());
    Assert.assertEquals(dbUserPermission.getModuleId(), vXUserPermission.getModuleId());
    Assert.assertEquals(dbUserPermission.getUpdateDate(), vXUserPermission.getUpdateDate());
    Assert.assertEquals(dbUserPermission.getUserId(), vXUserPermission.getUserId());
    Mockito.verify(xUserPermissionService).createResource(vXUserPermission);
}
Also used : VXUserPermission(org.apache.ranger.view.VXUserPermission) Test(org.junit.Test)

Example 24 with VXUserPermission

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

the class TestXUserMgr method test36getXUserPermission.

@Test
public void test36getXUserPermission() {
    VXUserPermission vXUserPermission = vXUserPermission();
    Mockito.when(xUserPermissionService.readResource(1L)).thenReturn(vXUserPermission);
    VXUserPermission dbUserPermission = xUserMgr.getXUserPermission(1L);
    Assert.assertNotNull(dbUserPermission);
    Assert.assertEquals(dbUserPermission, vXUserPermission);
    Assert.assertEquals(dbUserPermission.getId(), vXUserPermission.getId());
    Assert.assertEquals(dbUserPermission.getOwner(), vXUserPermission.getOwner());
    Assert.assertEquals(dbUserPermission.getUpdatedBy(), vXUserPermission.getUpdatedBy());
    Assert.assertEquals(dbUserPermission.getUserName(), vXUserPermission.getUserName());
    Assert.assertEquals(dbUserPermission.getCreateDate(), vXUserPermission.getCreateDate());
    Assert.assertEquals(dbUserPermission.getIsAllowed(), vXUserPermission.getIsAllowed());
    Assert.assertEquals(dbUserPermission.getModuleId(), vXUserPermission.getModuleId());
    Assert.assertEquals(dbUserPermission.getUpdateDate(), vXUserPermission.getUpdateDate());
    Assert.assertEquals(dbUserPermission.getUserId(), vXUserPermission.getUserId());
    Mockito.verify(xUserPermissionService).readResource(1L);
}
Also used : VXUserPermission(org.apache.ranger.view.VXUserPermission) Test(org.junit.Test)

Example 25 with VXUserPermission

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

the class XUserPermissionService method populateViewBean.

@Override
public VXUserPermission populateViewBean(XXUserPermission xObj) {
    VXUserPermission vObj = super.populateViewBean(xObj);
    XXPortalUser xPortalUser = daoManager.getXXPortalUser().getById(xObj.getUserId());
    if (xPortalUser != null) {
        vObj.setUserName(xPortalUser.getLoginId());
    }
    XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(xObj.getModuleId());
    if (xModuleDef != null) {
        vObj.setModuleName(xModuleDef.getModule());
    }
    return vObj;
}
Also used : XXPortalUser(org.apache.ranger.entity.XXPortalUser) XXModuleDef(org.apache.ranger.entity.XXModuleDef) VXUserPermission(org.apache.ranger.view.VXUserPermission)

Aggregations

VXUserPermission (org.apache.ranger.view.VXUserPermission)26 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)16 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)14 Date (java.util.Date)12 XXUserPermission (org.apache.ranger.entity.XXUserPermission)12 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)11 XXModuleDef (org.apache.ranger.entity.XXModuleDef)11 XXPortalUser (org.apache.ranger.entity.XXPortalUser)10 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)10 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)9 VXPortalUser (org.apache.ranger.view.VXPortalUser)9 VXString (org.apache.ranger.view.VXString)9 XXGroupPermissionDao (org.apache.ranger.db.XXGroupPermissionDao)6 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)6 XXUserPermissionDao (org.apache.ranger.db.XXUserPermissionDao)6 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)5 VXModuleDef (org.apache.ranger.view.VXModuleDef)4 VXStringList (org.apache.ranger.view.VXStringList)4 VXPasswordChange (org.apache.ranger.view.VXPasswordChange)3