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