-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d2c8d1
commit dc3ee94
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../org/apache/kyuubi/plugin/spark/authz/ranger/PaimonCatalogRangerSparkExtensionSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.kyuubi.plugin.spark.authz.ranger | ||
|
||
import org.scalatest.Outcome | ||
|
||
import org.apache.kyuubi.Utils | ||
import org.apache.kyuubi.plugin.spark.authz.AccessControlException | ||
import org.apache.kyuubi.plugin.spark.authz.RangerTestUsers._ | ||
import org.apache.kyuubi.plugin.spark.authz.util.AuthZUtils._ | ||
import org.apache.kyuubi.tags.PaimonTest | ||
import org.apache.kyuubi.util.AssertionUtils._ | ||
|
||
/** | ||
* Tests for RangerSparkExtensionSuite on Paimon | ||
*/ | ||
@PaimonTest | ||
class PaimonCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite { | ||
override protected val catalogImpl: String = "hive" | ||
private def isSupportedVersion = !isSparkV35OrGreater | ||
|
||
val catalogV2 = "paimon_catalog" | ||
val namespace1 = "paimon_ns" | ||
val table1 = "table1" | ||
|
||
override def withFixture(test: NoArgTest): Outcome = { | ||
assume(isSupportedVersion) | ||
test() | ||
} | ||
|
||
override def beforeAll(): Unit = { | ||
if (isSupportedVersion) { | ||
spark.conf.set(s"spark.sql.catalog.$catalogV2", "org.apache.paimon.spark.SparkCatalog") | ||
spark.conf.set( | ||
s"spark.sql.catalog.$catalogV2.warehouse", | ||
Utils.createTempDir("iceberg-hadoop").toString) | ||
super.beforeAll() | ||
} | ||
|
||
doAs(admin, sql(s"CREATE DATABASE IF NOT EXISTS $catalogV2.$namespace1")) | ||
} | ||
|
||
override def afterAll(): Unit = { | ||
if (isSupportedVersion) { | ||
super.afterAll() | ||
spark.sessionState.catalog.reset() | ||
spark.sessionState.conf.clear() | ||
} | ||
} | ||
|
||
test("CreateTable") { | ||
withCleanTmpResources(Seq((s"$catalogV2.$namespace1.$table1", "table"))) { | ||
val createTable = | ||
s""" | ||
|CREATE TABLE IF NOT EXISTS $catalogV2.$namespace1.$table1 | ||
|(id int, name string, city string) | ||
|USING paimon | ||
|OPTIONS ( | ||
| primaryKey = 'id' | ||
|) | ||
|""".stripMargin | ||
|
||
interceptContains[AccessControlException] { | ||
doAs(someone, sql(createTable)) | ||
}(s"does not have [create] privilege on [$namespace1/$table1]") | ||
doAs(admin, createTable) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
kyuubi-util-scala/src/test/java/org/apache/kyuubi/tags/PaimonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.kyuubi.tags; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.scalatest.TagAnnotation; | ||
|
||
@TagAnnotation | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
public @interface PaimonTest {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters