Search in sources :

Example 1 with SetAndRestoreConfiguration

use of alluxio.SetAndRestoreConfiguration in project alluxio by Alluxio.

the class PermissionCheckTest method readNotExecuteDir.

@Test
public void readNotExecuteDir() throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "033")) {
        String dir = PathUtils.concatPath(TEST_DIR_URI, "/notExecuteDir");
        // create dir "/testDir/notExecuteDir" [user1, group1, drwxr--r--]
        verifyCreateDirectory(TEST_USER_1, dir, false);
        verifyRead(TEST_USER_1, dir, false);
        mThrown.expect(AccessControlException.class);
        mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.EXECUTE, dir, "notExecuteDir")));
        verifyGetFileInfoOrList(TEST_USER_2, dir, false);
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) Test(org.junit.Test)

Example 2 with SetAndRestoreConfiguration

use of alluxio.SetAndRestoreConfiguration in project alluxio by Alluxio.

the class PermissionCheckTest method completeFileFail.

@Test
public void completeFileFail() throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066")) {
        String file = PathUtils.concatPath(TEST_DIR_URI, "/testComplete1");
        verifyCreateFile(TEST_USER_1, file, false);
        CompleteFileOptions expect = getNonDefaultCompleteFileOptions();
        mThrown.expect(AccessControlException.class);
        mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.WRITE, file, "testComplete1")));
        verifyCompleteFile(TEST_USER_2, file, expect);
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) CompleteFileOptions(alluxio.master.file.options.CompleteFileOptions) Test(org.junit.Test)

Example 3 with SetAndRestoreConfiguration

use of alluxio.SetAndRestoreConfiguration in project alluxio by Alluxio.

the class PermissionCheckTest method freeNonNullDirectoryFail.

@Test
public void freeNonNullDirectoryFail() throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066")) {
        String file = PathUtils.concatPath(TEST_DIR_URI + "/testComplete1");
        verifyCreateFile(TEST_USER_1, file, false);
        mThrown.expect(AccessControlException.class);
        mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.READ, file, "testComplete1")));
        verifyFree(TEST_USER_2, file, false);
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) Test(org.junit.Test)

Example 4 with SetAndRestoreConfiguration

use of alluxio.SetAndRestoreConfiguration in project alluxio by Alluxio.

the class PermissionCheckTest method createUnreadableFileOrDir.

private String createUnreadableFileOrDir(boolean isFile) throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066")) {
        String fileOrDir = PathUtils.concatPath(TEST_DIR_URI, "/onlyReadByUser1");
        if (isFile) {
            // create file "/testDir/onlyReadByUser1" [user1, group1, -rw-------]
            verifyCreateFile(TEST_USER_1, fileOrDir, false);
            verifyRead(TEST_USER_1, fileOrDir, true);
        } else {
            // create dir "/testDir/onlyReadByUser1" [user1, group1, drwx--x--x]
            verifyCreateDirectory(TEST_USER_1, fileOrDir, false);
            verifyRead(TEST_USER_1, fileOrDir, false);
        }
        return fileOrDir;
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration)

Example 5 with SetAndRestoreConfiguration

use of alluxio.SetAndRestoreConfiguration in project alluxio by Alluxio.

the class PermissionCheckTest method freeFileFail.

@Test
public void freeFileFail() throws Exception {
    // set unmask
    try (SetAndRestoreConfiguration c = new SetAndRestoreConfiguration(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066")) {
        String file = PathUtils.concatPath(TEST_DIR_URI, "testComplete1");
        verifyCreateFile(TEST_USER_1, file, false);
        mThrown.expect(AccessControlException.class);
        mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.READ, file, "testComplete1")));
        verifyFree(TEST_USER_2, file, false);
    }
}
Also used : SetAndRestoreConfiguration(alluxio.SetAndRestoreConfiguration) Test(org.junit.Test)

Aggregations

SetAndRestoreConfiguration (alluxio.SetAndRestoreConfiguration)8 Test (org.junit.Test)7 CompleteFileOptions (alluxio.master.file.options.CompleteFileOptions)2 SetAttributeOptions (alluxio.master.file.options.SetAttributeOptions)2