Skip to content

Commit

Permalink
Update RangerSparkExtensionSuite.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
AngersZhuuuu committed Nov 2, 2023
1 parent 6f634f4 commit d4bb5b4
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.kyuubi.plugin.spark.authz.ranger

import scala.reflect.io.File
import java.nio.file.Path

import scala.reflect.io.File
import scala.util.Try

import org.apache.hadoop.security.UserGroupInformation
Expand Down Expand Up @@ -1086,4 +1086,31 @@ class HiveCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
}
}
}

test("HadoopFsRelation") {
val db1 = defaultDb
val table1 = "table1"
val tableDirectory = getClass.getResource("/").getPath + "table_directory"
val directory = File(tableDirectory).createDirectory()
withSingleCallEnabled {
withCleanTmpResources(Seq((s"$db1.$table1", "table"))) {
doAs(admin, sql(s"CREATE TABLE IF NOT EXISTS $db1.$table1 (id int, scope int)"))
doAs(
admin,
sql(
s"""
|INSERT OVERWRITE DIRECTORY '${directory.path}'
|USING parquet
|SELECT * FROM $db1.$table1""".stripMargin))

interceptContains[AccessControlException](doAs(
someone,
sql(
s"""
|SELECT * FROM parquet.`${directory.path}`""".stripMargin).explain(true)))(
s"does not have [select] privilege on " +
s"[[file:${directory.path}, file:${directory.path}/]]")
}
}
}
}

0 comments on commit d4bb5b4

Please sign in to comment.