jnturton commented on code in PR #2618: URL: https://github.com/apache/drill/pull/2618#discussion_r945514482
########## contrib/storage-splunk/src/main/java/org/apache/drill/exec/store/splunk/SplunkGroupScan.java: ########## @@ -50,17 +54,20 @@ public class SplunkGroupScan extends AbstractGroupScan { private int hashCode; + private MetadataProviderManager metadataProviderManager; Review Comment: Can you elaborate on the role played by the metastore in this PR a bit, please? ########## contrib/storage-splunk/src/test/java/org/apache/drill/exec/store/splunk/TestSplunkUserTranslation.java: ########## @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.drill.exec.store.splunk; + +import org.apache.drill.categories.SlowTest; +import org.apache.drill.common.config.DrillProperties; +import org.apache.drill.exec.physical.rowSet.RowSet; +import org.apache.drill.test.ClientFixture; +import org.junit.Test; +import org.junit.experimental.categories.Category; + + +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.ADMIN_USER; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.ADMIN_USER_PASSWORD; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.TEST_USER_1; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.TEST_USER_1_PASSWORD; +import static org.junit.Assert.assertEquals; + +@Category({SlowTest.class}) +public class TestSplunkUserTranslation extends SplunkBaseTest { + + @Test + public void testQueryWithMissingCredentials() throws Exception { + // This test validates that the correct credentials are sent down to Splunk. + // This user should not see the ut_splunk because they do not have valid credentials + ClientFixture client = cluster + .clientBuilder() + .property(DrillProperties.USER, ADMIN_USER) + .property(DrillProperties.PASSWORD, ADMIN_USER_PASSWORD) + .build(); + + String sql = "SHOW DATABASES"; + + RowSet results = client.queryBuilder().sql(sql).rowSet(); + assertEquals(8, results.rowCount()); Review Comment: I guess something like this would take care of it: `show databases where table_schema like 'ut_splunk.%'` and `assertEquals(0, results.rowCount());` ########## contrib/storage-splunk/src/test/java/org/apache/drill/exec/store/splunk/TestSplunkUserTranslation.java: ########## @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.drill.exec.store.splunk; + +import org.apache.drill.categories.SlowTest; +import org.apache.drill.common.config.DrillProperties; +import org.apache.drill.exec.physical.rowSet.RowSet; +import org.apache.drill.test.ClientFixture; +import org.junit.Test; +import org.junit.experimental.categories.Category; + + +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.ADMIN_USER; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.ADMIN_USER_PASSWORD; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.TEST_USER_1; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.TEST_USER_1_PASSWORD; +import static org.junit.Assert.assertEquals; + +@Category({SlowTest.class}) +public class TestSplunkUserTranslation extends SplunkBaseTest { + + @Test + public void testQueryWithMissingCredentials() throws Exception { + // This test validates that the correct credentials are sent down to Splunk. + // This user should not see the ut_splunk because they do not have valid credentials + ClientFixture client = cluster + .clientBuilder() + .property(DrillProperties.USER, ADMIN_USER) + .property(DrillProperties.PASSWORD, ADMIN_USER_PASSWORD) + .build(); + + String sql = "SHOW DATABASES"; + + RowSet results = client.queryBuilder().sql(sql).rowSet(); + assertEquals(8, results.rowCount()); Review Comment: This magic number of 8 is a bit brittle. Can we replace it with a short search through the results to check for the absence of the Splunk plugin? Afterthought: ever read any Terry Pratchett? I think 8 _is_ the magic number in the Discworld :-) ########## contrib/storage-splunk/src/test/java/org/apache/drill/exec/store/splunk/TestSplunkUserTranslation.java: ########## @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.drill.exec.store.splunk; + +import org.apache.drill.categories.SlowTest; +import org.apache.drill.common.config.DrillProperties; +import org.apache.drill.exec.physical.rowSet.RowSet; +import org.apache.drill.test.ClientFixture; +import org.junit.Test; +import org.junit.experimental.categories.Category; + + +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.ADMIN_USER; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.ADMIN_USER_PASSWORD; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.TEST_USER_1; +import static org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl.TEST_USER_1_PASSWORD; +import static org.junit.Assert.assertEquals; + +@Category({SlowTest.class}) +public class TestSplunkUserTranslation extends SplunkBaseTest { + + @Test + public void testQueryWithMissingCredentials() throws Exception { + // This test validates that the correct credentials are sent down to Splunk. + // This user should not see the ut_splunk because they do not have valid credentials + ClientFixture client = cluster + .clientBuilder() + .property(DrillProperties.USER, ADMIN_USER) + .property(DrillProperties.PASSWORD, ADMIN_USER_PASSWORD) + .build(); + + String sql = "SHOW DATABASES"; + + RowSet results = client.queryBuilder().sql(sql).rowSet(); + assertEquals(8, results.rowCount()); + } + + @Test + public void testQueryWithValidCredentials() throws Exception { + ClientFixture client = cluster + .clientBuilder() + .property(DrillProperties.USER, TEST_USER_1) + .property(DrillProperties.PASSWORD, TEST_USER_1_PASSWORD) + .build(); + + String sql = "SHOW DATABASES"; + + RowSet results = client.queryBuilder().sql(sql).rowSet(); + assertEquals(9, results.rowCount()); Review Comment: Restrict this count to schemas registered by _this_ plugin using a LIKE filter in the SHOW DATABASES, or similar. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@drill.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org