@Test
  public void testAuthorizedConnection() throws Exception {
    CloseableHttpClient httpclient = null;
    try {
      String username = "user1";
      String password = "1";
      httpclient = HttpClients.createDefault();

      HttpGet httpGet = new HttpGet("http://" + host + ":" + webUIPort);
      String authB64Code = B64Code.encode(username + ":" + password, StringUtil.__ISO_8859_1);
      httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
      CloseableHttpResponse response = httpclient.execute(httpGet);
      Assert.assertTrue(response.toString().contains(Integer.toString(HttpURLConnection.HTTP_OK)));

    } finally {
      if (httpclient != null) {
        httpclient.close();
      }
    }
  }
TestHS2HttpServerPam -- executes tests of HiveServer2 HTTP Server for Pam authentication
service/src/test/org/apache/hive/service/server/TestHS2HttpServerPam.java