Search in sources :

Example 51 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria in project ranger by apache.

the class TestXUserREST method test74getAuthSessions.

@SuppressWarnings("unchecked")
@Test
public void test74getAuthSessions() {
    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.extractLong(request, testSearchCriteria, "id", "Auth Session Id")).thenReturn(1L);
    Mockito.when(searchUtil.extractLong(request, testSearchCriteria, "userId", "User Id")).thenReturn(1L);
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "authStatus", "Auth Status")).thenReturn(1);
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "deviceType", "Device Type")).thenReturn(1);
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "firstName", "User First Name", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "lastName", "User Last Name", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "requestUserAgent", "User Agent", StringUtil.VALIDATION_TEXT)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "requestIP", "Request IP Address", StringUtil.VALIDATION_IP_ADDRESS)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "loginId", "Login ID", StringUtil.VALIDATION_TEXT)).thenReturn("");
    VXAuthSessionList testVXAuthSessionList = new VXAuthSessionList();
    testVXAuthSessionList.setTotalCount(1);
    testVXAuthSessionList.setStartIndex(1);
    VXAuthSession testVXAuthSession = createVXAuthSession();
    List<VXAuthSession> testvXAuthSessions = new ArrayList<VXAuthSession>();
    testvXAuthSessions.add(testVXAuthSession);
    testVXAuthSessionList.setVXAuthSessions(testvXAuthSessions);
    Mockito.when(sessionMgr.searchAuthSessions(testSearchCriteria)).thenReturn(testVXAuthSessionList);
    VXAuthSessionList outputvXGroupList = xUserRest.getAuthSessions(request);
    Mockito.verify(sessionMgr).searchAuthSessions(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractLong(request, testSearchCriteria, "id", "Auth Session Id");
    Mockito.verify(searchUtil).extractLong(request, testSearchCriteria, "userId", "User Id");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "authStatus", "Auth Status");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "authType", "Login Type");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "deviceType", "Device Type");
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "firstName", "User First Name", StringUtil.VALIDATION_NAME);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "lastName", "User Last Name", StringUtil.VALIDATION_NAME);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "requestUserAgent", "User Agent", StringUtil.VALIDATION_TEXT);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "requestIP", "Request IP Address", StringUtil.VALIDATION_IP_ADDRESS);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "loginId", "Login ID", StringUtil.VALIDATION_TEXT);
    Mockito.verify(searchUtil).extractDate(request, testSearchCriteria, "startDate", "Start Date", null);
    Mockito.verify(searchUtil).extractDate(request, testSearchCriteria, "endDate", "End Date", null);
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getStartIndex(), testVXAuthSessionList.getStartIndex());
    assertEquals(outputvXGroupList.getTotalCount(), testVXAuthSessionList.getTotalCount());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXAuthSession(org.apache.ranger.view.VXAuthSession) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXAuthSessionList(org.apache.ranger.view.VXAuthSessionList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 52 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria in project ranger by apache.

the class TestXUserREST method test25countXUsers.

@SuppressWarnings("unchecked")
@Test
public void test25countXUsers() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    vXLong.setValue(1);
    Mockito.when(xUserMgr.getXUserSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXUsers(request);
    Mockito.verify(xUserMgr).getXUserSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 53 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria in project ranger by apache.

the class TestXUserREST method test60searchXAuditMaps.

@SuppressWarnings("unchecked")
@Test
public void test60searchXAuditMaps() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    List<VXAuditMap> testvXAuditMaps = new ArrayList<VXAuditMap>();
    testvXAuditMaps.add(testvXAuditMap);
    VXAuditMapList testVXAuditMapList = new VXAuditMapList();
    testVXAuditMapList.setVXAuditMaps(testvXAuditMaps);
    Mockito.when(xUserMgr.searchXAuditMaps(testSearchCriteria)).thenReturn(testVXAuditMapList);
    VXAuditMapList outputVXAuditMapList = xUserRest.searchXAuditMaps(request);
    Mockito.verify(xUserMgr).searchXAuditMaps(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputVXAuditMapList);
    assertEquals(outputVXAuditMapList.getClass(), testVXAuditMapList.getClass());
    assertEquals(outputVXAuditMapList.getResultSize(), testVXAuditMapList.getResultSize());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) VXAuditMap(org.apache.ranger.view.VXAuditMap) SortField(org.apache.ranger.common.SortField) VXAuditMapList(org.apache.ranger.view.VXAuditMapList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 54 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria in project ranger by apache.

the class TestXUserREST method test11searchXGroups.

@SuppressWarnings("unchecked")
@Test
public void test11searchXGroups() {
    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, "name", "group name", null)).thenReturn("");
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "isVisible", "Group Visibility")).thenReturn(1);
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "groupSource", "group source", null)).thenReturn("");
    VXGroupList testvXGroupList = createxGroupList();
    Mockito.when(xUserMgr.searchXGroups(testSearchCriteria)).thenReturn(testvXGroupList);
    VXGroupList outputvXGroupList = xUserRest.searchXGroups(request);
    Mockito.verify(xUserMgr).searchXGroups(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "name", "group name", null);
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "isVisible", "Group Visibility");
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "groupSource", "group source", null);
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getTotalCount(), testvXGroupList.getTotalCount());
    assertEquals(outputvXGroupList.getClass(), testvXGroupList.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupList(org.apache.ranger.view.VXGroupList) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 55 with SearchCriteria

use of org.apache.ranger.common.SearchCriteria in project ranger by apache.

the class TestXUserREST method test37countXGroupGroups.

@SuppressWarnings("unchecked")
@Test
public void test37countXGroupGroups() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    vXLong.setValue(1);
    Mockito.when(xUserMgr.getXGroupGroupSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroupGroups(request);
    Mockito.verify(xUserMgr).getXGroupGroupSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getClass(), vXLong.getClass());
    assertEquals(testvxLong.getValue(), vXLong.getValue());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Aggregations

SearchCriteria (org.apache.ranger.common.SearchCriteria)61 Test (org.junit.Test)29 SortField (org.apache.ranger.common.SortField)27 ArrayList (java.util.ArrayList)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)20 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 VXLong (org.apache.ranger.view.VXLong)10 Date (java.util.Date)9 DateUtil (org.apache.ranger.common.DateUtil)6 HashMap (java.util.HashMap)4 XXPortalUser (org.apache.ranger.entity.XXPortalUser)4 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)4 RangerPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem)4 VXPermMap (org.apache.ranger.view.VXPermMap)4 VXUserList (org.apache.ranger.view.VXUserList)4 List (java.util.List)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)3