turboFei commented on code in PR #6624:
URL: https://github.com/apache/kyuubi/pull/6624#discussion_r1722394286


##########
kyuubi-server/src/test/scala/org/apache/kyuubi/operation/thrift/http/KyuubiOperationThriftHttpKerberosAndPlainAuthSuite.scala:
##########
@@ -49,19 +58,46 @@ class KyuubiOperationThriftHttpKerberosAndPlainAuthSuite
     UserGroupInformation.setConfiguration(config)
     assert(UserGroupInformation.isSecurityEnabled)
 
-    KyuubiConf().set(KyuubiConf.AUTHENTICATION_METHOD, Seq("KERBEROS", "LDAP", 
"CUSTOM"))
+    KyuubiConf().set(KyuubiConf.AUTHENTICATION_METHOD, Seq("KERBEROS", 
"CUSTOM", "LDAP"))
       .set(KyuubiConf.SERVER_KEYTAB, testKeytab)
       .set(KyuubiConf.SERVER_PRINCIPAL, testPrincipal)
       .set(KyuubiConf.AUTHENTICATION_LDAP_URL, ldapUrl)
       .set(KyuubiConf.AUTHENTICATION_LDAP_BASE_DN, ldapBaseDn.head)
       .set(
         KyuubiConf.AUTHENTICATION_CUSTOM_CLASS,
         classOf[UserDefineAuthenticationProviderImpl].getCanonicalName)
+      .set(
+        KyuubiConf.AUTHENTICATION_CUSTOM_BEARER_CLASS,
+        classOf[UserDefineAuthenticationProviderImpl].getCanonicalName)
       .set(KyuubiConf.SERVER_SPNEGO_KEYTAB, testKeytab)
       .set(KyuubiConf.SERVER_SPNEGO_PRINCIPAL, testSpnegoPrincipal)
   }
 
   override protected def getJdbcUrl: String =
     
s"jdbc:hive2://${server.frontendServices.head.connectionUrl}/default;transportMode=http;"
 +
       s"httpPath=cliservice"
+
+  test("test with valid CUSTOM http bearer authentication") {
+    val conn = DriverManager.getConnection(JdbcUrlWithValidBearerToken)
+    try {
+      val statement = conn.createStatement()
+      val resultSet = statement.executeQuery("select engine_name()")
+      assert(resultSet.next())
+      assert(resultSet.getString(1).nonEmpty)
+    } finally {
+      conn.close()
+    }
+  }
+
+  test("test with invalid CUSTOM http bearer authentication") {
+    intercept[SQLException] {
+      val conn = DriverManager.getConnection(JdbcUrlWithInvalidBearerToken)

Review Comment:
   FYI:
   ```
       withSessionConf(Map("bearerToken" -> "badToken"))()() {
         val conn = DriverManager.getConnection(jdbcUrlWithConf)
       }
   ```



##########
kyuubi-server/src/test/scala/org/apache/kyuubi/operation/thrift/http/KyuubiOperationThriftHttpKerberosAndPlainAuthSuite.scala:
##########
@@ -41,6 +44,12 @@ class KyuubiOperationThriftHttpKerberosAndPlainAuthSuite
   override protected def kerberosTgtJdbcUrlUsingAlias: String =
     jdbcUrl.stripSuffix(";") + s";kyuubiServerPrincipal=$testSpnegoPrincipal"
 
+  protected def JdbcUrlWithValidBearerToken: String =
+    jdbcUrl.stripSuffix(";") + s";bearerToken=$validToken"
+
+  protected def JdbcUrlWithInvalidBearerToken: String =
+    jdbcUrl.stripSuffix(";") + s";bearerToken=invalidToken"

Review Comment:
   not needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to