HADOOP-15793. ABFS: Skip unsupported test cases when non namespace enabled in ITestAzureBlobFileSystemAuthorization

Contributed by Yuan Gao.
This commit is contained in:
Steve Loughran 2018-10-02 11:37:28 +01:00
parent 5689355783
commit 43bc984891
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0

View File

@ -35,6 +35,7 @@
import static org.apache.hadoop.fs.permission.AclEntryScope.ACCESS; import static org.apache.hadoop.fs.permission.AclEntryScope.ACCESS;
import static org.apache.hadoop.fs.permission.AclEntryType.GROUP; import static org.apache.hadoop.fs.permission.AclEntryType.GROUP;
import static org.apache.hadoop.test.LambdaTestUtils.intercept; import static org.apache.hadoop.test.LambdaTestUtils.intercept;
import static org.junit.Assume.assumeTrue;
/** /**
* Test Perform Authorization Check operation * Test Perform Authorization Check operation
@ -202,6 +203,7 @@ public void testGetFileStatusUnauthorized() throws Exception {
@Test @Test
public void testSetOwnerAuthorized() throws Exception { public void testSetOwnerAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
fs.setOwner(TEST_WRITE_ONLY_FILE_PATH_0, "testUser", "testGroup"); fs.setOwner(TEST_WRITE_ONLY_FILE_PATH_0, "testUser", "testGroup");
} }
@ -209,6 +211,7 @@ public void testSetOwnerAuthorized() throws Exception {
@Test @Test
public void testSetOwnerUnauthorized() throws Exception { public void testSetOwnerUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
()-> { ()-> {
@ -219,6 +222,7 @@ public void testSetOwnerUnauthorized() throws Exception {
@Test @Test
public void testSetPermissionAuthorized() throws Exception { public void testSetPermissionAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
fs.setPermission(TEST_WRITE_ONLY_FILE_PATH_0, new FsPermission(FsAction.ALL, FsAction.NONE, FsAction.NONE)); 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 @Test
public void testSetPermissionUnauthorized() throws Exception { public void testSetPermissionUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
()-> { ()-> {
@ -236,6 +241,7 @@ public void testSetPermissionUnauthorized() throws Exception {
@Test @Test
public void testModifyAclEntriesAuthorized() throws Exception { public void testModifyAclEntriesAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
fs.modifyAclEntries(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec); fs.modifyAclEntries(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec);
@ -244,6 +250,7 @@ public void testModifyAclEntriesAuthorized() throws Exception {
@Test @Test
public void testModifyAclEntriesUnauthorized() throws Exception { public void testModifyAclEntriesUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
@ -255,15 +262,16 @@ public void testModifyAclEntriesUnauthorized() throws Exception {
@Test @Test
public void testRemoveAclEntriesAuthorized() throws Exception { public void testRemoveAclEntriesAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> 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); fs.removeAclEntries(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec);
} }
@Test @Test
public void testRemoveAclEntriesUnauthorized() throws Exception { public void testRemoveAclEntriesUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
@ -275,6 +283,7 @@ public void testRemoveAclEntriesUnauthorized() throws Exception {
@Test @Test
public void testRemoveDefaultAclAuthorized() throws Exception { public void testRemoveDefaultAclAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
fs.removeDefaultAcl(TEST_WRITE_ONLY_FILE_PATH_0); fs.removeDefaultAcl(TEST_WRITE_ONLY_FILE_PATH_0);
} }
@ -282,6 +291,7 @@ public void testRemoveDefaultAclAuthorized() throws Exception {
@Test @Test
public void testRemoveDefaultAclUnauthorized() throws Exception { public void testRemoveDefaultAclUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
()-> { ()-> {
@ -292,6 +302,7 @@ public void testRemoveDefaultAclUnauthorized() throws Exception {
@Test @Test
public void testRemoveAclAuthorized() throws Exception { public void testRemoveAclAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
fs.removeAcl(TEST_WRITE_ONLY_FILE_PATH_0); fs.removeAcl(TEST_WRITE_ONLY_FILE_PATH_0);
} }
@ -299,6 +310,7 @@ public void testRemoveAclAuthorized() throws Exception {
@Test @Test
public void testRemoveAclUnauthorized() throws Exception { public void testRemoveAclUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
()-> { ()-> {
@ -309,6 +321,7 @@ public void testRemoveAclUnauthorized() throws Exception {
@Test @Test
public void testSetAclAuthorized() throws Exception { public void testSetAclAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
fs.setAcl(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec); fs.setAcl(TEST_WRITE_ONLY_FILE_PATH_0, aclSpec);
@ -317,6 +330,7 @@ public void testSetAclAuthorized() throws Exception {
@Test @Test
public void testSetAclUnauthorized() throws Exception { public void testSetAclUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,
@ -328,6 +342,7 @@ public void testSetAclUnauthorized() throws Exception {
@Test @Test
public void testGetAclStatusAuthorized() throws Exception { public void testGetAclStatusAuthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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(); fs.create(TEST_WRITE_THEN_READ_ONLY_PATH).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
fs.getAclStatus(TEST_WRITE_THEN_READ_ONLY_PATH); fs.getAclStatus(TEST_WRITE_THEN_READ_ONLY_PATH);
@ -336,6 +351,7 @@ public void testGetAclStatusAuthorized() throws Exception {
@Test @Test
public void testGetAclStatusUnauthorized() throws Exception { public void testGetAclStatusUnauthorized() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); 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.create(TEST_WRITE_ONLY_FILE_PATH_0).close();
List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL)); List<AclEntry> aclSpec = Arrays.asList(aclEntry(ACCESS, GROUP, "bar", FsAction.ALL));
intercept(AbfsAuthorizationException.class, intercept(AbfsAuthorizationException.class,