@@ -20,6 +20,7 @@ package org.apache.spark
2020import java .io .File
2121import javax .net .ssl .SSLContext
2222
23+ import org .apache .hadoop .conf .Configuration
2324import org .scalatest .BeforeAndAfterAll
2425
2526import org .apache .spark .util .SparkConfWithEnv
@@ -40,6 +41,7 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
4041 .toSet
4142
4243 val conf = new SparkConf
44+ val hadoopConf = new Configuration ()
4345 conf.set(" spark.ssl.enabled" , " true" )
4446 conf.set(" spark.ssl.keyStore" , keyStorePath)
4547 conf.set(" spark.ssl.keyStorePassword" , " password" )
@@ -49,7 +51,7 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
4951 conf.set(" spark.ssl.enabledAlgorithms" , algorithms.mkString(" ," ))
5052 conf.set(" spark.ssl.protocol" , " TLSv1.2" )
5153
52- val opts = SSLOptions .parse(conf, " spark.ssl" )
54+ val opts = SSLOptions .parse(conf, hadoopConf, " spark.ssl" )
5355
5456 assert(opts.enabled === true )
5557 assert(opts.trustStore.isDefined === true )
@@ -70,6 +72,7 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
7072 val trustStorePath = new File (this .getClass.getResource(" /truststore" ).toURI).getAbsolutePath
7173
7274 val conf = new SparkConf
75+ val hadoopConf = new Configuration ()
7376 conf.set(" spark.ssl.enabled" , " true" )
7477 conf.set(" spark.ssl.keyStore" , keyStorePath)
7578 conf.set(" spark.ssl.keyStorePassword" , " password" )
@@ -80,8 +83,8 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
8083 " TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA" )
8184 conf.set(" spark.ssl.protocol" , " SSLv3" )
8285
83- val defaultOpts = SSLOptions .parse(conf, " spark.ssl" , defaults = None )
84- val opts = SSLOptions .parse(conf, " spark.ssl.ui" , defaults = Some (defaultOpts))
86+ val defaultOpts = SSLOptions .parse(conf, hadoopConf, " spark.ssl" , defaults = None )
87+ val opts = SSLOptions .parse(conf, hadoopConf, " spark.ssl.ui" , defaults = Some (defaultOpts))
8588
8689 assert(opts.enabled === true )
8790 assert(opts.trustStore.isDefined === true )
@@ -103,6 +106,7 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
103106 val trustStorePath = new File (this .getClass.getResource(" /truststore" ).toURI).getAbsolutePath
104107
105108 val conf = new SparkConf
109+ val hadoopConf = new Configuration ()
106110 conf.set(" spark.ssl.enabled" , " true" )
107111 conf.set(" spark.ssl.ui.enabled" , " false" )
108112 conf.set(" spark.ssl.ui.port" , " 4242" )
@@ -117,8 +121,8 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
117121 conf.set(" spark.ssl.ui.enabledAlgorithms" , " ABC, DEF" )
118122 conf.set(" spark.ssl.protocol" , " SSLv3" )
119123
120- val defaultOpts = SSLOptions .parse(conf, " spark.ssl" , defaults = None )
121- val opts = SSLOptions .parse(conf, " spark.ssl.ui" , defaults = Some (defaultOpts))
124+ val defaultOpts = SSLOptions .parse(conf, hadoopConf, " spark.ssl" , defaults = None )
125+ val opts = SSLOptions .parse(conf, hadoopConf, " spark.ssl.ui" , defaults = Some (defaultOpts))
122126
123127 assert(opts.enabled === false )
124128 assert(opts.port === Some (4242 ))
@@ -139,12 +143,13 @@ class SSLOptionsSuite extends SparkFunSuite with BeforeAndAfterAll {
139143 val conf = new SparkConfWithEnv (Map (
140144 " ENV1" -> " val1" ,
141145 " ENV2" -> " val2" ))
146+ val hadoopConf = new Configuration ()
142147
143148 conf.set(" spark.ssl.enabled" , " true" )
144149 conf.set(" spark.ssl.keyStore" , " ${env:ENV1}" )
145150 conf.set(" spark.ssl.trustStore" , " ${env:ENV2}" )
146151
147- val opts = SSLOptions .parse(conf, " spark.ssl" , defaults = None )
152+ val opts = SSLOptions .parse(conf, hadoopConf, " spark.ssl" , defaults = None )
148153 assert(opts.keyStore === Some (new File (" val1" )))
149154 assert(opts.trustStore === Some (new File (" val2" )))
150155 }
0 commit comments