sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SENTRY-319: group names should be case sensitive.
Date Mon, 30 Jun 2014 20:53:38 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master 0c3954045 -> bbec68b58


SENTRY-319: group names should be case sensitive.

(Sravya Tirukkovalur via Jarek Jarcec Cecho)


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

Branch: refs/heads/master
Commit: bbec68b5837ad7015ef6dcfabb60e112c447bdf0
Parents: 0c39540
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Mon Jun 30 13:53:10 2014 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon Jun 30 13:53:10 2014 -0700

----------------------------------------------------------------------
 .../db/service/persistent/SentryStore.java      | 14 +++++++-------
 .../db/service/persistent/TestSentryStore.java  |  2 +-
 .../e2e/dbprovider/TestDatabaseProvider.java    | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/bbec68b5/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index 5f77793..50507ea 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -644,7 +644,7 @@ public class SentryStore {
         query.setUnique(true);
         List<MSentryGroup> groups = Lists.newArrayList();
         for (TSentryGroup tGroup : groupNames) {
-          String groupName = tGroup.getGroupName().trim().toLowerCase();
+          String groupName = tGroup.getGroupName().trim();
           MSentryGroup group = (MSentryGroup) query.execute(groupName);
           if (group == null) {
             group = new MSentryGroup(groupName, System.currentTimeMillis(),
@@ -687,7 +687,7 @@ public class SentryStore {
         query.setUnique(true);
         List<MSentryGroup> groups = Lists.newArrayList();
         for (TSentryGroup tGroup : groupNames) {
-          String groupName = tGroup.getGroupName().trim().toLowerCase();
+          String groupName = tGroup.getGroupName().trim();
           MSentryGroup group = (MSentryGroup) query.execute(groupName);
           if (group != null) {
             group.removeRole(role);
@@ -863,7 +863,7 @@ public class SentryStore {
       } else {
         Query query = pm.newQuery(MSentryGroup.class);
         MSentryGroup sentryGroup;
-        groupName = groupName.trim().toLowerCase();
+        groupName = groupName.trim();
         query.setFilter("this.groupName == t");
         query.declareParameters("java.lang.String t");
         query.setUnique(true);
@@ -920,8 +920,8 @@ public class SentryStore {
       query.setFilter("this.groupName == t");
       query.declareParameters("java.lang.String t");
       query.setUnique(true);
-      for (String group : toTrimedLower(groups)) {
-        MSentryGroup sentryGroup = (MSentryGroup) query.execute(group);
+      for (String group : groups) {
+        MSentryGroup sentryGroup = (MSentryGroup) query.execute(group.trim());
         if (sentryGroup != null) {
           for (MSentryRole role : sentryGroup.getRoles()) {
             for (MSentryPrivilege privilege : role.getPrivileges()) {
@@ -950,8 +950,8 @@ public class SentryStore {
       query.setFilter("this.groupName == t");
       query.declareParameters("java.lang.String t");
       query.setUnique(true);
-      for (String group : toTrimedLower(groups)) {
-        MSentryGroup sentryGroup = (MSentryGroup) query.execute(group);
+      for (String group : groups) {
+        MSentryGroup sentryGroup = (MSentryGroup) query.execute(group.trim());
         if (sentryGroup != null) {
           for (MSentryRole role : sentryGroup.getRoles()) {
             result.add(role.getRoleName());

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/bbec68b5/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
index 6613d12..b23f477 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
@@ -73,7 +73,7 @@ public class TestSentryStore {
     }
   }
   @Test
-  public void testCaseInsensitiveRoleAndGroups() throws Exception {
+  public void testCaseInsensitiveRole() throws Exception {
     String roleName = "newRole";
     String grantor = "g1";
     Set<TSentryGroup> groups = Sets.newHashSet();

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/bbec68b5/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 83bf406..e2c39ea 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
@@ -1734,4 +1734,24 @@ public class TestDatabaseProvider extends AbstractTestWithStaticConfiguration
{
     connection.close();
   }
 
+  @Test
+  public void caseSensitiveGroupNames() throws Exception {
+    Connection connection = context.createConnection(ADMIN1);
+    Statement statement = context.createStatement(connection);
+    String testRole1 = "testRole1";
+    statement.execute("CREATE ROLE " + testRole1);
+    statement.execute("GRANT ROLE " + testRole1 + " TO GROUP " + ADMINGROUP);
+
+    ResultSet resultSet;
+    resultSet = statement.executeQuery("SHOW ROLE GRANT GROUP " + ADMINGROUP);
+    assertResultSize(resultSet, 1);
+
+    context.assertSentryException(statement, "SHOW ROLE GRANT GROUP Admin",
+        SentryNoSuchObjectException.class.getSimpleName());
+
+    statement.close();
+    connection.close();
+
+  }
+
 }


Mime
View raw message