fix ut
This commit is contained in:
parent
cf617ee5a6
commit
0a166e71ae
@ -17,22 +17,44 @@
|
||||
|
||||
package yaooqinn.kyuubi
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
import org.apache.hadoop.minikdc.MiniKdc
|
||||
import org.apache.hadoop.security.UserGroupInformation
|
||||
import org.apache.spark.{KyuubiSparkUtil, SparkConf}
|
||||
|
||||
trait SecuredFunSuite {
|
||||
|
||||
var kdc: MiniKdc = null
|
||||
val baseDir = KyuubiSparkUtil.createTempDir(namePrefix = "kyuubi-kdc")
|
||||
try {
|
||||
val kdcConf = MiniKdc.createConf()
|
||||
kdcConf.setProperty(MiniKdc.INSTANCE, "KyuubiKrbServer")
|
||||
kdcConf.setProperty(MiniKdc.ORG_NAME, "KYUUBI")
|
||||
kdcConf.setProperty(MiniKdc.ORG_DOMAIN, "COM")
|
||||
|
||||
if (kdc == null) {
|
||||
kdc = new MiniKdc(kdcConf, baseDir)
|
||||
kdc.start()
|
||||
}
|
||||
} catch {
|
||||
case e: IOException =>
|
||||
throw new AssertionError("unable to create temporary directory: " + e.getMessage)
|
||||
}
|
||||
|
||||
def tryWithSecurityEnabled(block: => Unit): Unit = {
|
||||
val conf = new SparkConf(true)
|
||||
assert(!UserGroupInformation.isSecurityEnabled)
|
||||
val authType = "spark.hadoop.hadoop.security.authentication"
|
||||
try {
|
||||
conf.set(authType, "KERBEROS")
|
||||
System.setProperty("java.security.krb5.realm", kdc.getRealm)
|
||||
UserGroupInformation.setConfiguration(KyuubiSparkUtil.newConfiguration(conf))
|
||||
assert(UserGroupInformation.isSecurityEnabled)
|
||||
block
|
||||
} finally {
|
||||
conf.remove(authType)
|
||||
System.clearProperty("java.security.krb5.realm")
|
||||
UserGroupInformation.setConfiguration(KyuubiSparkUtil.newConfiguration(conf))
|
||||
assert(!UserGroupInformation.isSecurityEnabled)
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@ class KyuubiSessionSecuredSuite extends SparkFunSuite with SecuredFunSuite {
|
||||
super.afterAll()
|
||||
}
|
||||
|
||||
|
||||
test("secured ugi test") {
|
||||
val be = server.beService
|
||||
val sessionMgr = be.getSessionManager
|
||||
|
||||
Loading…
Reference in New Issue
Block a user