This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 5faebb1e7 [KYUUBI #4658][FOLLOWUP] Improve unit tests
5faebb1e7 is described below
commit 5faebb1e75b57491ca655e0ba6fceacde5ef9459
Author: Karsonnel <[email protected]>
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 <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../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 2d108615e..beef36d5d 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
@@ -708,20 +708,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]"))
}
}
}