use of alluxio.security.authorization.AclEntry in project alluxio by Alluxio.
the class FileSystemMasterTest method removeExtendedAclMask.
@Test
public void removeExtendedAclMask() throws Exception {
mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext.mergeFrom(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);
}
use of alluxio.security.authorization.AclEntry in project alluxio by Alluxio.
the class FileSystemMasterTest method removeExtendedDefaultAclMask.
@Test
public void removeExtendedDefaultAclMask() throws Exception {
mFileSystemMaster.createDirectory(NESTED_URI, CreateDirectoryContext.mergeFrom(CreateDirectoryPOptions.newBuilder().setRecursive(true)));
AclEntry newAcl = AclEntry.fromCliString("default:user:newuser:rwx");
// Add an ACL
addAcl(NESTED_URI, newAcl);
assertThat(getInfo(NESTED_URI).getDefaultAcl().getEntries(), hasItem(newAcl));
// Attempt to remove the ACL mask
AclEntry maskEntry = AclEntry.fromCliString("default:mask::rwx");
assertThat(getInfo(NESTED_URI).getDefaultAcl().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);
}
use of alluxio.security.authorization.AclEntry in project alluxio by Alluxio.
the class FileSystemMasterTest method setAclWithoutOwner.
@Test
public void setAclWithoutOwner() throws Exception {
createFileWithSingleBlock(NESTED_FILE_URI);
mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder().setMode(new Mode((short) 0777).toProto())));
Set<String> entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT).convertAclToStringEntries());
assertEquals(3, entries.size());
try (AuthenticatedClientUserResource userA = new AuthenticatedClientUserResource("userA", ServerConfiguration.global())) {
Set<String> newEntries = Sets.newHashSet("user::rwx", "group::rwx", "other::rwx");
mThrown.expect(AccessControlException.class);
mFileSystemMaster.setAcl(NESTED_FILE_URI, SetAclAction.REPLACE, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), SetAclContext.defaults());
}
}
use of alluxio.security.authorization.AclEntry in project alluxio by Alluxio.
the class FileSystemMasterTest method setDefaultAclforFile.
@Test
public void setDefaultAclforFile() throws Exception {
SetAclContext context = SetAclContext.defaults();
createFileWithSingleBlock(NESTED_FILE_URI);
Set<String> newEntries = Sets.newHashSet("default:user::rwx", "default:group::rwx", "default:other::r-x");
mThrown.expect(UnsupportedOperationException.class);
mFileSystemMaster.setAcl(NESTED_FILE_URI, SetAclAction.MODIFY, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
}
use of alluxio.security.authorization.AclEntry in project alluxio by Alluxio.
the class FileSystemMasterTest method setDefaultAcl.
@Test
public void setDefaultAcl() throws Exception {
SetAclContext context = SetAclContext.defaults();
createFileWithSingleBlock(NESTED_FILE_URI);
Set<String> entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertEquals(0, entries.size());
// replace
Set<String> newEntries = Sets.newHashSet("default:user::rwx", "default:group::rwx", "default:other::r-x");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.REPLACE, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertEquals(newEntries, entries);
// replace
newEntries = Sets.newHashSet("default:user::rw-", "default:group::r--", "default:other::r--");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.REPLACE, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertEquals(newEntries, entries);
// modify existing
newEntries = Sets.newHashSet("default:user::rwx", "default:group::rw-", "default:other::r-x");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.MODIFY, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertEquals(newEntries, entries);
// modify add
Set<String> oldEntries = new HashSet<>(entries);
newEntries = Sets.newHashSet("default:user:usera:---", "default:group:groupa:--x");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.MODIFY, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertTrue(entries.containsAll(oldEntries));
assertTrue(entries.containsAll(newEntries));
assertTrue(entries.contains("default:mask::rwx"));
// modify existing and add
newEntries = Sets.newHashSet("default:user:usera:---", "default:group:groupa:--x", "default:other::r-x");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.MODIFY, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertTrue(entries.containsAll(newEntries));
// remove default
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.REMOVE_DEFAULT, Collections.emptyList(), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertEquals(0, entries.size());
// remove
newEntries = Sets.newHashSet("default:user:usera:---", "default:user:userb:rwx", "default:group:groupa:--x", "default:group:groupb:-wx");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.MODIFY, newEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
oldEntries = new HashSet<>(entries);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
assertTrue(entries.containsAll(oldEntries));
Set<String> deleteEntries = Sets.newHashSet("default:user:userb:rwx", "default:group:groupa:--x");
mFileSystemMaster.setAcl(NESTED_URI, SetAclAction.REMOVE, deleteEntries.stream().map(AclEntry::fromCliString).collect(Collectors.toList()), context);
entries = Sets.newHashSet(mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT).convertDefaultAclToStringEntries());
Set<String> remainingEntries = new HashSet<>(newEntries);
assertTrue(remainingEntries.removeAll(deleteEntries));
assertTrue(entries.containsAll(remainingEntries));
final Set<String> finalEntries = entries;
assertTrue(deleteEntries.stream().noneMatch(finalEntries::contains));
}
Aggregations