Search in sources :

Example 51 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasCommands method testCreatePublicAliasWithNonAdminUser.

@Test
public void testCreatePublicAliasWithNonAdminUser() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        String sql = "CREATE OR REPLACE PUBLIC ALIAS abc for storage dfs";
        client.queryBuilder().sql(sql).run();
        fail();
    } catch (UserRemoteException e) {
        MatcherAssert.assertThat(e.getVerboseMessage(), containsString("PERMISSION ERROR: Not authorized to perform operations on public aliases"));
    } finally {
        storageAliasesRegistry.deletePublicAliases();
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 52 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasCommands method testDropStorageUserAlias.

@Test
public void testDropStorageUserAlias() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        storageAliasesRegistry.createUserAliases(TEST_USER_2);
        storageAliasesRegistry.getUserAliases(TEST_USER_2).put("`abc`", "`cp`", true);
        String sql = "DROP ALIAS abc FOR STORAGE";
        client.testBuilder().sqlQuery(sql).unOrdered().baselineColumns("ok", "summary").baselineValues(true, "Storage alias '`abc`' dropped successfully").go();
        storageAliasesRegistry.getUserAliases(TEST_USER_2).getAllAliases().forEachRemaining(entry -> fail());
    } finally {
        storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 53 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasSubstitution method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    cluster = ClusterFixture.bareBuilder(dirTestWatcher).configProperty(ExecConstants.USER_AUTHENTICATION_ENABLED, true).configProperty(ExecConstants.IMPERSONATION_ENABLED, true).configProperty(ExecConstants.USER_AUTHENTICATOR_IMPL, UserAuthenticatorTestImpl.TYPE).configProperty(DrillProperties.USER, PROCESS_USER).configProperty(DrillProperties.PASSWORD, PROCESS_USER_PASSWORD).build();
    ClientFixture admin = cluster.clientBuilder().property(DrillProperties.USER, PROCESS_USER).property(DrillProperties.PASSWORD, PROCESS_USER_PASSWORD).build();
    admin.alterSystem(ExecConstants.ADMIN_USERS_KEY, ADMIN_USER + "," + PROCESS_USER);
    admin.alterSystem(ExecConstants.ADMIN_USER_GROUPS_KEY, ADMIN_GROUP);
    client = cluster.clientBuilder().property(DrillProperties.USER, ADMIN_USER).property(DrillProperties.PASSWORD, ADMIN_USER_PASSWORD).build();
    storageAliasesRegistry = cluster.drillbit().getContext().getAliasRegistryProvider().getStorageAliasesRegistry();
    tableAliasesRegistry = cluster.drillbit().getContext().getAliasRegistryProvider().getTableAliasesRegistry();
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) BeforeClass(org.junit.BeforeClass)

Example 54 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasSubstitution method testNonSharingStorageUserAlias.

@Test
public void testNonSharingStorageUserAlias() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_1).property(DrillProperties.PASSWORD, TEST_USER_1_PASSWORD).build();
        storageAliasesRegistry.createUserAliases(TEST_USER_2);
        storageAliasesRegistry.getUserAliases(TEST_USER_2).put("`foobar`", "`cp`", false);
        String sql = "SELECT * FROM foobar.`tpch/lineitem.parquet` limit 1";
        client.queryBuilder().sql(sql).run().recordCount();
        fail();
    } catch (UserRemoteException e) {
        MatcherAssert.assertThat(e.getVerboseMessage(), containsString("VALIDATION ERROR: Schema [[foobar]] is not valid with respect to either root schema or current default schema."));
    } finally {
        storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 55 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasSubstitution method testStorageUserAlias.

@Test
public void testStorageUserAlias() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        storageAliasesRegistry.createUserAliases(TEST_USER_2);
        storageAliasesRegistry.getUserAliases(TEST_USER_2).put("`foobar`", "`cp`", false);
        String sql = "SELECT * FROM foobar.`tpch/lineitem.parquet` limit 1";
        long recordCount = client.queryBuilder().sql(sql).run().recordCount();
        assertEquals(1, recordCount);
    } finally {
        storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)122 Test (org.junit.Test)102 ClusterFixture (org.apache.drill.test.ClusterFixture)99 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)89 SlowTest (org.apache.drill.categories.SlowTest)46 OptionsTest (org.apache.drill.categories.OptionsTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)28 BaseTest (org.apache.drill.test.BaseTest)20 ClusterTest (org.apache.drill.test.ClusterTest)16 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 DrillTest (org.apache.drill.test.DrillTest)10 OperatorTest (org.apache.drill.categories.OperatorTest)8 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)7 RestClientFixture (org.apache.drill.test.RestClientFixture)4 ArrayList (java.util.ArrayList)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)3 BigIntVector (org.apache.drill.exec.vector.BigIntVector)3 File (java.io.File)2 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)2