Search in sources :

Example 21 with SortField

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

the class TestXUserREST method test61countXAuditMaps.

@SuppressWarnings("unchecked")
@Test
public void test61countXAuditMaps() {
    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.getXAuditMapSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXAuditMaps(request);
    Mockito.verify(xUserMgr).getXAuditMapSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertNotNull(testvxLong);
}
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 22 with SortField

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

the class TestXUserREST method test87countXUserPermission.

@SuppressWarnings("unchecked")
@Test
public void test87countXUserPermission() {
    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.getXUserPermissionSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXUserPermission(request);
    Mockito.verify(xUserMgr).getXUserPermissionSearchCount(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 23 with SortField

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

the class TestXUserREST method test92searchXGroupPermission.

@SuppressWarnings("unchecked")
@Test
public void test92searchXGroupPermission() {
    VXGroupPermissionList testVXGroupPermissionList = new VXGroupPermissionList();
    testVXGroupPermissionList.setTotalCount(1);
    VXGroupPermission testVXGroupPermission = createVXGroupPermission();
    List<VXGroupPermission> testVXGroupPermissions = new ArrayList<VXGroupPermission>();
    testVXGroupPermissions.add(testVXGroupPermission);
    testVXGroupPermissionList.setvXGroupPermission(testVXGroupPermissions);
    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, "groupPermissionList", "groupId", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(xUserMgr.searchXGroupPermission(testSearchCriteria)).thenReturn(testVXGroupPermissionList);
    VXGroupPermissionList outputVXGroupPermissionList = xUserRest.searchXGroupPermission(request);
    assertNotNull(outputVXGroupPermissionList);
    assertEquals(outputVXGroupPermissionList.getClass(), testVXGroupPermissionList.getClass());
    assertEquals(outputVXGroupPermissionList.getTotalCount(), testVXGroupPermissionList.getTotalCount());
    Mockito.verify(xUserMgr).searchXGroupPermission(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, "groupPermissionList", "groupId", StringUtil.VALIDATION_NAME);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXGroupPermissionList(org.apache.ranger.view.VXGroupPermissionList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 24 with SortField

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

the class TestXUserREST method test12countXGroups.

@SuppressWarnings("unchecked")
@Test
public void test12countXGroups() {
    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.getXGroupSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroups(request);
    Mockito.verify(xUserMgr).getXGroupSearchCount(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 25 with SortField

use of org.apache.ranger.common.SortField 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)

Aggregations

SortField (org.apache.ranger.common.SortField)34 Test (org.junit.Test)30 SearchCriteria (org.apache.ranger.common.SearchCriteria)26 HttpServletRequest (javax.servlet.http.HttpServletRequest)23 ArrayList (java.util.ArrayList)15 VXLong (org.apache.ranger.view.VXLong)12 Date (java.util.Date)3 VXAccessAuditList (org.apache.ranger.view.VXAccessAuditList)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)2 VXAccessAudit (org.apache.ranger.view.VXAccessAudit)2 VXTrxLogList (org.apache.ranger.view.VXTrxLogList)2 VXUser (org.apache.ranger.view.VXUser)2 VXUserList (org.apache.ranger.view.VXUserList)2 Predicate (org.apache.commons.collections.Predicate)1 KeySearchFilter (org.apache.ranger.plugin.util.KeySearchFilter)1 VXAuditMap (org.apache.ranger.view.VXAuditMap)1 VXAuditMapList (org.apache.ranger.view.VXAuditMapList)1 VXAuthSession (org.apache.ranger.view.VXAuthSession)1 VXAuthSessionList (org.apache.ranger.view.VXAuthSessionList)1 VXCredentialStore (org.apache.ranger.view.VXCredentialStore)1