Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[KYUUBI-122]obtain delegation tokens from possible kerberized services #123

Merged
merged 8 commits into from
Dec 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add it
  • Loading branch information
yaooqinn committed Dec 5, 2018
commit 5f5f85d6b6ac2700df926d4131c855897e6e02ee
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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 yaooqinn.kyuubi.session

import org.apache.hive.service.cli.thrift.TProtocolVersion
import org.apache.spark.{KyuubiConf, KyuubiSparkUtil}

import yaooqinn.kyuubi.SecuredFunSuite
import yaooqinn.kyuubi.server.KyuubiServer
import yaooqinn.kyuubi.ui.KyuubiServerMonitor

class KyuubiSessionSecuredSuite extends KyuubiSessionSuite with SecuredFunSuite {

override def beforeAll(): Unit = {
System.setProperty(KyuubiConf.FRONTEND_BIND_PORT.key, "0")
System.setProperty("spark.master", "local")
System.setProperty("spark.hadoop.yarn.resourcemanager.principal", "yarn/_HOST@KENT.KYUUBI.COM")

server = KyuubiServer.startKyuubiServer()
val be = server.beService
val sessionMgr = be.getSessionManager
val operationMgr = sessionMgr.getOperationMgr
val user = "Kent"
val passwd = ""
val ip = ""
val imper = true
val proto = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8
tryWithSecurityEnabled {
session =
new KyuubiSession(proto, user, passwd, server.getConf, ip, imper, sessionMgr, operationMgr)
}
session.open(Map.empty)
KyuubiServerMonitor.getListener(user)
.foreach(_.onSessionCreated(
session.getIpAddress, session.getSessionHandle.getSessionId.toString, user))
spark = session.sparkSession
super.beforeAll()
}

override def afterAll(): Unit = {
System.clearProperty(KyuubiConf.FRONTEND_BIND_PORT.key)
System.clearProperty("spark.master")
System.clearProperty("spark.hadoop.yarn.resourcemanager.principal")
if (session != null) {
if (session.sparkSession != null) session.sparkSession.stop()
session.close()
}
if (server != null) server.stop()
super.afterAll()
}

}
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ class KyuubiSessionSuite extends SparkFunSuite {
spark = session.sparkSession
super.beforeAll()
}

override def afterAll(): Unit = {
System.clearProperty(KyuubiConf.FRONTEND_BIND_PORT.key)
System.clearProperty("spark.master")
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 yaooqinn.kyuubi.session.security

import org.apache.spark.{KyuubiSparkUtil, SparkConf, SparkFunSuite}

import yaooqinn.kyuubi.SecuredFunSuite
import yaooqinn.kyuubi.utils.KyuubiHiveUtil

class HiveTokenCollectorSuite extends SparkFunSuite with SecuredFunSuite {

test("token required") {
val conf = new SparkConf()
assert(!HiveTokenCollector.tokensRequired(conf))

tryWithSecurityEnabled {
assert(!HiveTokenCollector.tokensRequired(conf))
conf.set(KyuubiSparkUtil.SPARK_HADOOP_PREFIX + KyuubiHiveUtil.URIS, "thrift://kyuubi:9093")
assert(HiveTokenCollector.tokensRequired(conf))
}
}

test("obtain tokens") {
val conf = new SparkConf()
HiveTokenCollector.obtainTokens(conf)
conf.set(KyuubiSparkUtil.SPARK_HADOOP_PREFIX + KyuubiHiveUtil.URIS, "thrift://kyuubi:9093")
HiveTokenCollector.obtainTokens(conf)
}
}