use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UnderFileSystemConfigurationTest method containsWhenGlobalConfHasProperty.
@Test
public void containsWhenGlobalConfHasProperty() throws Exception {
// Unset property in global configuration
try (Closeable c = new ConfigurationRule(PropertyKey.S3A_ACCESS_KEY, "bar", mConfiguration).toResource()) {
Random random = new Random();
boolean readOnly = random.nextBoolean();
boolean shared = random.nextBoolean();
UnderFileSystemConfiguration conf = UnderFileSystemConfiguration.defaults(mConfiguration).setReadOnly(readOnly).setShared(shared);
assertTrue(conf.isSet(PropertyKey.S3A_ACCESS_KEY));
conf.createMountSpecificConf(ImmutableMap.of(PropertyKey.S3A_ACCESS_KEY.toString(), "foo"));
assertEquals(readOnly, conf.isReadOnly());
assertEquals(shared, conf.isShared());
assertTrue(conf.isSet(PropertyKey.S3A_ACCESS_KEY));
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class PermissionCheckTest method readNotExecuteDir.
@Test
public void readNotExecuteDir() throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "033", ServerConfiguration.global()).toResource()) {
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.ConfigurationRule in project alluxio by Alluxio.
the class PermissionCheckTest method freeNonNullDirectoryFail.
@Test
public void freeNonNullDirectoryFail() throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066", ServerConfiguration.global()).toResource()) {
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.ConfigurationRule in project alluxio by Alluxio.
the class PermissionCheckTest method createUnreadableFileOrDir.
private String createUnreadableFileOrDir(boolean isFile) throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066", ServerConfiguration.global()).toResource()) {
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.ConfigurationRule in project alluxio by Alluxio.
the class PermissionCheckTest method freeFileFail.
@Test
public void freeFileFail() throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066", ServerConfiguration.global()).toResource()) {
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