Search in sources :

Example 6 with VXUserPermission

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

the class TestXUserMgr method vXModuleDef.

private VXModuleDef vXModuleDef() {
    VXUserPermission userPermission = vXUserPermission();
    List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
    userPermList.add(userPermission);
    VXGroupPermission groupPermission = vXGroupPermission();
    List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
    groupPermList.add(groupPermission);
    VXModuleDef vxModuleDef = new VXModuleDef();
    vxModuleDef.setAddedById(userId);
    vxModuleDef.setCreateDate(new Date());
    vxModuleDef.setCreateTime(new Date());
    vxModuleDef.setId(userId);
    vxModuleDef.setModule("Policy manager");
    vxModuleDef.setOwner("admin");
    vxModuleDef.setUpdateDate(new Date());
    vxModuleDef.setUpdatedBy("admin");
    vxModuleDef.setUpdatedById(userId);
    vxModuleDef.setUpdateTime(new Date());
    vxModuleDef.setUrl("/policy manager");
    vxModuleDef.setUserPermList(userPermList);
    vxModuleDef.setGroupPermList(groupPermList);
    return vxModuleDef;
}
Also used : VXGroupPermission(org.apache.ranger.view.VXGroupPermission) VXModuleDef(org.apache.ranger.view.VXModuleDef) ArrayList(java.util.ArrayList) VXUserPermission(org.apache.ranger.view.VXUserPermission) Date(java.util.Date)

Example 7 with VXUserPermission

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

the class TestXUserREST method createVXUserPermission.

private VXUserPermission createVXUserPermission() {
    VXUserPermission testVXUserPermission = new VXUserPermission();
    testVXUserPermission.setCreateDate(new Date());
    testVXUserPermission.setId(id);
    testVXUserPermission.setIsAllowed(1);
    testVXUserPermission.setModuleId(id);
    testVXUserPermission.setModuleName("testModule");
    testVXUserPermission.setOwner("Admin");
    testVXUserPermission.setUpdateDate(new Date());
    testVXUserPermission.setUpdatedBy("Admin");
    testVXUserPermission.setUserId(id);
    testVXUserPermission.setUserName("testVXUser");
    return testVXUserPermission;
}
Also used : VXUserPermission(org.apache.ranger.view.VXUserPermission) Date(java.util.Date)

Example 8 with VXUserPermission

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

the class TestXUserREST method test86searchXUserPermission.

@SuppressWarnings("unchecked")
@Test
public void test86searchXUserPermission() {
    VXUserPermissionList testVXUserPermissionList = new VXUserPermissionList();
    testVXUserPermissionList.setTotalCount(1);
    testVXUserPermissionList.setStartIndex(1);
    VXUserPermission testVXUserPermission = createVXUserPermission();
    List<VXUserPermission> testVXUserPermissions = new ArrayList<VXUserPermission>();
    testVXUserPermissions.add(testVXUserPermission);
    testVXUserPermissionList.setvXModuleDef(testVXUserPermissions);
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "id", "id", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userPermissionList", "userId", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(xUserMgr.searchXUserPermission(testSearchCriteria)).thenReturn(testVXUserPermissionList);
    VXUserPermissionList outputVXUserPermissionList = xUserRest.searchXUserPermission(request);
    assertNotNull(outputVXUserPermissionList);
    assertEquals(outputVXUserPermissionList.getStartIndex(), testVXUserPermissionList.getStartIndex());
    assertEquals(outputVXUserPermissionList.getTotalCount(), testVXUserPermissionList.getTotalCount());
    Mockito.verify(xUserMgr).searchXUserPermission(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "id", "id", StringUtil.VALIDATION_NAME);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userPermissionList", "userId", StringUtil.VALIDATION_NAME);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXUserPermissionList(org.apache.ranger.view.VXUserPermissionList) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXUserPermission(org.apache.ranger.view.VXUserPermission) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 9 with VXUserPermission

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

the class TestXUserREST method createVXModuleDef.

private VXModuleDef createVXModuleDef() {
    VXModuleDef testVXModuleDef = new VXModuleDef();
    testVXModuleDef.setAddedById(id);
    testVXModuleDef.setCreateDate(new Date());
    testVXModuleDef.setCreateTime(new Date());
    VXGroupPermission testVXGroupPermission = createVXGroupPermission();
    List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
    groupPermList.add(testVXGroupPermission);
    testVXModuleDef.setGroupPermList(groupPermList);
    testVXModuleDef.setId(id);
    testVXModuleDef.setModule("testModule");
    testVXModuleDef.setOwner("Admin");
    testVXModuleDef.setUpdateDate(new Date());
    testVXModuleDef.setUpdatedBy("Admin");
    testVXModuleDef.setUpdatedById(id);
    testVXModuleDef.setUpdateTime(new Date());
    testVXModuleDef.setUrl("testUrrl");
    List<VXUserPermission> userPermList = new ArrayList<VXUserPermission>();
    VXUserPermission testVXUserPermission = createVXUserPermission();
    userPermList.add(testVXUserPermission);
    testVXModuleDef.setUserPermList(userPermList);
    return testVXModuleDef;
}
Also used : VXGroupPermission(org.apache.ranger.view.VXGroupPermission) VXModuleDef(org.apache.ranger.view.VXModuleDef) ArrayList(java.util.ArrayList) Date(java.util.Date) VXUserPermission(org.apache.ranger.view.VXUserPermission)

Example 10 with VXUserPermission

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

the class TestUserMgr method test33setUserRoles.

@Test
public void test33setUserRoles() {
    setup();
    XXPortalUserRoleDao xPortalUserRoleDao = Mockito.mock(XXPortalUserRoleDao.class);
    XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
    XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class);
    XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class);
    XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class);
    VXPortalUser userProfile = userProfile();
    XXPortalUser user = new XXPortalUser();
    user.setEmailAddress(userProfile.getEmailAddress());
    user.setFirstName(userProfile.getFirstName());
    user.setLastName(userProfile.getLastName());
    user.setLoginId(userProfile.getLoginId());
    user.setPassword(userProfile.getPassword());
    user.setUserSource(userProfile.getUserSource());
    user.setPublicScreenName(userProfile.getPublicScreenName());
    user.setId(userProfile.getId());
    List<VXString> vStringRolesList = new ArrayList<VXString>();
    VXString vXStringObj = new VXString();
    vXStringObj.setValue("ROLE_USER");
    vStringRolesList.add(vXStringObj);
    List<XXPortalUserRole> xPortalUserRoleList = new ArrayList<XXPortalUserRole>();
    XXPortalUserRole XXPortalUserRole = new XXPortalUserRole();
    XXPortalUserRole.setId(userId);
    XXPortalUserRole.setUserId(userId);
    XXPortalUserRole.setUserRole("ROLE_USER");
    xPortalUserRoleList.add(XXPortalUserRole);
    List<XXUserPermission> xUserPermissionsList = new ArrayList<XXUserPermission>();
    XXUserPermission xUserPermissionObj = new XXUserPermission();
    xUserPermissionObj.setAddedByUserId(userId);
    xUserPermissionObj.setCreateTime(new Date());
    xUserPermissionObj.setId(userId);
    xUserPermissionObj.setIsAllowed(1);
    xUserPermissionObj.setModuleId(1L);
    xUserPermissionObj.setUpdatedByUserId(userId);
    xUserPermissionObj.setUpdateTime(new Date());
    xUserPermissionObj.setUserId(userId);
    xUserPermissionsList.add(xUserPermissionObj);
    List<XXGroupPermission> xGroupPermissionList = new ArrayList<XXGroupPermission>();
    XXGroupPermission xGroupPermissionObj = new XXGroupPermission();
    xGroupPermissionObj.setAddedByUserId(userId);
    xGroupPermissionObj.setCreateTime(new Date());
    xGroupPermissionObj.setId(userId);
    xGroupPermissionObj.setIsAllowed(1);
    xGroupPermissionObj.setModuleId(1L);
    xGroupPermissionObj.setUpdatedByUserId(userId);
    xGroupPermissionObj.setUpdateTime(new Date());
    xGroupPermissionObj.setGroupId(userId);
    xGroupPermissionList.add(xGroupPermissionObj);
    List<VXGroupPermission> groupPermList = new ArrayList<VXGroupPermission>();
    VXGroupPermission groupPermission = new VXGroupPermission();
    groupPermission.setId(1L);
    groupPermission.setIsAllowed(1);
    groupPermission.setModuleId(1L);
    groupPermission.setGroupId(userId);
    groupPermission.setGroupName("xyz");
    groupPermission.setOwner("admin");
    groupPermList.add(groupPermission);
    XXModuleDef xModuleDef = new XXModuleDef();
    xModuleDef.setUpdatedByUserId(userId);
    xModuleDef.setAddedByUserId(userId);
    xModuleDef.setCreateTime(new Date());
    xModuleDef.setId(userId);
    xModuleDef.setModule("Policy manager");
    xModuleDef.setUpdateTime(new Date());
    xModuleDef.setUrl("/policy manager");
    VXUserPermission userPermission = new VXUserPermission();
    userPermission.setId(1L);
    userPermission.setIsAllowed(1);
    userPermission.setModuleId(1L);
    userPermission.setUserId(userId);
    userPermission.setUserName("xyz");
    userPermission.setOwner("admin");
    Mockito.when(daoManager.getXXPortalUserRole()).thenReturn(xPortalUserRoleDao);
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
    Mockito.when(userDao.getById(userId)).thenReturn(user);
    Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao);
    Mockito.when(xUserPermissionDao.findByUserPermissionIdAndIsAllowed(userProfile.getId())).thenReturn(xUserPermissionsList);
    Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao);
    Mockito.when(xGroupPermissionDao.findbyVXPortalUserId(userProfile.getId())).thenReturn(xGroupPermissionList);
    Mockito.when(xGroupPermissionService.populateViewBean(xGroupPermissionObj)).thenReturn(groupPermission);
    Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
    Mockito.when(xModuleDefDao.findByModuleId(Mockito.anyLong())).thenReturn(xModuleDef);
    Mockito.when(xUserPermissionService.populateViewBean(xUserPermissionObj)).thenReturn(userPermission);
    Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao);
    Mockito.when(xModuleDefDao.findByModuleId(Mockito.anyLong())).thenReturn(xModuleDef);
    Mockito.doNothing().when(rangerBizUtil).blockAuditorRoleUser();
    userMgr.checkAccess(userId);
    userMgr.setUserRoles(userId, vStringRolesList);
    Mockito.verify(daoManager).getXXUserPermission();
    Mockito.verify(daoManager).getXXGroupPermission();
    Mockito.verify(xGroupPermissionService).populateViewBean(xGroupPermissionObj);
    Mockito.verify(xUserPermissionService).populateViewBean(xUserPermissionObj);
}
Also used : XXGroupPermission(org.apache.ranger.entity.XXGroupPermission) XXUserPermissionDao(org.apache.ranger.db.XXUserPermissionDao) XXGroupPermissionDao(org.apache.ranger.db.XXGroupPermissionDao) ArrayList(java.util.ArrayList) XXModuleDefDao(org.apache.ranger.db.XXModuleDefDao) XXUserPermission(org.apache.ranger.entity.XXUserPermission) Date(java.util.Date) VXUserPermission(org.apache.ranger.view.VXUserPermission) VXString(org.apache.ranger.view.VXString) XXPortalUserRoleDao(org.apache.ranger.db.XXPortalUserRoleDao) XXPortalUser(org.apache.ranger.entity.XXPortalUser) XXModuleDef(org.apache.ranger.entity.XXModuleDef) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) VXPortalUser(org.apache.ranger.view.VXPortalUser) XXPortalUserRole(org.apache.ranger.entity.XXPortalUserRole) Test(org.junit.Test)

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