Skip to content

Commit 114aafe

Browse files
committed
mv test to HiveCatalogRangerSparkExtensionSuite
1 parent 05c7de0 commit 114aafe

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RangerSparkExtensionSuite.scala

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,8 @@ abstract class RangerSparkExtensionSuite extends AnyFunSuite
301301
test("auth: functions") {
302302
val db = defaultDb
303303
val func = "func"
304-
val kyuubiFunc = "kyuubi_func1"
305304
withCleanTmpResources(Seq(
306-
(func, "function"),
307-
(kyuubiFunc, "function"))) {
305+
(func, "function"))) {
308306
val create0 = s"CREATE FUNCTION IF NOT EXISTS $db.$func AS 'abc.mnl.xyz'"
309307
doAs(
310308
bob, {
@@ -317,33 +315,6 @@ abstract class RangerSparkExtensionSuite extends AnyFunSuite
317315
assert(e.getMessage === errorMessage("create", s"$db/$func"))
318316
})
319317
doAs(admin, assert(Try(sql(create0)).isSuccess))
320-
321-
// [KYUUBI #7186] Introduce RuleFunctionAuthorization
322-
val createKyuubiFunc =
323-
s"""
324-
|CREATE FUNCTION IF NOT EXISTS
325-
| $db.$kyuubiFunc
326-
| AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskHash'
327-
|""".stripMargin
328-
doAs(
329-
kent, {
330-
val e = intercept[AccessControlException](sql(createKyuubiFunc))
331-
assert(e.getMessage === errorMessage("create", s"$db/$kyuubiFunc"))
332-
})
333-
doAs(bob, assert(Try(sql(createKyuubiFunc)).isSuccess))
334-
doAs(admin, assert(Try(sql(createKyuubiFunc)).isSuccess))
335-
336-
val selectKyuubiFunc =
337-
s"""
338-
|SELECT $db.$kyuubiFunc("KYUUBUI_TEST_STRING")""".stripMargin
339-
doAs(
340-
alice, {
341-
val e = intercept[AccessControlException](sql(selectKyuubiFunc))
342-
assert(e.getMessage === errorMessage("select", s"$db/$kyuubiFunc"))
343-
})
344-
doAs(kent, assert(Try(sql(selectKyuubiFunc)).isSuccess))
345-
doAs(bob, assert(Try(sql(selectKyuubiFunc)).isSuccess))
346-
doAs(admin, assert(Try(sql(selectKyuubiFunc)).isSuccess))
347318
}
348319
}
349320

@@ -1614,4 +1585,38 @@ class HiveCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
16141585
}
16151586
}
16161587
}
1588+
1589+
1590+
test("[KYUUBI #7186] Introduce RuleFunctionAuthorization") {
1591+
val db = defaultDb
1592+
val kyuubiFunc = "kyuubi_func1"
1593+
withCleanTmpResources(Seq(
1594+
(kyuubiFunc, "function"))) {
1595+
val createKyuubiFunc =
1596+
s"""
1597+
|CREATE FUNCTION IF NOT EXISTS
1598+
| $db.$kyuubiFunc
1599+
| AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFMaskHash'
1600+
|""".stripMargin
1601+
doAs(
1602+
kent, {
1603+
val e = intercept[AccessControlException](sql(createKyuubiFunc))
1604+
assert(e.getMessage === errorMessage("create", s"$db/$kyuubiFunc"))
1605+
})
1606+
doAs(bob, assert(Try(sql(createKyuubiFunc)).isSuccess))
1607+
doAs(admin, assert(Try(sql(createKyuubiFunc)).isSuccess))
1608+
1609+
val selectKyuubiFunc =
1610+
s"""
1611+
|SELECT $db.$kyuubiFunc("KYUUBUI_TEST_STRING")""".stripMargin
1612+
doAs(
1613+
alice, {
1614+
val e = intercept[AccessControlException](sql(selectKyuubiFunc))
1615+
assert(e.getMessage === errorMessage("select", s"$db/$kyuubiFunc"))
1616+
})
1617+
doAs(kent, assert(Try(sql(selectKyuubiFunc)).isSuccess))
1618+
doAs(bob, assert(Try(sql(selectKyuubiFunc)).isSuccess))
1619+
doAs(admin, assert(Try(sql(selectKyuubiFunc)).isSuccess))
1620+
}
1621+
}
16171622
}

0 commit comments

Comments
 (0)