From 2c66a9f5ae5d324dab8f59f47c1546f610109ec7 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 4 Oct 2012 02:06:56 +0000 Subject: [PATCH] HDFS-2127. Add a test that ensure AccessControlExceptions contain a full path. Contributed by Stephen Chu git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1393878 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/security/TestPermission.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 10b0e3f5b8..5930198fa8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -137,6 +137,9 @@ Trunk (Unreleased) HDFS-3880. Use Builder to build RPC server in HDFS. (Brandon Li vias suresh) + HDFS-2127. Add a test that ensure AccessControlExceptions contain + a full path. (Stephen Chu via eli) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java index 6de0c6952f..3d09f8b0c3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestPermission.java @@ -166,7 +166,7 @@ public void testCreate() throws Exception { } @Test - public void testFilePermision() throws Exception { + public void testFilePermission() throws Exception { final Configuration conf = new HdfsConfiguration(); conf.setBoolean(DFSConfigKeys.DFS_PERMISSIONS_ENABLED_KEY, true); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build(); @@ -244,6 +244,10 @@ static boolean canMkdirs(FileSystem fs, Path p) throws IOException { fs.mkdirs(p); return true; } catch(AccessControlException e) { + // We check that AccessControlExceptions contain absolute paths. + Path parent = p.getParent(); + assertTrue(parent.isUriPathAbsolute()); + assertTrue(e.getMessage().contains(parent.toString())); return false; } } @@ -253,6 +257,9 @@ static boolean canCreate(FileSystem fs, Path p) throws IOException { fs.create(p); return true; } catch(AccessControlException e) { + Path parent = p.getParent(); + assertTrue(parent.isUriPathAbsolute()); + assertTrue(e.getMessage().contains(parent.toString())); return false; } } @@ -262,6 +269,8 @@ static boolean canOpen(FileSystem fs, Path p) throws IOException { fs.open(p); return true; } catch(AccessControlException e) { + assertTrue(p.isUriPathAbsolute()); + assertTrue(e.getMessage().contains(p.toString())); return false; } } @@ -272,6 +281,9 @@ static boolean canRename(FileSystem fs, Path src, Path dst fs.rename(src, dst); return true; } catch(AccessControlException e) { + Path parent = dst.getParent(); + assertTrue(parent.isUriPathAbsolute()); + assertTrue(e.getMessage().contains(parent.toString())); return false; } }