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/04/07 10:54:41 UTC

[kyuubi] branch branch-1.7 updated: [KYUUBI #4658][FOLLOWUP] Improve unit tests

This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new 87ca0659c [KYUUBI #4658][FOLLOWUP] Improve unit tests
87ca0659c is described below

commit 87ca0659c58d61c74b5e049f928d1509a802de8f
Author: Karsonnel <74...@qq.com>
AuthorDate: Fri Apr 7 18:54:14 2023 +0800

    [KYUUBI #4658][FOLLOWUP] Improve unit tests
    
    ### _Why are the changes needed?_
    
    To allow up the reviewer's comment in  https://github.com/apache/kyuubi/issues/4660.
    
    ### _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.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #4661 from Karsonnel/4658-authz-insert-follow-up.
    
    Closes #4658
    
    3ce7efc3d [Karsonnel] add e2e test for InsertIntoDatasourceCommand
    2c8e3469a [Karsonnel] rename test
    1349c2b02 [Karsonnel] fix test assert text
    d2f04ca45 [Karsonnel] fix test
    8f86bb14b [Karsonnel] Resolve reviewer's comment in pr #4660
    
    Authored-by: Karsonnel <74...@qq.com>
    Signed-off-by: Cheng Pan <ch...@apache.org>
    (cherry picked from commit 5faebb1e75b57491ca655e0ba6fceacde5ef9459)
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 .../authz/ranger/RangerSparkExtensionSuite.scala   | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

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 4f4d4a618..2b8c2bca6 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
@@ -785,20 +785,37 @@ class HiveCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
     }
   }
 
-  test("[KYUUBI #4658] INSERT OVERWRITE DIRECTORY did check query permission") {
+  test("[KYUUBI #4658] insert overwrite hive directory") {
     val db1 = "default"
     val table = "src"
 
     withCleanTmpResources(Seq((s"$db1.$table", "table"))) {
-      doAs("bob", sql(s"CREATE TABLE IF NOT EXISTS $db1.$table (id int, name string)"))
-      val e1 = intercept[AccessControlException](
+      doAs("admin", sql(s"CREATE TABLE IF NOT EXISTS $db1.$table (id int, name string)"))
+      val e = intercept[AccessControlException](
         doAs(
           "someone",
           sql(
             s"""INSERT OVERWRITE DIRECTORY '/tmp/test_dir' ROW FORMAT DELIMITED FIELDS
                | TERMINATED BY ','
                | SELECT * FROM $db1.$table;""".stripMargin)))
-      assert(e1.getMessage.contains(s"does not have [select] privilege on [$db1/$table/id"))
+      assert(e.getMessage.contains(s"does not have [select] privilege on [$db1/$table/id]"))
+    }
+  }
+
+  test("[KYUUBI #4658] insert overwrite datasource directory") {
+    val db1 = "default"
+    val table = "src"
+
+    withCleanTmpResources(Seq((s"$db1.$table", "table"))) {
+      doAs("admin", sql(s"CREATE TABLE IF NOT EXISTS $db1.$table (id int, name string)"))
+      val e = intercept[AccessControlException](
+        doAs(
+          "someone",
+          sql(
+            s"""INSERT OVERWRITE DIRECTORY '/tmp/test_dir'
+               | USING parquet
+               | SELECT * FROM $db1.$table;""".stripMargin)))
+      assert(e.getMessage.contains(s"does not have [select] privilege on [$db1/$table/id]"))
     }
   }
 }