Repository: incubator-sentry Updated Branches: refs/heads/master 1c32c13ad -> cfaa570f0
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestDocLevelOperations.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestDocLevelOperations.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestDocLevelOperations.java index 46399df..71452e2 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestDocLevelOperations.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestDocLevelOperations.java @@ -16,8 +16,6 @@ */ package org.apache.sentry.tests.e2e.solr; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.junit.After; import org.junit.Before; import static org.junit.Assert.assertEquals; @@ -33,7 +31,6 @@ import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; -import org.apache.solr.common.util.NamedList; import java.io.File; import java.net.URLEncoder; @@ -46,8 +43,6 @@ import org.junit.Test; * Test the document-level security features */ public class TestDocLevelOperations extends AbstractSolrSentryTestBase { - private static final Logger LOG = LoggerFactory - .getLogger(TestDocLevelOperations.class); private static final String AUTH_FIELD = "sentry_auth"; private static final int NUM_DOCS = 100; private static final int EXTRA_AUTH_FIELDS = 2; @@ -114,7 +109,7 @@ public class TestDocLevelOperations extends AbstractSolrSentryTestBase { CloudSolrServer server = getCloudSolrServer(collectionName); try { - DocLevelGenerator generator = new DocLevelGenerator(collectionName, AUTH_FIELD); + DocLevelGenerator generator = new DocLevelGenerator(AUTH_FIELD); generator.generateDocs(server, NUM_DOCS, "junit_role", "admin_role", EXTRA_AUTH_FIELDS); querySimple(new QueryRequest(new SolrQuery("*:*")), server, checkNonAdminUsers); @@ -169,20 +164,20 @@ public class TestDocLevelOperations extends AbstractSolrSentryTestBase { // test filter queries work as AND -- i.e. user can't avoid doc-level // checks by prefixing their own filterQuery setAuthenticationUser("junit"); - String fq = URLEncoder.encode(" {!raw f=" + AUTH_FIELD + " v=docLevel_role}"); + String fq = URLEncoder.encode(" {!raw f=" + AUTH_FIELD + " v=docLevel_role}", "UTF-8"); String path = "/" + collectionName + "/select?q=*:*&fq="+fq; String retValue = makeHttpRequest(server, "GET", path, null, null); assertTrue(retValue.contains("numFound=\"" + NUM_DOCS / 2 + "\" ")); // test that user can't inject an "OR" into the query final String syntaxErrorMsg = "org.apache.solr.search.SyntaxError: Cannot parse"; - fq = URLEncoder.encode(" {!raw f=" + AUTH_FIELD + " v=docLevel_role} OR "); + fq = URLEncoder.encode(" {!raw f=" + AUTH_FIELD + " v=docLevel_role} OR ", "UTF-8"); path = "/" + collectionName + "/select?q=*:*&fq="+fq; retValue = makeHttpRequest(server, "GET", path, null, null); assertTrue(retValue.contains(syntaxErrorMsg)); // same test, prefix OR this time - fq = URLEncoder.encode(" OR {!raw f=" + AUTH_FIELD + " v=docLevel_role}"); + fq = URLEncoder.encode(" OR {!raw f=" + AUTH_FIELD + " v=docLevel_role}", "UTF-8"); path = "/" + collectionName + "/select?q=*:*&fq="+fq; retValue = makeHttpRequest(server, "GET", path, null, null); assertTrue(retValue.contains(syntaxErrorMsg)); @@ -229,7 +224,9 @@ public class TestDocLevelOperations extends AbstractSolrSentryTestBase { } if (i % allRolesFactor == 0) { doc.addField(AUTH_FIELD, allRolesToken); ++totalAllRolesAdded; - if (!addedViaJunit) ++totalOnlyAllRolesAdded; + if (!addedViaJunit) { + ++totalOnlyAllRolesAdded; + } } docs.add(doc); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestQueryOperations.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestQueryOperations.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestQueryOperations.java index c257175..f8ed955 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestQueryOperations.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestQueryOperations.java @@ -27,9 +27,6 @@ import org.apache.solr.common.SolrInputDocument; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; - import org.junit.Test; import static org.junit.Assert.assertEquals; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestRealTimeGet.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestRealTimeGet.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestRealTimeGet.java index 0d25562..6181d8b 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestRealTimeGet.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/TestRealTimeGet.java @@ -27,8 +27,6 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -48,8 +46,6 @@ import java.util.Random; import java.util.Set; public class TestRealTimeGet extends AbstractSolrSentryTestBase { - private static final Logger LOG = LoggerFactory - .getLogger(TestRealTimeGet.class); private static final String AUTH_FIELD = "sentry_auth"; private static final Random rand = new Random(); private String userName = null; @@ -79,7 +75,9 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { modParams.set("numShards", shards); StringBuilder builder = new StringBuilder(); for (int i = 0; i < shards; ++i) { - if (i != 0) builder.append(","); + if (i != 0) { + builder.append(","); + } builder.append("shard").append(i+1); } modParams.set("shards", builder.toString()); @@ -108,7 +106,7 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { } private void assertExpected(ExpectedResult expectedResult, QueryResponse rsp, - ExpectedResult controlExpectedResult, QueryResponse controlRsp) throws Exception { + QueryResponse controlRsp) throws Exception { SolrDocumentList docList = rsp.getResults(); SolrDocumentList controlDocList = controlRsp.getResults(); SolrDocument doc = (SolrDocument)rsp.getResponse().get("doc"); @@ -150,7 +148,9 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { private QueryResponse getIdsResponse(ExpectedResult expectedResult) throws Exception { StringBuilder builder = new StringBuilder(); for (int i = 0; i < expectedResult.ids.length; ++i) { - if (i != 0) builder.append(","); + if (i != 0) { + builder.append(","); + } builder.append(expectedResult.ids[ i ]); } ModifiableSolrParams params = new ModifiableSolrParams(); @@ -167,12 +167,12 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { // test specifying with "id" QueryResponse idRsp = getIdResponse(expectedResult); QueryResponse idControlRsp = getIdResponse(controlExpectedResult); - assertExpected(expectedResult, idRsp, controlExpectedResult, idControlRsp); + assertExpected(expectedResult, idRsp, idControlRsp); // test specifying with "ids" QueryResponse idsRsp = getIdsResponse(expectedResult); QueryResponse idsControlRsp = getIdsResponse(controlExpectedResult); - assertExpected(expectedResult, idsRsp, controlExpectedResult, idsControlRsp); + assertExpected(expectedResult, idsRsp, idsControlRsp); } @Test @@ -186,7 +186,7 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { try { for (CloudSolrServer s : new CloudSolrServer [] {server, serverControl}) { - DocLevelGenerator generator = new DocLevelGenerator(s.getDefaultCollection(), AUTH_FIELD); + DocLevelGenerator generator = new DocLevelGenerator(AUTH_FIELD); generator.generateDocs(s, 100, "junit_role", "admin_role", 2); } @@ -262,7 +262,7 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { CloudSolrServer server = getCloudSolrServer(collection); try { - DocLevelGenerator generator = new DocLevelGenerator(collection, AUTH_FIELD); + DocLevelGenerator generator = new DocLevelGenerator(AUTH_FIELD); generator.generateDocs(server, 100, "junit_role", "admin_role", 2); String [] ids = new String[] {"1", "3", "5"}; @@ -282,7 +282,7 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { CloudSolrServer server = getCloudSolrServer(collection); try { - DocLevelGenerator generator = new DocLevelGenerator(collection, AUTH_FIELD); + DocLevelGenerator generator = new DocLevelGenerator(AUTH_FIELD); generator.generateDocs(server, 100, "junit_role", "admin_role", 2); // make some uncommitted modifications and ensure they are reflected @@ -352,7 +352,7 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { int numQueries = 5; try { - DocLevelGenerator generator = new DocLevelGenerator(collection, authField); + DocLevelGenerator generator = new DocLevelGenerator(authField); generator.generateDocs(server, 100, "junit_role", "admin_role", 2); List<AuthFieldModifyThread> threads = new LinkedList<AuthFieldModifyThread>(); @@ -400,7 +400,7 @@ public class TestRealTimeGet extends AbstractSolrSentryTestBase { int docCount = 100; try { - DocLevelGenerator generator = new DocLevelGenerator(collection, AUTH_FIELD); + DocLevelGenerator generator = new DocLevelGenerator(AUTH_FIELD); generator.generateDocs(server, docCount, "junit_role", "admin_role", 2); setAuthenticationUser("solr"); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/AbstractSolrSentryTestWithDbProvider.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/AbstractSolrSentryTestWithDbProvider.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/AbstractSolrSentryTestWithDbProvider.java index b1a68aa..11f93d5 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/AbstractSolrSentryTestWithDbProvider.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/AbstractSolrSentryTestWithDbProvider.java @@ -170,6 +170,11 @@ public class AbstractSolrSentryTestWithDbProvider extends AbstractSolrSentryTest public boolean equals(Object obj) { return true; } + + @Override + public int hashCode() { + return 17; + } }); extraRequestFilters.put(ModifiableUserAuthenticationFilter.class, "*"); @@ -316,4 +321,4 @@ public class AbstractSolrSentryTestWithDbProvider extends AbstractSolrSentryTest tPrivilege.setAuthorizables(authorizables); return tPrivilege; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrAdminOperations.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrAdminOperations.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrAdminOperations.java index 69b8357..c07b3b8 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrAdminOperations.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrAdminOperations.java @@ -26,11 +26,8 @@ import org.apache.sentry.core.model.search.Collection; import org.apache.sentry.core.model.search.SearchConstants; import org.apache.solr.common.params.CollectionParams.CollectionAction; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TestSolrAdminOperations extends AbstractSolrSentryTestWithDbProvider { - private static final Logger LOG = LoggerFactory.getLogger(TestSolrAdminOperations.class); private static final String TEST_COLLECTION_NAME1 = "collection1"; private static final String COLLECTION_CONFIG_DIR = RESOURCES_DIR + File.separator + "collection1" + File.separator + "conf"; @@ -242,4 +239,4 @@ public class TestSolrAdminOperations extends AbstractSolrSentryTestWithDbProvide client.listPrivilegesByRoleName("user3", "role3", COMPONENT_SOLR, SERVICE_NAME, Arrays.asList(new Collection(TEST_COLLECTION_NAME1))).size() == 0); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrQueryOperations.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrQueryOperations.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrQueryOperations.java index c8f7e5f..3eb6c0f 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrQueryOperations.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrQueryOperations.java @@ -22,13 +22,10 @@ import org.apache.sentry.core.model.search.Collection; import org.apache.sentry.core.model.search.SearchConstants; import org.apache.solr.common.SolrInputDocument; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.google.common.collect.Lists; public class TestSolrQueryOperations extends AbstractSolrSentryTestWithDbProvider { - private static final Logger LOG = LoggerFactory.getLogger(TestSolrQueryOperations.class); private static final String TEST_COLLECTION_NAME1 = "collection1"; private static final String COLLECTION_CONFIG_DIR = RESOURCES_DIR + File.separator + "collection1" + File.separator + "conf"; @@ -96,4 +93,4 @@ public class TestSolrQueryOperations extends AbstractSolrSentryTestWithDbProvide deleteCollection(TEST_COLLECTION_NAME1); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrUpdateOperations.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrUpdateOperations.java b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrUpdateOperations.java index 765fc34..9412325 100644 --- a/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrUpdateOperations.java +++ b/sentry-tests/sentry-tests-solr/src/test/java/org/apache/sentry/tests/e2e/solr/db/integration/TestSolrUpdateOperations.java @@ -21,11 +21,8 @@ import java.io.File; import org.apache.sentry.core.model.search.SearchConstants; import org.apache.solr.common.SolrInputDocument; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TestSolrUpdateOperations extends AbstractSolrSentryTestWithDbProvider { - private static final Logger LOG = LoggerFactory.getLogger(TestSolrUpdateOperations.class); private static final String TEST_COLLECTION_NAME1 = "collection1"; private static final String COLLECTION_CONFIG_DIR = RESOURCES_DIR + File.separator + "collection1" + File.separator + "conf"; @@ -100,4 +97,4 @@ public class TestSolrUpdateOperations extends AbstractSolrSentryTestWithDbProvid deleteCollection(TEST_COLLECTION_NAME1); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestConnectorEndToEnd.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestConnectorEndToEnd.java b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestConnectorEndToEnd.java index 9e13b13..27f1420 100644 --- a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestConnectorEndToEnd.java +++ b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestConnectorEndToEnd.java @@ -17,9 +17,6 @@ package org.apache.sentry.tests.e2e.sqoop; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Collection; import org.apache.sentry.core.model.sqoop.SqoopActionConstant; import org.apache.sqoop.client.SqoopClient; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestOwnerPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestOwnerPrivilege.java b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestOwnerPrivilege.java index 9bed526..abef80c 100644 --- a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestOwnerPrivilege.java +++ b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestOwnerPrivilege.java @@ -23,8 +23,6 @@ import static org.junit.Assert.fail; import org.apache.sentry.core.model.sqoop.SqoopActionConstant; import org.apache.sqoop.client.SqoopClient; -import org.apache.sqoop.model.MConnector; -import org.apache.sqoop.model.MDriverConfig; import org.apache.sqoop.model.MJob; import org.apache.sqoop.model.MLink; import org.apache.sqoop.model.MPrincipal; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestShowPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestShowPrivilege.java b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestShowPrivilege.java index 609239f..0ccbf5d 100644 --- a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestShowPrivilege.java +++ b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TestShowPrivilege.java @@ -28,7 +28,6 @@ import org.junit.Test; import com.google.common.collect.Lists; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class TestShowPrivilege extends AbstractSqoopSentryTestBase { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/cfaa570f/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TomcatSqoopRunner.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TomcatSqoopRunner.java b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TomcatSqoopRunner.java index 0d50574..cea9acc 100644 --- a/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TomcatSqoopRunner.java +++ b/sentry-tests/sentry-tests-sqoop/src/test/java/org/apache/sentry/tests/e2e/sqoop/TomcatSqoopRunner.java @@ -44,7 +44,6 @@ import org.codehaus.cargo.container.configuration.LocalConfiguration; import org.codehaus.cargo.container.deployable.WAR; import org.codehaus.cargo.container.installer.Installer; import org.codehaus.cargo.container.installer.ZipURLInstaller; -import org.codehaus.cargo.container.property.GeneralPropertySet; import org.codehaus.cargo.container.property.ServletPropertySet; import org.codehaus.cargo.container.tomcat.TomcatPropertySet; import org.codehaus.cargo.generic.DefaultContainerFactory;