QueryIndexAuthorizationComponent extends SearchComponent { @Override public void prepare(ResponseBuilder rb) throws IOException { sentryInstance.authorizeCollectionAction( rb.req, EnumSet.of(SearchModelAction.QUERY), OPERATION_NAME); String collections = rb.req.getParams().get("collection"); if (collections != null) { List<String> collectionList = StrUtils.splitSmart(collections, ",", true); for (String coll : collectionList) { sentryInstance.authorizeCollectionAction(rb.req, EnumSet.of(SearchModelAction.QUERY), OPERATION_NAME, coll, true); } } } QueryIndexAuthorizationComponent(); @VisibleForTesting  QueryIndexAuthorizationComponent(SentryIndexAuthorizationSingleton sentryInstance); @Override void prepare(ResponseBuilder rb); @Override void process(ResponseBuilder rb); @Override String getDescription(); @Override String getSource();  }
@Test public void testQueryComponentAccessAll() throws Exception { ResponseBuilder responseBuilder = getResponseBuilder(); prepareCollAndUser(core, responseBuilder.req, "collection1", "junit"); QueryIndexAuthorizationComponent query = new QueryIndexAuthorizationComponent(sentryInstance); query.prepare(responseBuilder); }
@Test public void testQueryComponentAccessQuery() throws Exception { ResponseBuilder responseBuilder = getResponseBuilder(); prepareCollAndUser(core, responseBuilder.req, "queryCollection", "junit"); QueryIndexAuthorizationComponent query = new QueryIndexAuthorizationComponent(sentryInstance); query.prepare(responseBuilder); }