Search in sources :

Example 1 with TestUserState

use of alluxio.security.user.TestUserState in project alluxio by Alluxio.

the class PermissionCheckTest method before.

@Before
public void before() throws Exception {
    ServerConfiguration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, mTestFolder.newFolder());
    GroupMappingServiceTestUtils.resetCache();
    mRegistry = new MasterRegistry();
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext(new NoopJournalSystem(), new TestUserState(TEST_USER_ADMIN.getUser(), ServerConfiguration.global()));
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    new BlockMasterFactory().create(mRegistry, masterContext);
    mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, masterContext);
    mRegistry.start(true);
    createDirAndFileForTest();
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) TestUserState(alluxio.security.user.TestUserState) MasterRegistry(alluxio.master.MasterRegistry) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Example 2 with TestUserState

use of alluxio.security.user.TestUserState in project alluxio by Alluxio.

the class ClusterInitializationIntegrationTest method recoverClusterFail.

/**
 * When a user starts a cluster with journal logs, which are generated by previous running
 * cluster owned by a different user, it should fail and throw an exception.
 */
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void recoverClusterFail() throws Exception {
    FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
    fs.createFile(new AlluxioURI("/testFile")).close();
    mLocalAlluxioClusterResource.get().stopFS();
    mThrown.expect(PermissionDeniedException.class);
    mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage("Unauthorized user on root"));
    // user jack cannot recover master from journal, in which the root is owned by alluxio.
    MasterTestUtils.createLeaderFileSystemMasterFromJournal(new TestUserState(USER, ServerConfiguration.global())).close();
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 3 with TestUserState

use of alluxio.security.user.TestUserState in project alluxio by Alluxio.

the class SetFaclCommandIntegrationTest method createFiles.

// Helper function to create a set of files in the file system
private URIStatus[] createFiles(String user) throws IOException, AlluxioException {
    FileSystem fs = sFileSystem;
    if (user != null) {
        fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState(user, ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
    }
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WritePType.MUST_CACHE, 10);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WritePType.MUST_CACHE, 20);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WritePType.THROUGH, 30);
    URIStatus[] files = new URIStatus[4];
    files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA"));
    files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir"));
    files[2] = fs.getStatus(new AlluxioURI("/testRoot/testDir/testFileB"));
    files[3] = fs.getStatus(new AlluxioURI("/testRoot/testFileC"));
    return files;
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 4 with TestUserState

use of alluxio.security.user.TestUserState in project alluxio by Alluxio.

the class LsCommandSecurityIntegrationTest method lsWildcard.

/**
 * Tests ls command with wildcard when security is enabled.
 */
@Test
public void lsWildcard() throws Exception {
    FileSystem fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState("test_user_ls", ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
    String testDir = FileSystemShellUtilsTest.resetFileHierarchy(fs);
    sFsShell.run("ls", testDir + "/*/foo*");
    // CHECKSTYLE.OFF: LineLengthExceed - Improve readability
    checkOutput("-rw-r--r--  test_user_ls   test_user_ls                30   NOT_PERSISTED .+ .+ 100% /testDir/bar/foobar3", "-rw-r--r--  test_user_ls   test_user_ls                10   NOT_PERSISTED .+ .+ 100% /testDir/foo/foobar1", "-rw-r--r--  test_user_ls   test_user_ls                20   NOT_PERSISTED .+ .+ 100% /testDir/foo/foobar2");
    mOutput.reset();
    sFsShell.run("ls", "--sort", "path", testDir + "/*");
    checkOutput("-rw-r--r--  test_user_ls   test_user_ls                30   NOT_PERSISTED .+ .+ 100% /testDir/bar/foobar3", "-rw-r--r--  test_user_ls   test_user_ls                10   NOT_PERSISTED .+ .+ 100% /testDir/foo/foobar1", "-rw-r--r--  test_user_ls   test_user_ls                20   NOT_PERSISTED .+ .+ 100% /testDir/foo/foobar2", "-rw-r--r--  test_user_ls   test_user_ls                40   NOT_PERSISTED .+ .+ 100% /testDir/foobar4");
// CHECKSTYLE.ON: LineLengthExceed
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 5 with TestUserState

use of alluxio.security.user.TestUserState in project alluxio by Alluxio.

the class LsCommandIntegrationTest method createFiles.

// Helper function to create a set of files in the file system
private void createFiles(String user) throws Exception {
    FileSystem fs = sFileSystem;
    if (user != null) {
        fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState(user, ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
    }
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WritePType.MUST_CACHE, 10);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WritePType.MUST_CACHE, 20);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WritePType.THROUGH, 30);
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState)

Aggregations

TestUserState (alluxio.security.user.TestUserState)11 FileSystem (alluxio.client.file.FileSystem)6 AlluxioURI (alluxio.AlluxioURI)4 Test (org.junit.Test)4 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)2 FileSystemShellUtilsTest (alluxio.client.cli.fs.FileSystemShellUtilsTest)2 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)2 CoreMasterContext (alluxio.master.CoreMasterContext)2 MasterRegistry (alluxio.master.MasterRegistry)2 BlockMasterFactory (alluxio.master.block.BlockMasterFactory)2 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)2 UserState (alluxio.security.user.UserState)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 Before (org.junit.Before)2 URIStatus (alluxio.client.file.URIStatus)1 StorageList (alluxio.grpc.StorageList)1 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1