use of alluxio.AuthenticatedUserRule in project alluxio by Alluxio.
the class PermissionCheckTest method verifyRename.
private void verifyRename(TestUser user, String srcPath, String dstPath) throws Exception {
try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) {
String fileOwner = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(srcPath))).getOwner();
mFileSystemMaster.rename(new AlluxioURI(srcPath), new AlluxioURI(dstPath), RenameContext.defaults());
assertEquals(-1, mFileSystemMaster.getFileId(new AlluxioURI(srcPath)));
FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(dstPath)));
String[] pathComponents = dstPath.split("/");
assertEquals(pathComponents[pathComponents.length - 1], fileInfo.getName());
assertEquals(fileOwner, fileInfo.getOwner());
}
}
use of alluxio.AuthenticatedUserRule in project alluxio by Alluxio.
the class PermissionCheckTest method verifySetAcl.
private void verifySetAcl(TestUser runUser, String path, String owner, String group, short mode, boolean recursive) throws Exception {
try (Closeable r = new AuthenticatedUserRule(runUser.getUser(), ServerConfiguration.global()).toResource()) {
SetAttributeContext context = SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder().setMode(new Mode(mode).toProto()).setRecursive(recursive));
if (owner != null) {
context.getOptions().setOwner(owner);
}
if (group != null) {
context.getOptions().setGroup(group);
}
mFileSystemMaster.setAttribute(new AlluxioURI(path), context);
}
try (Closeable r = new AuthenticatedUserRule(TEST_USER_ADMIN.getUser(), ServerConfiguration.global()).toResource()) {
FileInfo fileInfo = mFileSystemMaster.getFileInfo(mFileSystemMaster.getFileId(new AlluxioURI(path)));
if (owner != null) {
assertEquals(owner, fileInfo.getOwner());
}
if (group != null) {
assertEquals(group, fileInfo.getGroup());
}
if (mode != -1) {
assertEquals(mode, fileInfo.getMode());
}
}
}
use of alluxio.AuthenticatedUserRule in project alluxio by Alluxio.
the class PermissionCheckTest method verifyCreateFile.
private void verifyCreateFile(TestUser user, String path, boolean recursive) throws Exception {
try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) {
CreateFileContext context = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setRecursive(recursive)).setOwner(SecurityUtils.getOwnerFromGrpcClient(ServerConfiguration.global())).setGroup(SecurityUtils.getGroupFromGrpcClient(ServerConfiguration.global())).setWriteType(WriteType.CACHE_THROUGH);
FileInfo fileInfo = mFileSystemMaster.createFile(new AlluxioURI(path), context);
String[] pathComponents = path.split("/");
assertEquals(pathComponents[pathComponents.length - 1], fileInfo.getName());
assertEquals(user.getUser(), fileInfo.getOwner());
}
}
Aggregations