You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/01/06 04:19:28 UTC
[kyuubi] branch branch-1.6 updated: [KYUUBI #4076][AUTHZ][FOLLOWUP][1.6] Add missing withCleanTmpResources
This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.6 by this push:
new fc8fdad1c [KYUUBI #4076][AUTHZ][FOLLOWUP][1.6] Add missing withCleanTmpResources
fc8fdad1c is described below
commit fc8fdad1cfb18276e075413472ac0ca9d76fc860
Author: Cheng Pan <ch...@apache.org>
AuthorDate: Fri Jan 6 12:19:15 2023 +0800
[KYUUBI #4076][AUTHZ][FOLLOWUP][1.6] Add missing withCleanTmpResources
### _Why are the changes needed?_
https://github.com/apache/kyuubi/pull/4076#issuecomment-1373054230
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #4107 from pan3793/4076-followup.
Closes #4076
3bea39a2 [Cheng Pan] style
d78a40fe [Cheng Pan] [KYUUBI #4076][AUTHZ][FOLLOWUP][1.6] Add missing withCleanTmpResources
Authored-by: Cheng Pan <ch...@apache.org>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
.../spark/authz/ranger/RangerSparkExtensionSuite.scala | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtensionSuite.scala b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtensionSuite.scala
index 1ea2575bb..d763ec5bf 100644
--- a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtensionSuite.scala
+++ b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtensionSuite.scala
@@ -62,6 +62,24 @@ abstract class RangerSparkExtensionSuite extends AnyFunSuite
s"Permission denied: user [$user] does not have [$privilege] privilege on [$resource]"
}
+ protected def withCleanTmpResources[T](res: Seq[(String, String)])(f: => T): T = {
+ try {
+ f
+ } finally {
+ res.foreach {
+ case (t, "table") => doAs("admin", sql(s"DROP TABLE IF EXISTS $t"))
+ case (db, "database") => doAs("admin", sql(s"DROP DATABASE IF EXISTS $db"))
+ case (fn, "function") => doAs("admin", sql(s"DROP FUNCTION IF EXISTS $fn"))
+ case (view, "view") => doAs("admin", sql(s"DROP VIEW IF EXISTS $view"))
+ case (cacheTable, "cache") => if (isSparkV32OrGreater) {
+ doAs("admin", sql(s"UNCACHE TABLE IF EXISTS $cacheTable"))
+ }
+ case (_, e) =>
+ throw new RuntimeException(s"the resource whose resource type is $e cannot be cleared")
+ }
+ }
+ }
+
test("[KYUUBI #3226] RuleAuthorization: Should check privileges once only.") {
val logicalPlan = doAs("admin", sql("SHOW TABLES").queryExecution.logical)
val rule = new RuleAuthorization(spark)