use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class FileSystemAclIntegrationTest method loadDirMetadataMode.
/**
* Tests the loaded directory metadata from UFS having the same mode as that in the UFS.
*/
@Test
public void loadDirMetadataMode() throws Exception {
// Skip non-local and non-HDFS UFSs.
Assume.assumeTrue(UnderFileSystemUtils.isLocal(sUfs) || UnderFileSystemUtils.isHdfs(sUfs));
List<Integer> permissionValues = Lists.newArrayList(0111, 0222, 0333, 0444, 0555, 0666, 0777, 0755, 0733, 0644, 0533, 0511);
for (int value : permissionValues) {
Path dir = new Path("/loadDirMetadataMode" + value + "/");
sTFS.delete(dir, true);
// Create a directory directly in UFS and set the corresponding mode.
String ufsPath = PathUtils.concatPath(sUfsRoot, dir);
sUfs.mkdirs(ufsPath, MkdirsOptions.defaults(ServerConfiguration.global()).setCreateParent(false).setOwner("testuser").setGroup("testgroup").setMode(new Mode((short) value)));
Assert.assertTrue(sUfs.isDirectory(PathUtils.concatPath(sUfsRoot, dir)));
// Check the mode is consistent in Alluxio namespace once it's loaded from UFS to Alluxio.
Assert.assertEquals(new Mode((short) value).toString(), new Mode(sTFS.getFileStatus(dir).getPermission().toShort()).toString());
}
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class PermissionCheckTest method getPermissionOther.
@Test
public void getPermissionOther() throws Exception {
ArrayList<Triple<String, String, Mode>> permissions = new ArrayList<>();
permissions.add(new ImmutableTriple<>(TEST_USER_1.getUser(), TEST_USER_1.getGroup(), new Mode((short) 0754)));
LockedInodePath lockedInodePath = getLockedInodePath(permissions);
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(TEST_USER_2.getUser())) {
PermissionChecker checker = new PermissionChecker(mInodeTree);
Mode.Bits actual = checker.getPermission(lockedInodePath);
Assert.assertEquals(Mode.Bits.READ, actual);
}
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class CreateDirectoryOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() throws Exception {
Random random = new Random();
boolean allowExists = random.nextBoolean();
boolean mountPoint = random.nextBoolean();
long operationTimeMs = random.nextLong();
String owner = CommonUtils.randomAlphaNumString(10);
String group = CommonUtils.randomAlphaNumString(10);
Mode mode = new Mode((short) random.nextInt());
boolean persisted = random.nextBoolean();
boolean recursive = random.nextBoolean();
long ttl = random.nextLong();
CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setAllowExists(allowExists).setMountPoint(mountPoint).setOperationTimeMs(operationTimeMs).setPersisted(persisted).setOwner(owner).setGroup(group).setMode(mode).setRecursive(recursive).setTtl(ttl).setTtlAction(TtlAction.FREE);
Assert.assertEquals(allowExists, options.isAllowExists());
Assert.assertEquals(mountPoint, options.isMountPoint());
Assert.assertEquals(operationTimeMs, options.getOperationTimeMs());
Assert.assertEquals(persisted, options.isPersisted());
Assert.assertEquals(owner, options.getOwner());
Assert.assertEquals(group, options.getGroup());
Assert.assertEquals(mode, options.getMode());
Assert.assertEquals(recursive, options.isRecursive());
Assert.assertEquals(ttl, options.getTtl());
Assert.assertEquals(TtlAction.FREE, options.getTtlAction());
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class CreateFileOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() throws Exception {
Random random = new Random();
long blockSize = random.nextLong();
boolean mountPoint = random.nextBoolean();
long operationTimeMs = random.nextLong();
String owner = CommonUtils.randomAlphaNumString(10);
String group = CommonUtils.randomAlphaNumString(10);
Mode mode = new Mode((short) random.nextInt());
boolean persisted = random.nextBoolean();
boolean recursive = random.nextBoolean();
long ttl = random.nextLong();
CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(blockSize).setMountPoint(mountPoint).setOperationTimeMs(operationTimeMs).setPersisted(persisted).setOwner(owner).setGroup(group).setMode(mode).setRecursive(recursive).setTtl(ttl).setTtlAction(TtlAction.FREE);
Assert.assertEquals(blockSize, options.getBlockSizeBytes());
Assert.assertEquals(mountPoint, options.isMountPoint());
Assert.assertEquals(operationTimeMs, options.getOperationTimeMs());
Assert.assertEquals(owner, options.getOwner());
Assert.assertEquals(group, options.getGroup());
Assert.assertEquals(mode, options.getMode());
Assert.assertEquals(persisted, options.isPersisted());
Assert.assertEquals(recursive, options.isRecursive());
Assert.assertEquals(ttl, options.getTtl());
Assert.assertEquals(TtlAction.FREE, options.getTtlAction());
}
use of alluxio.security.authorization.Mode in project alluxio by Alluxio.
the class PermissionCheckTest method getPermissionGroup.
@Test
public void getPermissionGroup() throws Exception {
ArrayList<Triple<String, String, Mode>> permissions = new ArrayList<>();
permissions.add(new ImmutableTriple<>(TEST_USER_1.getUser(), TEST_USER_1.getGroup(), new Mode((short) 0754)));
LockedInodePath lockedInodePath = getLockedInodePath(permissions);
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(TEST_USER_3.getUser())) {
PermissionChecker checker = new PermissionChecker(mInodeTree);
Mode.Bits actual = checker.getPermission(lockedInodePath);
Assert.assertEquals(Mode.Bits.READ_EXECUTE, actual);
}
}
Aggregations