From 43bc9848914cee5e03a9965eb2165f42efb2c35d Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Tue, 2 Oct 2018 11:37:28 +0100 Subject: [PATCH] HADOOP-15793. ABFS: Skip unsupported test cases when non namespace enabled in ITestAzureBlobFileSystemAuthorization Contributed by Yuan Gao. --- .../ITestAzureBlobFileSystemAuthorization.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemAuthorization.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemAuthorization.java index 37ab825dfd..1705516977 100644 --- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemAuthorization.java +++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemAuthorization.java @@ -35,6 +35,7 @@ import static org.apache.hadoop.fs.permission.AclEntryScope.ACCESS; import static org.apache.hadoop.fs.permission.AclEntryType.GROUP; import static org.apache.hadoop.test.LambdaTestUtils.intercept; +import static org.junit.Assume.assumeTrue; /** * Test Perform Authorization Check operation @@ -202,6 +203,7 @@ public void testGetFileStatusUnauthorized() throws Exception { @Test public void testSetOwnerAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); fs.setOwner(TEST_WRITE_ONLY_FILE_PATH_0, "testUser", "testGroup"); } @@ -209,6 +211,7 @@ public void testSetOwnerAuthorized() throws Exception { @Test public void testSetOwnerUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); intercept(AbfsAuthorizationException.class, ()-> { @@ -219,6 +222,7 @@ public void testSetOwnerUnauthorized() throws Exception { @Test public void testSetPermissionAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); fs.setPermission(TEST_WRITE_ONLY_FILE_PATH_0, new FsPermission(FsAction.ALL, FsAction.NONE, FsAction.NONE)); } @@ -226,6 +230,7 @@ public void testSetPermissionAuthorized() throws Exception { @Test public void testSetPermissionUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); intercept(AbfsAuthorizationException.class, ()-> { @@ -236,6 +241,7 @@ public void testSetPermissionUnauthorized() throws Exception { @Test public void testModifyAclEntriesAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); fs.modifyAclEntries(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec); @@ -244,6 +250,7 @@ public void testModifyAclEntriesAuthorized() throws Exception { @Test public void testModifyAclEntriesUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); intercept(AbfsAuthorizationException.class, @@ -255,15 +262,16 @@ public void testModifyAclEntriesUnauthorized() throws Exception { @Test public void testRemoveAclEntriesAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); - //fs.modifyAclEntries(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec); fs.removeAclEntries(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec); } @Test public void testRemoveAclEntriesUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); intercept(AbfsAuthorizationException.class, @@ -275,6 +283,7 @@ public void testRemoveAclEntriesUnauthorized() throws Exception { @Test public void testRemoveDefaultAclAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); fs.removeDefaultAcl(TEST_WRITE_ONLY_FILE_PATH_0); } @@ -282,6 +291,7 @@ public void testRemoveDefaultAclAuthorized() throws Exception { @Test public void testRemoveDefaultAclUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); intercept(AbfsAuthorizationException.class, ()-> { @@ -292,6 +302,7 @@ public void testRemoveDefaultAclUnauthorized() throws Exception { @Test public void testRemoveAclAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); fs.removeAcl(TEST_WRITE_ONLY_FILE_PATH_0); } @@ -299,6 +310,7 @@ public void testRemoveAclAuthorized() throws Exception { @Test public void testRemoveAclUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); intercept(AbfsAuthorizationException.class, ()-> { @@ -309,6 +321,7 @@ public void testRemoveAclUnauthorized() throws Exception { @Test public void testSetAclAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); fs.setAcl(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec); @@ -317,6 +330,7 @@ public void testSetAclAuthorized() throws Exception { @Test public void testSetAclUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); intercept(AbfsAuthorizationException.class, @@ -328,6 +342,7 @@ public void testSetAclUnauthorized() throws Exception { @Test public void testGetAclStatusAuthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); fs.getAclStatus(TEST_WRITE_THEN_READ_ONLY_PATH); @@ -336,6 +351,7 @@ public void testGetAclStatusAuthorized() throws Exception { @Test public void testGetAclStatusUnauthorized() throws Exception { final AzureBlobFileSystem fs = getFileSystem(); + assumeTrue("This test case only runs when namespace is enabled", fs.getIsNamespaceEnabeld()); fs.create(TEST_WRITE_ONLY_FILE_PATH_0).close(); List aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); intercept(AbfsAuthorizationException.class,