use of alluxio.SetAndRestoreAuthenticatedUser in project alluxio by Alluxio.
the class PermissionCheckTest method getPermissionOwner.
@Test
public void getPermissionOwner() throws Exception {
ArrayList<Triple<String, String, Mode>> permissions = new ArrayList<>();
permissions.add(new ImmutableTriple<>(TEST_USER_1.getUser(), TEST_USER_1.getGroup(), new Mode((short) 0754)));
LockedInodePath lockedInodePath = getLockedInodePath(permissions);
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(TEST_USER_1.getUser())) {
PermissionChecker checker = new PermissionChecker(mInodeTree);
Mode.Bits actual = checker.getPermission(lockedInodePath);
Assert.assertEquals(Mode.Bits.ALL, actual);
}
}
use of alluxio.SetAndRestoreAuthenticatedUser in project alluxio by Alluxio.
the class PermissionCheckTest method getPermissionOther.
@Test
public void getPermissionOther() throws Exception {
ArrayList<Triple<String, String, Mode>> permissions = new ArrayList<>();
permissions.add(new ImmutableTriple<>(TEST_USER_1.getUser(), TEST_USER_1.getGroup(), new Mode((short) 0754)));
LockedInodePath lockedInodePath = getLockedInodePath(permissions);
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(TEST_USER_2.getUser())) {
PermissionChecker checker = new PermissionChecker(mInodeTree);
Mode.Bits actual = checker.getPermission(lockedInodePath);
Assert.assertEquals(Mode.Bits.READ, actual);
}
}
use of alluxio.SetAndRestoreAuthenticatedUser in project alluxio by Alluxio.
the class PermissionCheckTest method getPermissionGroup.
@Test
public void getPermissionGroup() throws Exception {
ArrayList<Triple<String, String, Mode>> permissions = new ArrayList<>();
permissions.add(new ImmutableTriple<>(TEST_USER_1.getUser(), TEST_USER_1.getGroup(), new Mode((short) 0754)));
LockedInodePath lockedInodePath = getLockedInodePath(permissions);
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(TEST_USER_3.getUser())) {
PermissionChecker checker = new PermissionChecker(mInodeTree);
Mode.Bits actual = checker.getPermission(lockedInodePath);
Assert.assertEquals(Mode.Bits.READ_EXECUTE, actual);
}
}
use of alluxio.SetAndRestoreAuthenticatedUser in project alluxio by Alluxio.
the class PermissionCheckTest method verifySetState.
private SetAttributeOptions verifySetState(TestUser user, String path, SetAttributeOptions options) throws Exception {
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(user.getUser())) {
mFileSystemMaster.setAttribute(new AlluxioURI(path), options);
FileInfo fileInfo = mFileSystemMaster.getFileInfo(new AlluxioURI(path));
return SetAttributeOptions.defaults().setPinned(fileInfo.isPinned()).setTtl(fileInfo.getTtl()).setPersisted(fileInfo.isPersisted());
}
}
Aggregations