Search in sources :

Example 6 with VXUserList

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

the class TestRoleBasedUserSearchUtil method TestValidateUserAndFetchUserList.

@Test
public void TestValidateUserAndFetchUserList() {
    List<String> permissionList = new ArrayList<String>();
    permissionList.add(RangerConstants.MODULE_USER_GROUPS);
    String currentEncryptedPassword = "testpassword";
    XXPortalUser xxPortalUser = new XXPortalUser();
    xxPortalUser.setId(1L);
    xxPortalUser.setLoginId("testUser");
    xxPortalUser.setPassword("testpassword");
    xxPortalUser.setFirstName("testUser");
    VXUser vxUser = new VXUser();
    vxUser.setId(1L);
    VXUserList vXUserList = new VXUserList();
    List<VXUser> vXUsers = new ArrayList<VXUser>();
    vXUsers.add(vxUser);
    vXUserList.setVXUsers(vXUsers);
    List<String> userRoleList = new ArrayList<String>();
    userRoleList.add("ROLE_SYS_ADMIN");
    List<XXPortalUser> listXXPortalUser = new ArrayList<XXPortalUser>();
    listXXPortalUser.add(xxPortalUser);
    vxUser.setUserRoleList(userRoleList);
    XXModuleDefDao xXModuleDefDao = Mockito.mock(XXModuleDefDao.class);
    Mockito.when(daoMgr.getXXPortalUser()).thenReturn(xXPortalUserDao);
    Mockito.when(xXPortalUserDao.findByLoginId(Mockito.anyString())).thenReturn(xxPortalUser);
    Mockito.when(xUserService.getXUserByUserName(xxPortalUser.getLoginId())).thenReturn(vxUser);
    Mockito.when(daoMgr.getXXModuleDef()).thenReturn(xXModuleDefDao);
    Mockito.when(xXModuleDefDao.findAccessibleModulesByUserId(Mockito.anyLong(), Mockito.anyLong())).thenReturn(permissionList);
    Mockito.when(userMgr.encrypt(Mockito.anyString(), Mockito.anyString())).thenReturn(currentEncryptedPassword);
    Mockito.when(xXPortalUserDao.findByRole(Mockito.anyString())).thenReturn(listXXPortalUser);
    roleBasedUserSearchUtil.validateUserAndFetchUserList();
    Mockito.verify(xXPortalUserDao).findByLoginId(Mockito.anyString());
    Mockito.verify(xUserService).getXUserByUserName(xxPortalUser.getLoginId());
    Mockito.verify(xXModuleDefDao).findAccessibleModulesByUserId(Mockito.anyLong(), Mockito.anyLong());
    Mockito.verify(userMgr).encrypt(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(xXPortalUserDao, Mockito.atLeast(2)).findByRole(Mockito.anyString());
}
Also used : XXPortalUser(org.apache.ranger.entity.XXPortalUser) ArrayList(java.util.ArrayList) XXModuleDefDao(org.apache.ranger.db.XXModuleDefDao) VXUser(org.apache.ranger.view.VXUser) VXUserList(org.apache.ranger.view.VXUserList) Test(org.junit.Test)

Aggregations

VXUserList (org.apache.ranger.view.VXUserList)6 ArrayList (java.util.ArrayList)4 SearchCriteria (org.apache.ranger.common.SearchCriteria)4 VXUser (org.apache.ranger.view.VXUser)4 Test (org.junit.Test)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 SortField (org.apache.ranger.common.SortField)2 List (java.util.List)1 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)1 XXPortalUser (org.apache.ranger.entity.XXPortalUser)1 XXUser (org.apache.ranger.entity.XXUser)1 VXGroup (org.apache.ranger.view.VXGroup)1 VXString (org.apache.ranger.view.VXString)1