Skip to content

Commit

Permalink
refactor kerbereos helper
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Oct 23, 2021
1 parent 6691cc5 commit 4fc6308
Showing 1 changed file with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,33 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
private var kdc: MiniKdc = _
private var krb5ConfPath: String = _

eventually(timeout(60.seconds), interval(1.second)) {
try {
kdc = new MiniKdc(kdcConf, baseDir)
kdc.start()
krb5ConfPath = kdc.getKrb5conf.getAbsolutePath
} catch {
case NonFatal(e) =>
if (kdc != null) {
kdc.stop()
kdc = null
}
throw e
}
}

private val keytabFile = new File(baseDir, "kyuubi-test.keytab")
protected val testKeytab: String = keytabFile.getAbsolutePath
protected var testPrincipal = s"client/$hostName"
kdc.createPrincipal(keytabFile, testPrincipal)

protected var testPrincipal: String = _

override def beforeAll(): Unit = {
eventually(timeout(60.seconds), interval(1.second)) {
try {
kdc = new MiniKdc(kdcConf, baseDir)
kdc.start()
krb5ConfPath = kdc.getKrb5conf.getAbsolutePath
} catch {
case NonFatal(e) =>
if (kdc != null) {
kdc.stop()
kdc = null
}
throw e
}
}
val tempTestPrincipal = s"client/$hostName"
kdc.createPrincipal(keytabFile, tempTestPrincipal)
rewriteKrb5Conf()
testPrincipal = tempTestPrincipal + "@" + kdc.getRealm
info(s"KerberizedTest Principal: $testPrincipal")
info(s"KerberizedTest Keytab: $testKeytab")
super.beforeAll()
}

/**
* Forked from Apache Spark
Expand Down Expand Up @@ -113,13 +120,6 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
System.lineSeparator() + s" $key=$value"
}

rewriteKrb5Conf()

testPrincipal = testPrincipal + "@" + kdc.getRealm

info(s"KerberizedTest Principal: $testPrincipal")
info(s"KerberizedTest Keytab: $testKeytab")

override def afterAll(): Unit = {
kdc.stop()
super.afterAll()
Expand Down

0 comments on commit 4fc6308

Please sign in to comment.