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);
}
}
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);
}
}
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);
}
}
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;
}
}
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);
}
}
Aggregations