Search in sources :

Example 11 with ConfigurationRule

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));
    }
}
Also used : Random(java.util.Random) Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 12 with ConfigurationRule

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);
    }
}
Also used : Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 13 with ConfigurationRule

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);
    }
}
Also used : Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 14 with ConfigurationRule

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;
    }
}
Also used : Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule)

Example 15 with ConfigurationRule

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);
    }
}
Also used : Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Aggregations

ConfigurationRule (alluxio.ConfigurationRule)42 Closeable (java.io.Closeable)42 Test (org.junit.Test)40 HashMap (java.util.HashMap)16 File (java.io.File)6 AlluxioURI (alluxio.AlluxioURI)5 PropertyKey (alluxio.conf.PropertyKey)5 SeekableUnderFileInputStream (alluxio.underfs.SeekableUnderFileInputStream)5 TieredIdentity (alluxio.wire.TieredIdentity)5 InputStream (java.io.InputStream)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)4 LocalityTier (alluxio.wire.TieredIdentity.LocalityTier)4 WorkerNetAddress (alluxio.wire.WorkerNetAddress)4 Random (java.util.Random)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 URIStatus (alluxio.client.file.URIStatus)3 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)2 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)2 ConnectDetails (alluxio.master.MasterInquireClient.ConnectDetails)2