sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject [17/18] sentry git commit: SENTRY-858: Add a test case for - Database prefix is not honoured when executing grant statement ( Rahul Sharma, Reviewed by: Sravya Tirukkovalur)
Date Mon, 13 Jun 2016 02:52:21 GMT
SENTRY-858: Add a test case for - Database prefix is not honoured when executing grant statement
 ( Rahul Sharma, Reviewed by: Sravya Tirukkovalur)

Change-Id: I5ad9dc38c3ace4454ea2e51772824a8693c32656


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/170eb22f
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/170eb22f
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/170eb22f

Branch: refs/heads/SENTRY-1205
Commit: 170eb22f62733483cb17cb269ee21e893a182f1b
Parents: 79204bc
Author: Sravya Tirukkovalur <sravya@apache.org>
Authored: Mon Jun 6 14:19:55 2016 -0700
Committer: Sravya Tirukkovalur <sravya@apache.org>
Committed: Mon Jun 6 14:19:55 2016 -0700

----------------------------------------------------------------------
 .../e2e/dbprovider/TestDatabaseProvider.java    | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/170eb22f/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java
index a7c0a0c..ff4eeaf 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java
@@ -2177,4 +2177,41 @@ public class TestDatabaseProvider extends AbstractTestWithStaticConfiguration
{
     statement.close();
     connection.close();
   }
+
+  /* Sentry-858 */
+  @Test
+  public void testShowPrivilegesWithDbPrefix() throws Exception {
+    //negative testcase
+    Connection connection = context.createConnection(ADMIN1);
+    Statement statement = context.createStatement(connection);
+    statement.execute("CREATE ROLE role1");
+    ResultSet resultSet = statement.executeQuery("SHOW GRANT ROLE role1");
+    assertResultSize(resultSet, 0);
+    statement.execute("CREATE DATABASE db1");
+    statement.execute("USE db1");
+    statement.execute("CREATE TABLE tab1 (col1 string)");
+    statement.execute("USE default");
+    statement.execute("GRANT SELECT ON TABLE db1.tab1 TO ROLE role1");
+    statement.execute("GRANT ROLE role1 to GROUP " + USERGROUP1);
+
+    String[] users = {USER1_1};
+    connection = context.createConnection(USER1_1);
+    statement = context.createStatement(connection);
+    resultSet = statement.executeQuery("SHOW GRANT ROLE role1");
+
+    while ( resultSet.next()) {
+      assertThat(resultSet.getString(1), equalToIgnoringCase("default"));//the value should
be db1
+      assertThat(resultSet.getString(2), equalToIgnoringCase("tab1"));
+      assertThat(resultSet.getString(3), equalToIgnoringCase(""));//partition
+      assertThat(resultSet.getString(4), equalToIgnoringCase(""));//column
+      assertThat(resultSet.getString(5), equalToIgnoringCase("role1"));//principalName
+      assertThat(resultSet.getString(6), equalToIgnoringCase("role"));//principalType
+      assertThat(resultSet.getString(7), equalToIgnoringCase("select"));
+      assertThat(resultSet.getBoolean(8), is(new Boolean("False")));//grantOption
+      assertThat(resultSet.getString(10), equalToIgnoringCase("--"));//grantor
+    }
+    statement.close();
+    connection.close();
+  }
+
 }


Mime
View raw message