Search in sources :

Example 26 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class TestServiceDBStore method test37getPaginatedServicePolicies.

@Test
public void test37getPaginatedServicePolicies() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    RangerService rangerService = rangerService();
    XXService xService = xService();
    XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
    Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
    Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
    // PList<RangerPolicy> dbRangerPolicyList =
    serviceDBStore.getPaginatedServicePolicies(rangerService.getId(), filter);
    Mockito.verify(daoManager).getXXService();
}
Also used : SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 27 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class TestServiceDBStore method test31getPaginatedPolicies.

@Test
public void test31getPaginatedPolicies() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    RangerPolicyList policyListObj = new RangerPolicyList();
    policyListObj.setPageSize(0);
    policyListObj.setResultSize(1);
    policyListObj.setSortBy("asc");
    policyListObj.setSortType("1");
    policyListObj.setStartIndex(0);
    policyListObj.setTotalCount(10);
    PList<RangerPolicy> dbRangerPolicyList = serviceDBStore.getPaginatedPolicies(filter);
    Assert.assertNotNull(dbRangerPolicyList);
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerPolicyList(org.apache.ranger.view.RangerPolicyList) Test(org.junit.Test)

Example 28 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class TestServiceDBStore method test32getServicePolicies.

@Test
public void test32getServicePolicies() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    XXService xService = xService();
    XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
    Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
    Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
    thrown.expect(Exception.class);
    List<RangerPolicy> dbRangerPolicy = serviceDBStore.getServicePolicies(Id, filter);
    Assert.assertFalse(dbRangerPolicy.isEmpty());
    Mockito.verify(daoManager).getXXService();
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) Test(org.junit.Test)

Example 29 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class TestServiceDBStore method test25getPaginatedServiceDefs.

@Test
public void test25getPaginatedServiceDefs() throws Exception {
    SearchFilter filter = new SearchFilter();
    filter.setParam(SearchFilter.POLICY_NAME, "policyName");
    filter.setParam(SearchFilter.SERVICE_NAME, "serviceName");
    List<RangerService> serviceList = new ArrayList<RangerService>();
    RangerService rangerService = rangerService();
    serviceList.add(rangerService);
    RangerServiceList serviceListObj = new RangerServiceList();
    serviceListObj.setPageSize(0);
    serviceListObj.setResultSize(1);
    serviceListObj.setSortBy("asc");
    serviceListObj.setSortType("1");
    serviceListObj.setStartIndex(0);
    serviceListObj.setTotalCount(10);
    serviceListObj.setServices(serviceList);
    Mockito.when(svcService.searchRangerServices(filter)).thenReturn(serviceListObj);
    PList<RangerService> dbServiceList = serviceDBStore.getPaginatedServices(filter);
    Assert.assertNotNull(dbServiceList);
    Assert.assertEquals(dbServiceList.getList(), serviceListObj.getServices());
    Mockito.verify(svcService).searchRangerServices(filter);
}
Also used : ArrayList(java.util.ArrayList) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) RangerServiceList(org.apache.ranger.view.RangerServiceList) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 30 with SearchFilter

use of org.apache.ranger.plugin.util.SearchFilter in project ranger by apache.

the class RangerSearchUtil method getSearchFilterFromLegacyRequestForRepositorySearch.

public SearchFilter getSearchFilterFromLegacyRequestForRepositorySearch(HttpServletRequest request, List<SortField> sortFields) {
    if (request == null) {
        return null;
    }
    SearchFilter ret = new SearchFilter();
    if (MapUtils.isEmpty(request.getParameterMap())) {
        ret.setParams(new HashMap<String, String>());
    }
    ret.setParam(SearchFilter.SERVICE_NAME, request.getParameter("name"));
    ret.setParam(SearchFilter.IS_ENABLED, request.getParameter("status"));
    String serviceType = request.getParameter("type");
    if (serviceType != null) {
        serviceType = serviceType.toLowerCase();
    }
    ret.setParam(SearchFilter.SERVICE_TYPE, serviceType);
    extractCommonCriteriasForFilter(request, ret, sortFields);
    return ret;
}
Also used : SearchFilter(org.apache.ranger.plugin.util.SearchFilter)

Aggregations

SearchFilter (org.apache.ranger.plugin.util.SearchFilter)61 Test (org.junit.Test)32 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)30 ArrayList (java.util.ArrayList)27 RangerService (org.apache.ranger.plugin.model.RangerService)24 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 GET (javax.ws.rs.GET)12 WebApplicationException (javax.ws.rs.WebApplicationException)11 RangerPolicyList (org.apache.ranger.view.RangerPolicyList)11 VXString (org.apache.ranger.view.VXString)10 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)9 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)7 RangerServiceDefList (org.apache.ranger.view.RangerServiceDefList)6 RangerServiceList (org.apache.ranger.view.RangerServiceList)6 HashMap (java.util.HashMap)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 XXTrxLog (org.apache.ranger.entity.XXTrxLog)4 RangerExportPolicyList (org.apache.ranger.view.RangerExportPolicyList)4