pan3793 commented on code in PR #5705:
URL: https://github.com/apache/kyuubi/pull/5705#discussion_r1400235930
##########
kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/BatchesResourceSuite.scala:
##########
@@ -852,4 +852,92 @@ abstract class BatchesResourceSuiteBase extends
KyuubiFunSuite
val getBatchListResponse = response.readEntity(classOf[GetBatchesResponse])
assert(getBatchListResponse.getTotal == 1)
}
+
+ test("open batch session with proxyUser") {
+ // we use superUser to impersonate commonUser
+ val superUser = "superUser"
+ val commonUser = "commonUser"
+
+ val openBatchExecutor = (kyuubiProxyUser: String, hs2ProxyUser: String) =>
{
+ val conf = scala.collection.mutable.Map("spark.master" -> "local")
+ if (kyuubiProxyUser != null) conf += (PROXY_USER.key -> kyuubiProxyUser)
+ if (hs2ProxyUser != null) conf +=
(KyuubiAuthenticationFactory.HS2_PROXY_USER -> hs2ProxyUser)
+ val proxyUserRequest = newSparkBatchRequest(conf.toMap)
+
+ webTarget.path("api/v1/batches")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .header(AUTHORIZATION_HEADER, basicAuthorizationHeader(superUser))
+ .post(Entity.entity(proxyUserRequest, MediaType.APPLICATION_JSON_TYPE))
+ }
+
+ // use kyuubi.session.proxy.user
+ val proxyUserResponse1 = openBatchExecutor(commonUser, null)
+ assert(proxyUserResponse1.getStatus === 405)
+ val errorMessage = s"Failed to validate proxy privilege of $superUser for
$commonUser"
+
assert(proxyUserResponse1.readEntity(classOf[String]).contains(errorMessage))
+
+ // it should be the same behavior as hive.server2.proxy.user
+ val proxyUserResponse2 = openBatchExecutor(null, commonUser)
+ assert(proxyUserResponse2.getStatus === 405)
+
assert(proxyUserResponse2.readEntity(classOf[String]).contains(errorMessage))
+
+ // when both set, kyuubi.session.proxy.user takes precedence
+ val proxyUserResponse3 = openBatchExecutor(commonUser,
s"${commonUser}HiveServer2")
+ assert(proxyUserResponse3.getStatus === 405)
+
assert(proxyUserResponse3.readEntity(classOf[String]).contains(errorMessage))
+ }
+
+ test("delete batch with proxyUser") {
Review Comment:
we should delete this one, see full context
https://github.com/apache/kyuubi/pull/5717
--
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]