eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yonzhang2...@apache.org
Subject incubator-eagle git commit: EAGLE-104 fix unit test bug in hdfs security log parser fix unit test bug in hdfs security log parser Author: pmujumdar prasadm@apache.org Reviewer: yonzhang yonzhang2012@apache.org Closes: 61
Date Wed, 13 Jan 2016 01:17:05 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master db2bbf91b -> 90a1fb3f8


EAGLE-104 fix unit test bug in hdfs security log parser
fix unit test bug in hdfs security log parser
Author: pmujumdar prasadm@apache.org
Reviewer: yonzhang yonzhang2012@apache.org
Closes: 61


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

Branch: refs/heads/master
Commit: 90a1fb3f886c2246841dd4a3c0df8136946813a2
Parents: db2bbf9
Author: yonzhang <yonzhang@ebay.com>
Authored: Tue Jan 12 17:16:50 2016 -0800
Committer: yonzhang <yonzhang@ebay.com>
Committed: Tue Jan 12 17:16:50 2016 -0800

----------------------------------------------------------------------
 eagle-samples/pom.xml                           | 18 ++++++++-
 .../eagle/security/util/LogParseUtil.java       | 12 +++---
 .../security/TestHDFSSecuritylogParser.java     | 40 +++++++++++++++++---
 pom.xml                                         |  1 +
 4 files changed, 58 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/90a1fb3f/eagle-samples/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-samples/pom.xml b/eagle-samples/pom.xml
index 2c38539..48935d4 100644
--- a/eagle-samples/pom.xml
+++ b/eagle-samples/pom.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -16,4 +32,4 @@
     </modules>
 
 
-</project>
\ No newline at end of file
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/90a1fb3f/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/util/LogParseUtil.java
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/util/LogParseUtil.java
b/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/util/LogParseUtil.java
index 0c7f3cc..d1cb8b5 100644
--- a/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/util/LogParseUtil.java
+++ b/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/util/LogParseUtil.java
@@ -28,14 +28,14 @@ public class LogParseUtil {
      * 2)hadoop/123.dc1.xyz.com@xyz.com (auth:KERBEROS)
      * 3)hadoop (auth:KERBEROS)
      */
-    public static String parseUserFromUGI(String ugi) {
-        if(ugi == null) return null;
-        String newUgi = ugi.trim();
+    public static String parseUserFromUGI(String newUgi) {
+        if(newUgi == null) return null;
         int index = newUgi.indexOf("/");
-        if (index != -1) return newUgi.substring(0, index).trim();
+        if (index != -1) return newUgi.substring(0, index);
         index = newUgi.indexOf("@");
-        if (index != -1) return newUgi.substring(0, index).trim();
+        if (index != -1) return newUgi.substring(0, index);
         index = newUgi.indexOf("(");
-        return newUgi.substring(0, index).trim();
+        if (index != -1) return newUgi.substring(0, index).trim();
+        return newUgi.trim();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/90a1fb3f/eagle-security/eagle-security-hdfs-securitylog/src/test/java/org/apache/eagle/security/TestHDFSSecuritylogParser.java
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-hdfs-securitylog/src/test/java/org/apache/eagle/security/TestHDFSSecuritylogParser.java
b/eagle-security/eagle-security-hdfs-securitylog/src/test/java/org/apache/eagle/security/TestHDFSSecuritylogParser.java
index b72d05e..550e017 100644
--- a/eagle-security/eagle-security-hdfs-securitylog/src/test/java/org/apache/eagle/security/TestHDFSSecuritylogParser.java
+++ b/eagle-security/eagle-security-hdfs-securitylog/src/test/java/org/apache/eagle/security/TestHDFSSecuritylogParser.java
@@ -28,14 +28,42 @@ import java.text.ParseException;
 
 public class TestHDFSSecuritylogParser {
 
+  /**
+   * Test success log message with simple auth
+   * @throws ParseException
+   */
     @Test
-    public void test() throws ParseException {
-        String msg = "2015-11-18 08:41:10,200 INFO SecurityLogger.org.apache.hadoop.security.authorize.ServiceAuthorizationManager:
Authorization successful for hbase (auth:SIMPLE) for protocol=interface org.apache.hadoop.hdfs.protocol.ClientProtocol";
+    public void testSimpleAuth() throws ParseException {
+      String msg = "2015-11-18 08:41:10,200 INFO SecurityLogger.org.apache.hadoop.security.authorize.ServiceAuthorizationManager:
Authorization successful for hbase (auth:SIMPLE) for protocol=interface org.apache.hadoop.hdfs.protocol.ClientProtocol";
+      verifyParserAttributes(msg);
+    }
+
+    /**
+     * Test success log message with kerberos auth for service principal
+     * @throws ParseException
+     */
+    @Test
+    public void testServicePrincipalAuth() throws ParseException {
+      String msg = "2015-12-22 17:07:03,359 INFO SecurityLogger.org.apache.hadoop.security.authorize.ServiceAuthorizationManager:
Authorization successful for hbase/node1.foo.com@EXAMPLE.COM (auth:KERBEROS) for protocol=interface
org.apache.hadoop.hdfs.protocol.ClientProtocol";
+      verifyParserAttributes(msg);
+    }
+
+    /**
+     * Test success log message with kerberos auth for user principal
+     * @throws ParseException
+     */
+    @Test
+    public void testUserPrincipalAuth() throws ParseException {
+      String msg = "2015-12-22 17:07:03,359 INFO SecurityLogger.org.apache.hadoop.security.authorize.ServiceAuthorizationManager:
Authorization successful for hbase@EXAMPLE.COM (auth:KERBEROS) for protocol=interface org.apache.hadoop.hdfs.protocol.ClientProtocol";
+      verifyParserAttributes(msg);
+    }
+
+    private void verifyParserAttributes(String logMessage) throws ParseException {
+      HDFSSecurityLogParser parser = new HDFSSecurityLogParser();
+      HDFSSecurityLogObject obj = parser.parse(logMessage);
 
-        HDFSSecurityLogParser parser = new HDFSSecurityLogParser();
-        HDFSSecurityLogObject obj = parser.parse(msg);
+      Assert.assertEquals("hbase", obj.user);
+      Assert.assertEquals(true, obj.allowed);
 
-        Assert.assertEquals("hbase", obj.user);
-        Assert.assertEquals(true, obj.allowed);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/90a1fb3f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8da0859..d8b8158 100755
--- a/pom.xml
+++ b/pom.xml
@@ -892,6 +892,7 @@
                                 <exclude>**/*.log</exclude>
                                 <exclude>**/eagle.log*</exclude>
                                 <exclude>**/resources/**/*.json</exclude>
+                                <exclude>**/resources/eagle.siddhiext</exclude>
                                 <exclude>**/test/resources/securityAuditLog</exclude>
                                 <exclude>**/resources/**/ml-policyDef-UserProfile.txt</exclude>
                                 <exclude>**/test/resources/onelinehiveauditlog.txt</exclude>


Mime
View raw message