knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-529 - Fix wildcard based principal group mapping
Date Wed, 15 Apr 2015 00:15:58 GMT
Repository: knox
Updated Branches:
  refs/heads/v0.6.0 cb36dd988 -> 4528f6da9


KNOX-529 - Fix wildcard based principal group mapping


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/4528f6da
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/4528f6da
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/4528f6da

Branch: refs/heads/v0.6.0
Commit: 4528f6da9f85c98944a82716d8b257a55105a413
Parents: cb36dd9
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Tue Apr 14 20:14:49 2015 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Tue Apr 14 20:15:35 2015 -0400

----------------------------------------------------------------------
 .../security/principal/SimplePrincipalMapper.java  |  3 +++
 .../security/principal/PrincipalMapperTest.java    | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/4528f6da/gateway-spi/src/main/java/org/apache/hadoop/gateway/security/principal/SimplePrincipalMapper.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/security/principal/SimplePrincipalMapper.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/security/principal/SimplePrincipalMapper.java
index 6c91b2c..e1623e7 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/security/principal/SimplePrincipalMapper.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/security/principal/SimplePrincipalMapper.java
@@ -97,6 +97,9 @@ public class SimplePrincipalMapper implements PrincipalMapper {
     
     if (groupMappings != null) {
       groups = groupMappings.get(principalName);
+      if (groups == null) {
+        groups = groupMappings.get("*");
+      }
     }
     
     return groups;

http://git-wip-us.apache.org/repos/asf/knox/blob/4528f6da/gateway-spi/src/test/java/org/apache/hadoop/gateway/security/principal/PrincipalMapperTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/hadoop/gateway/security/principal/PrincipalMapperTest.java
b/gateway-spi/src/test/java/org/apache/hadoop/gateway/security/principal/PrincipalMapperTest.java
index e50f5b2..890a46f 100644
--- a/gateway-spi/src/test/java/org/apache/hadoop/gateway/security/principal/PrincipalMapperTest.java
+++ b/gateway-spi/src/test/java/org/apache/hadoop/gateway/security/principal/PrincipalMapperTest.java
@@ -37,6 +37,23 @@ public class PrincipalMapperTest {
   public void setup() {
     mapper = new SimplePrincipalMapper();
   }
+
+  @Test
+  public void testSimplePrincipalMappingWithWildcardGroups() {
+    String principalMapping = "";
+    String groupMapping = "*=users";
+    try {
+      mapper.loadMappingTable(principalMapping, groupMapping);
+    }
+    catch (PrincipalMappingException pme) {
+      pme.printStackTrace();
+      fail();
+    }
+    
+    assertTrue(mapper.mapUserPrincipal("lmccay").equals("lmccay"));
+    assertTrue(mapper.mapGroupPrincipal("hdfs")[0].equals("users"));
+    assertTrue(mapper.mapGroupPrincipal("lmccay")[0].equals("users"));
+  }
   
   @Test
   public void testNonNullSimplePrincipalMappingWithGroups() {


Mime
View raw message