private void testFunction(FunctionInvoker mscFunctionInvoker) throws Exception {
    boolean caughtEx = false;
    try {
      try {
        mscFunctionInvoker.invoke();
      } catch (RuntimeException e) {
        // A hack to verify that authorization check passed. Exception can be thrown be cause
        // the functions are not being called with valid params.
        // verify that exception has come from ObjectStore code, which means that the
        // authorization checks passed.
        String exStackString = ExceptionUtils.getStackTrace(e);
        assertTrue("Verifying this exception came after authorization check",
                exStackString.contains("org.apache.hadoop.hive.metastore.ObjectStore"));
        // If its not an exception caused by auth check, ignore it
      }
      assertFalse("Authz Exception should have been thrown in remote mode", isRemoteMetastoreMode);
      System.err.println("No auth exception thrown");
    } catch (MetaException e) {
      System.err.println("Caught exception");
      String exStackString = ExceptionUtils.getStackTrace(e);
      // Check if MetaException has one of InvalidObjectException or NoSuchObjectExcetion or any exception thrown from ObjectStore , which means that the
      // authorization checks passed.
      if(exStackString.contains("org.apache.hadoop.hive.metastore.api.NoSuchObjectException") ||
              exStackString.contains("org.apache.hadoop.hive.metastore.api.InvalidObjectException")) {
        assertFalse("No Authz exception thrown in embedded mode", isRemoteMetastoreMode);
      } else {
        caughtEx = true;
        assertTrue(e.getMessage().contains(MetaStoreAuthzAPIAuthorizerEmbedOnly.errMsg));
      }
    } catch (TException e) {
      String exStackString = ExceptionUtils.getStackTrace(e);
      assertTrue("Verifying this exception came after authorization check",
              exStackString.contains("org.apache.hadoop.hive.metastore.ObjectStore"));
    }
    if (!isRemoteMetastoreMode) {
      assertFalse("No exception should be thrown in embedded mode", caughtEx);
    }
  }
Test the if authorization failed/passed for FunctionInvoker that invokes a metastore client
api call
@param mscFunctionInvoker
@throws Exception
itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/AbstractTestAuthorizationApiAuthorizer.java