@Test
@TestDir
@TestJetty
@TestHdfs
public void testCreateFileWithUnmaskedPermissions() throws Exception {

  createHttpFSServer(false, false);
  FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
  // Create a folder with a default acl default:user2:rw-
  fs.mkdirs(new Path("/tmp"));
  AclEntry acl = new org.apache.hadoop.fs.permission.AclEntry.Builder()
      .setType(AclEntryType.USER)
      .setScope(AclEntryScope.DEFAULT)
      .setName("user2")
      .setPermission(FsAction.READ_WRITE)
      .build();
  fs.setAcl(new Path("/tmp"), new ArrayList<AclEntry>(Arrays.asList(acl)));
  String notUnmaskedFile = "/tmp/notUnmasked";
  String unmaskedFile = "/tmp/unmasked";
  // Create a file inside the folder. It should inherit the default acl
  // but the mask should affect the ACL permissions. The mask is controlled
  // by the group permissions, which are 0, and hence the mask will make
  // the effective permission of the inherited ACL be NONE.
  createWithHttp(notUnmaskedFile, "700");
  // Pull the relevant ACL from the FS object and check the mask has affected
  // its permissions.
  AclStatus aclStatus = fs.getAclStatus(new Path(notUnmaskedFile));
  AclEntry theAcl = findAclWithName(aclStatus, "user2");
  Assert.assertNotNull(theAcl);
  Assert.assertEquals(FsAction.NONE,
      aclStatus.getEffectivePermission(theAcl));
  // Create another file, this time pass a mask of 777. Now the inherited
  // permissions should be as expected
  createWithHttp(unmaskedFile, "700", "777");
  aclStatus = fs.getAclStatus(new Path(unmaskedFile));
  theAcl = findAclWithName(aclStatus, "user2");
  Assert.assertNotNull(theAcl);
  Assert.assertEquals(FsAction.READ_WRITE,
      aclStatus.getEffectivePermission(theAcl));
}