@Test
  public void testKrbJwtAuth() throws Exception {
    String krb5Url = new StringBuilder(miniHS2.getBaseHttpJdbcURL())
        .append("default;")
        .append("transportMode=http;httpPath=cliservice;")
        .append("principal=" + miniHiveKdc.getFullHiveServicePrincipal())
        .toString();

    try (Connection hs2Conn = DriverManager.getConnection(krb5Url)) {
      try (Statement statement = hs2Conn.createStatement()) {
        statement.execute("create table if not exists test_hs2_with_jwt_kerberos(a string)");
        statement.execute("set hive.support.concurrency");
        validateResult(statement.getResultSet(), 1);
      }
    }

    StringBuilder jwtUrl = new StringBuilder(miniHS2.getBaseHttpJdbcURL())
        .append("default;")
        .append("transportMode=http;httpPath=cliservice;")
        .append("auth=jwt;")
        .append("jwt=");

    try (Connection hs2Conn = DriverManager.getConnection(jwtUrl
        .append(generateJWT("user1", true, TimeUnit.MINUTES.toMillis(5)))
        .toString())) {
      try (Statement statement = hs2Conn.createStatement()) {
        statement.execute("create table if not exists test_hs2_with_jwt_kerberos(a string)");
        statement.execute("set hive.support.concurrency");
        validateResult(statement.getResultSet(), 1);
      }
    }

    try {
      DriverManager.getConnection(jwtUrl
          .append(generateJWT("user1", false, TimeUnit.MINUTES.toMillis(5)))
          .toString());
      Assert.fail("Exception is expected as JWT token is invalid");
    } catch (Exception e) {
      Assert.assertTrue(e.getMessage().contains("HTTP Response code: 401"));
    }
  }
Test for supporting Kerberos + JWT in HS2 http mode
itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2JWTWithMiniKdc.java