Return-Path: X-Original-To: apmail-eagle-commits-archive@minotaur.apache.org Delivered-To: apmail-eagle-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C42BF18368 for ; Wed, 13 Jan 2016 01:17:15 +0000 (UTC) Received: (qmail 90036 invoked by uid 500); 13 Jan 2016 01:17:15 -0000 Delivered-To: apmail-eagle-commits-archive@eagle.apache.org Received: (qmail 90007 invoked by uid 500); 13 Jan 2016 01:17:15 -0000 Mailing-List: contact commits-help@eagle.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@eagle.incubator.apache.org Delivered-To: mailing list commits@eagle.incubator.apache.org Received: (qmail 89998 invoked by uid 99); 13 Jan 2016 01:17:15 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2016 01:17:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 34579180510 for ; Wed, 13 Jan 2016 01:17:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.228 X-Spam-Level: * X-Spam-Status: No, score=1.228 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, NORMAL_HTTP_TO_IP=0.001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id RORe5SywSNBr for ; Wed, 13 Jan 2016 01:17:06 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id C09A4439C4 for ; Wed, 13 Jan 2016 01:17:05 +0000 (UTC) Received: (qmail 89868 invoked by uid 99); 13 Jan 2016 01:17:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2016 01:17:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 44FB1E2C88; Wed, 13 Jan 2016 01:17:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yonzhang2012@apache.org To: commits@eagle.incubator.apache.org Message-Id: <069aaa4e1d7445c682c21ca40c396fff@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Tue Jan 12 17:16:50 2016 -0800 Committer: yonzhang 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 @@ + @@ -16,4 +32,4 @@ - \ No newline at end of file + 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 @@ **/*.log **/eagle.log* **/resources/**/*.json + **/resources/eagle.siddhiext **/test/resources/securityAuditLog **/resources/**/ml-policyDef-UserProfile.txt **/test/resources/onelinehiveauditlog.txt