protected void testFilterForDb(boolean filterAtServer) throws Exception {

    // Skip this call when testing filter hook at HMS server because HMS server calls authorization
    // API for getDatabase(), and does not call filter hook
    if (!filterAtServer) {
      try {
        assertNotNull(client.getDatabase(DBNAME1));
        fail("getDatabase() should fail with blocking mode");
      } catch (NoSuchObjectException e) {
        // Excepted
      }
    }

    assertEquals(0, client.getDatabases("*").size());
    assertEquals(0, client.getAllDatabases().size());
    assertEquals(0, client.getDatabases(DBNAME1).size());

    GetDatabaseObjectsRequest request = new GetDatabaseObjectsRequest();
    request.setCatalogName(Warehouse.DEFAULT_CATALOG_NAME);
    String testPrefix = DBNAME1.substring(0, DBNAME1.lastIndexOf("_"));
    request.setPattern(testPrefix + "_*");

    // Call the method with filtering enabled
    GetDatabaseObjectsResponse response = client.get_databases_req(request);
    assertEquals("With filtering enabled, should return empty list", 0, response.getDatabasesSize());

    // Temporarily disable blocking to test without filtering
    boolean originalBlockResults = DummyMetaStoreFilterHookImpl.blockResults;
    DummyMetaStoreFilterHookImpl.blockResults = false;

    try {
      response = client.get_databases_req(request);
      System.out.println("Returned databases:");
      for (Database db : response.getDatabases()) {
        System.out.println("DB name: " + db.getName());
      }
      assertEquals("With filtering disabled, should return all databases", 2, response.getDatabasesSize());

      // Verify the returned database objects have the correct names
      Set<String> returnedDbNames = new HashSet<>();
      for (Database db : response.getDatabases()) {
        returnedDbNames.add(db.getName());
      }
      assertTrue("Should contain first database", returnedDbNames.contains(DBNAME1.toLowerCase()));
      assertTrue("Should contain second database", returnedDbNames.contains(DBNAME2.toLowerCase()));
    } finally {
      DummyMetaStoreFilterHookImpl.blockResults = originalBlockResults;
    }
  }
By default, the HMS Client side filtering is enabled
Disable the HMS server side filtering in order to see HMS client filtering behavior
@throws Exception
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java