Exemplo n.º 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
    }
  }
Exemplo n.º 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);
   }
 }
 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
   }
 }