/** * @return the ACL entries for this path, mutable */ public AccessControlList getAcl() { return mInfo.getAcl(); }
@Test public void inheritNonExtendedDefaultAcl() throws Exception { AlluxioURI dir = new AlluxioURI("/dir"); mFileSystemMaster.createDirectory(dir, CreateDirectoryContext.defaults()); String aclString = "default:user::-w-"; mFileSystemMaster.setAcl(dir, SetAclAction.MODIFY, Arrays.asList(AclEntry.fromCliString(aclString)), SetAclContext.defaults()); AlluxioURI inner = new AlluxioURI("/dir/inner"); mFileSystemMaster.createDirectory(inner, CreateDirectoryContext.defaults()); FileInfo fileInfo = mFileSystemMaster.getFileInfo(inner, GetStatusContext.defaults()); List<String> accessEntries = fileInfo.getAcl().toStringEntries(); assertTrue(accessEntries.toString(), accessEntries.contains("user::-w-")); List<String> defaultEntries = fileInfo.getDefaultAcl().toStringEntries(); assertTrue(defaultEntries.toString(), defaultEntries.contains(aclString)); }
@Test public void inheritExtendedDefaultAcl() throws Exception { AlluxioURI dir = new AlluxioURI("/dir"); mFileSystemMaster.createDirectory(dir, CreateDirectoryContext.defaults()); String aclString = "default:user:foo:-w-"; mFileSystemMaster.setAcl(dir, SetAclAction.MODIFY, Arrays.asList(AclEntry.fromCliString(aclString)), SetAclContext.defaults()); AlluxioURI inner = new AlluxioURI("/dir/inner"); mFileSystemMaster.createDirectory(inner, CreateDirectoryContext.defaults()); FileInfo fileInfo = mFileSystemMaster.getFileInfo(inner, GetStatusContext.defaults()); List<String> accessEntries = fileInfo.getAcl().toStringEntries(); assertTrue(accessEntries.toString(), accessEntries.contains("user:foo:-w-")); List<String> defaultEntries = fileInfo.getDefaultAcl().toStringEntries(); assertTrue(defaultEntries.toString(), defaultEntries.contains(aclString)); }
@Test public void removeExtendedAclMask() throws Exception { mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext .defaults(CreateDirectoryPOptions.newBuilder().setRecursive(true))); AclEntry newAcl = AclEntry.fromCliString("user:newuser:rwx"); // Add an ACL addAcl(NESTED_URI, newAcl); assertThat(getInfo(NESTED_URI).getAcl().getEntries(), hasItem(newAcl)); // Attempt to remove the ACL mask AclEntry maskEntry = AclEntry.fromCliString("mask::rwx"); assertThat(getInfo(NESTED_URI).getAcl().getEntries(), hasItem(maskEntry)); try { removeAcl(NESTED_URI, maskEntry); fail("Expected removing the mask from an extended ACL to fail"); } catch (IOException e) { assertThat(e.getMessage(), containsString("mask")); } // Remove the extended ACL removeAcl(NESTED_URI, newAcl); // Now we can add and remove a mask addAcl(NESTED_URI, maskEntry); removeAcl(NESTED_URI, maskEntry); }