Search in sources :

Example 1 with SetAndRestoreAuthenticatedUser

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);
    }
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) MutableLockedInodePath(alluxio.master.file.meta.MutableLockedInodePath) LockedInodePath(alluxio.master.file.meta.LockedInodePath) SetAndRestoreAuthenticatedUser(alluxio.SetAndRestoreAuthenticatedUser) Mode(alluxio.security.authorization.Mode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with SetAndRestoreAuthenticatedUser

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);
    }
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) MutableLockedInodePath(alluxio.master.file.meta.MutableLockedInodePath) LockedInodePath(alluxio.master.file.meta.LockedInodePath) SetAndRestoreAuthenticatedUser(alluxio.SetAndRestoreAuthenticatedUser) Mode(alluxio.security.authorization.Mode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with SetAndRestoreAuthenticatedUser

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);
    }
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) MutableLockedInodePath(alluxio.master.file.meta.MutableLockedInodePath) LockedInodePath(alluxio.master.file.meta.LockedInodePath) SetAndRestoreAuthenticatedUser(alluxio.SetAndRestoreAuthenticatedUser) Mode(alluxio.security.authorization.Mode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with SetAndRestoreAuthenticatedUser

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());
    }
}
Also used : SetAndRestoreAuthenticatedUser(alluxio.SetAndRestoreAuthenticatedUser) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI)

Aggregations

SetAndRestoreAuthenticatedUser (alluxio.SetAndRestoreAuthenticatedUser)4 LockedInodePath (alluxio.master.file.meta.LockedInodePath)3 MutableLockedInodePath (alluxio.master.file.meta.MutableLockedInodePath)3 Mode (alluxio.security.authorization.Mode)3 ArrayList (java.util.ArrayList)3 ImmutableTriple (org.apache.commons.lang3.tuple.ImmutableTriple)3 Triple (org.apache.commons.lang3.tuple.Triple)3 Test (org.junit.Test)3 AlluxioURI (alluxio.AlluxioURI)1 FileInfo (alluxio.wire.FileInfo)1