コード例 #1
0
  /**
   * Asserts that permission is denied to the given fs/user for the given directory.
   *
   * @param fs FileSystem to check
   * @param user UserGroupInformation owner of fs
   * @param pathToCheck Path directory to check
   * @throws Exception if there is an unexpected error
   */
  private static void assertDirPermissionDenied(
      FileSystem fs, UserGroupInformation user, Path pathToCheck) throws Exception {
    try {
      fs.listStatus(pathToCheck);
      fail("expected AccessControlException for user " + user + ", path = " + pathToCheck);
    } catch (AccessControlException e) {
      // expected
    }

    try {
      fs.access(pathToCheck, FsAction.READ);
      fail("The access call should have failed for " + pathToCheck);
    } catch (AccessControlException e) {
      // expected
    }
  }
コード例 #2
0
 /**
  * Asserts that permission is granted to the given fs/user for the given directory.
  *
  * @param fs FileSystem to check
  * @param user UserGroupInformation owner of fs
  * @param pathToCheck Path directory to check
  * @throws Exception if there is an unexpected error
  */
 private static void assertDirPermissionGranted(
     FileSystem fs, UserGroupInformation user, Path pathToCheck) throws Exception {
   try {
     fs.listStatus(pathToCheck);
     fs.access(pathToCheck, FsAction.READ);
   } catch (AccessControlException e) {
     fail("expected permission granted for user " + user + ", path = " + pathToCheck);
   }
 }
コード例 #3
0
 private void assertPermissionDenied(UserGroupInformation user, String path, FsAction access)
     throws IOException {
   try {
     new FSPermissionChecker(SUPERUSER, SUPERGROUP, user)
         .checkPermission(path, inodeRoot, false, null, null, access, null, true);
     fail(
         "expected AccessControlException for user + "
             + user
             + ", path = "
             + path
             + ", access = "
             + access);
   } catch (AccessControlException e) {
     // expected
   }
 }