use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class FileSystemMasterTest method deleteDirRecursiveWithInsufficientPermissions.
@Test
public void deleteDirRecursiveWithInsufficientPermissions() throws Exception {
// userA has permissions to delete directory but not one of the nested files
createFileWithSingleBlock(NESTED_FILE_URI);
createFileWithSingleBlock(NESTED_FILE2_URI);
mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder().setMode(new Mode((short) 0777).toProto())));
mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder().setMode(new Mode((short) 0700).toProto())));
mFileSystemMaster.setAttribute(NESTED_FILE2_URI, SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder().setMode(new Mode((short) 0777).toProto())));
try (AuthenticatedClientUserResource userA = new AuthenticatedClientUserResource("userA", ServerConfiguration.global())) {
mFileSystemMaster.delete(NESTED_URI, DeleteContext.mergeFrom(DeletePOptions.newBuilder().setRecursive(true)));
fail("Deleting a directory w/ insufficient permission on child should fail");
} catch (AccessControlException e) {
String expectedChildMessage = ExceptionMessage.PERMISSION_DENIED.getMessage("user=userA, access=-w-, path=" + NESTED_FILE_URI + ": failed at file");
assertTrue(e.getMessage().startsWith(ExceptionMessage.DELETE_FAILED_DIR_CHILDREN.getMessage(NESTED_URI, expectedChildMessage)));
}
assertNotEquals(IdUtils.INVALID_FILE_ID, mFileSystemMaster.getFileId(NESTED_URI));
assertNotEquals(IdUtils.INVALID_FILE_ID, mFileSystemMaster.getFileId(NESTED_FILE_URI));
assertNotEquals(IdUtils.INVALID_FILE_ID, mFileSystemMaster.getFileId(NESTED_FILE2_URI));
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method deleteFile.
@Test
public void deleteFile() throws IOException, AlluxioException {
AlluxioURI fileUri = new AlluxioURI(FILE_PATH);
try {
mFileSystem.delete(fileUri);
Assert.fail("deleteFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(fileUri, MOUNT_PATH)));
}
Assert.assertTrue(mFileSystem.exists(fileUri));
Assert.assertNotNull(mFileSystem.getStatus(fileUri));
fileUri = new AlluxioURI(SUB_FILE_PATH);
try {
mFileSystem.delete(fileUri);
Assert.fail("deleteFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(fileUri, MOUNT_PATH)));
}
Assert.assertTrue(mFileSystem.exists(fileUri));
Assert.assertNotNull(mFileSystem.getStatus(fileUri));
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method chgrp.
@Test
public void chgrp() throws IOException, AlluxioException {
AlluxioURI uri = new AlluxioURI(FILE_PATH + "_chgrp");
try {
mFileSystem.setAttribute(uri, SetAttributePOptions.newBuilder().setGroup("foo").build());
Assert.fail("chgrp should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method createDirectory.
@Test
public void createDirectory() throws IOException, AlluxioException {
AlluxioURI uri = new AlluxioURI(PathUtils.concatPath(MOUNT_PATH, "create"));
try {
mFileSystem.createDirectory(uri);
Assert.fail("createDirectory should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
uri = new AlluxioURI(PathUtils.concatPath(SUB_DIR_PATH, "create"));
try {
mFileSystem.createDirectory(uri);
Assert.fail("createDirectory should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
}
use of alluxio.exception.AccessControlException in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method createFile.
@Test
public void createFile() throws IOException, AlluxioException {
CreateFilePOptions writeBoth = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
AlluxioURI uri = new AlluxioURI(FILE_PATH + "_create");
try {
mFileSystem.createFile(uri, writeBoth).close();
Assert.fail("createFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
uri = new AlluxioURI(SUB_FILE_PATH + "_create");
try {
mFileSystem.createFile(uri, writeBoth).close();
Assert.fail("createFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
}
Aggregations