You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ls...@apache.org on 2016/01/21 21:37:00 UTC
incubator-sentry git commit: SENTRY-991: Roles of Sentry Permission
needs to be case insensitive (Hao Hao via Lenni Kuff)
Repository: incubator-sentry
Updated Branches:
refs/heads/master cb92ceb3b -> 1b6fe629c
SENTRY-991: Roles of Sentry Permission needs to be case insensitive (Hao Hao via Lenni Kuff)
Change-Id: Id1d883e897a1f1f2345a5c8d7566ce45ebf45706
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/1b6fe629
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/1b6fe629
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/1b6fe629
Branch: refs/heads/master
Commit: 1b6fe629c9049b2246adf4913dd448afa4abf398
Parents: cb92ceb
Author: Lenni Kuff <ls...@cloudera.com>
Authored: Thu Jan 21 12:35:37 2016 -0800
Committer: Lenni Kuff <ls...@cloudera.com>
Committed: Thu Jan 21 12:35:37 2016 -0800
----------------------------------------------------------------------
.../apache/sentry/hdfs/SentryPermissions.java | 4 +-
.../sentry/hdfs/TestSentryPermissions.java | 40 ++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/1b6fe629/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java
index c61736f..107d3e1 100644
--- a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java
+++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java
@@ -77,8 +77,8 @@ public class SentryPermissions implements AuthzPermissions {
private final Map<String, PrivilegeInfo> privileges = new TreeMap<String, PrivilegeInfo>(String.CASE_INSENSITIVE_ORDER);
private Map<String, Set<String>> authzObjChildren = new TreeMap<String, Set<String>>(String.CASE_INSENSITIVE_ORDER);
- // Should the comparison of role be case insensitive?
- private final Map<String, RoleInfo> roles = new HashMap<String, RoleInfo>();
+ // RoleInfo should be case insensitive.
+ private final Map<String, RoleInfo> roles = new TreeMap<String, RoleInfo>(String.CASE_INSENSITIVE_ORDER);
String getParentAuthzObject(String authzObject) {
int dot = authzObject.indexOf('.');
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/1b6fe629/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java
new file mode 100644
index 0000000..dbce405
--- /dev/null
+++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java
@@ -0,0 +1,40 @@
+/**
+ * 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.sentry.hdfs;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test suits for components inside SentryPermissions.
+ */
+public class TestSentryPermissions {
+
+ @Test
+ public void testRoleInfoCaseInsensitive() {
+ SentryPermissions perm = new SentryPermissions();
+ SentryPermissions.RoleInfo roleInfo = new SentryPermissions.RoleInfo("Admin");
+ perm.addRoleInfo(roleInfo);
+
+ // RoleInfo is case insensitive.
+ Assert.assertNotNull(perm.getRoleInfo("admin"));
+ Assert.assertNull(perm.getRoleInfo("doesNotExist"));
+ }
+}