Search in sources :

Example 26 with VXUser

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

the class TestXUserREST method test73getXGroupUsers.

@SuppressWarnings("unchecked")
@Test
public void test73getXGroupUsers() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    testSearchCriteria.addParam("xGroupId", id);
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    VXUser testVXUser = createVXUser();
    VXUserList testVXUserList = new VXUserList();
    List<VXUser> testVXUsers = new ArrayList<VXUser>();
    testVXUsers.add(testVXUser);
    testVXUserList.setVXUsers(testVXUsers);
    testVXUserList.setStartIndex(1);
    testVXUserList.setTotalCount(1);
    Mockito.when(xUserMgr.getXGroupUsers(testSearchCriteria)).thenReturn(testVXUserList);
    VXUserList retVxGroupList = xUserRest.getXGroupUsers(request, id);
    assertNotNull(retVxGroupList);
    assertEquals(testVXUserList.getTotalCount(), retVxGroupList.getTotalCount());
    assertEquals(testVXUserList.getStartIndex(), retVxGroupList.getStartIndex());
    Mockito.verify(xUserMgr).getXGroupUsers(testSearchCriteria);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXUser(org.apache.ranger.view.VXUser) VXUserList(org.apache.ranger.view.VXUserList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 27 with VXUser

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

the class TestXUserREST method test18updateXUser.

@Test
public void test18updateXUser() {
    Mockito.when(xUserMgr.updateXUser(vxUser)).thenReturn(vxUser);
    VXUser gotVXUser = xUserRest.updateXUser(vxUser);
    Mockito.verify(xUserMgr).updateXUser(vxUser);
    assertNotNull(gotVXUser);
    assertEquals(vxUser.getId(), gotVXUser.getId());
    assertEquals(vxUser.getName(), gotVXUser.getName());
}
Also used : VXUser(org.apache.ranger.view.VXUser) Test(org.junit.Test)

Example 28 with VXUser

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

the class TestXUserREST method test99deleteUsersByUserName.

@Test
public void test99deleteUsersByUserName() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    String TestforceDeleteStr = "true";
    boolean forceDelete = false;
    Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
    VXString testVXString = new VXString();
    testVXString.setValue("User1");
    VXUser testVXUser = createVXUser();
    VXStringList vxStringList = createVXStringList();
    Mockito.when(xUserService.getXUserByUserName(testVXString.getValue())).thenReturn(testVXUser);
    forceDelete = true;
    Mockito.doNothing().when(xUserMgr).deleteXUser(testVXUser.getId(), forceDelete);
    xUserRest.deleteUsersByUserName(request, vxStringList);
    Mockito.verify(xUserMgr).deleteXUser(testVXUser.getId(), forceDelete);
    Mockito.verify(xUserService).getXUserByUserName(testVXString.getValue());
    Mockito.verify(request).getParameter("forceDelete");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) VXStringList(org.apache.ranger.view.VXStringList) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) Test(org.junit.Test)

Example 29 with VXUser

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

the class TestXUserREST method test100deleteUsersByUserNameNull.

@Test
public void test100deleteUsersByUserNameNull() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    String TestforceDeleteStr = "false";
    boolean forceDelete = true;
    Mockito.when(request.getParameter("forceDelete")).thenReturn(TestforceDeleteStr);
    VXString testVXString = new VXString();
    testVXString.setValue("User1");
    VXUser testVXUser = createVXUser();
    VXStringList vxStringList = createVXStringList();
    Mockito.when(xUserService.getXUserByUserName(testVXString.getValue())).thenReturn(testVXUser);
    forceDelete = false;
    Mockito.doNothing().when(xUserMgr).deleteXUser(testVXUser.getId(), forceDelete);
    xUserRest.deleteUsersByUserName(request, vxStringList);
    Mockito.verify(xUserMgr).deleteXUser(testVXUser.getId(), forceDelete);
    Mockito.verify(xUserService).getXUserByUserName(testVXString.getValue());
    Mockito.verify(request).getParameter("forceDelete");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) VXStringList(org.apache.ranger.view.VXStringList) VXString(org.apache.ranger.view.VXString) VXUser(org.apache.ranger.view.VXUser) Test(org.junit.Test)

Example 30 with VXUser

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

the class TestXUserREST method test70deleteXGroupAndXUser.

@Test
public void test70deleteXGroupAndXUser() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    VXGroup testVXGroup = createVXGroup();
    VXUser testVXuser = createVXUser();
    Mockito.doNothing().when(xUserMgr).deleteXGroupAndXUser(testVXGroup.getName(), testVXuser.getName());
    xUserRest.deleteXGroupAndXUser(testVXGroup.getName(), testVXuser.getName(), request);
    Mockito.verify(xUserMgr).deleteXGroupAndXUser(testVXGroup.getName(), testVXuser.getName());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXUser(org.apache.ranger.view.VXUser) VXGroup(org.apache.ranger.view.VXGroup) Test(org.junit.Test)

Aggregations

VXUser (org.apache.ranger.view.VXUser)42 Test (org.junit.Test)31 VXString (org.apache.ranger.view.VXString)21 ArrayList (java.util.ArrayList)13 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 XXUser (org.apache.ranger.entity.XXUser)8 XXPortalUser (org.apache.ranger.entity.XXPortalUser)6 VXStringList (org.apache.ranger.view.VXStringList)6 VXPortalUser (org.apache.ranger.view.VXPortalUser)5 HashMap (java.util.HashMap)4 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)4 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)4 XXUserDao (org.apache.ranger.db.XXUserDao)4 VXUserList (org.apache.ranger.view.VXUserList)4 Date (java.util.Date)3 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)3 VXGroup (org.apache.ranger.view.VXGroup)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 IOException (java.io.IOException)2 List (java.util.List)2