You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/12/17 12:48:22 UTC
[incubator-openwhisk-cli] 03/04: Inline SSL context logic as to
avoid loading of https config
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 28fcb93c0f574076e9e951f7e1531d32c0ee10de
Author: Chetan Mehrotra <ch...@apache.org>
AuthorDate: Fri Dec 14 11:17:11 2018 +0530
Inline SSL context logic as to avoid loading of https config
---
tests/src/test/scala/system/basic/HttpProxy.scala | 17 ++++++++++++++---
.../test/scala/system/basic/WskCliActivationTests.scala | 1 +
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/src/test/scala/system/basic/HttpProxy.scala b/tests/src/test/scala/system/basic/HttpProxy.scala
index 98b9a55..c0aa0e8 100644
--- a/tests/src/test/scala/system/basic/HttpProxy.scala
+++ b/tests/src/test/scala/system/basic/HttpProxy.scala
@@ -17,14 +17,16 @@
package system.basic
import java.net.ServerSocket
-import akka.http.scaladsl.Http
+import akka.http.scaladsl.{Http, HttpsConnectionContext}
import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}
import akka.http.scaladsl.model.Uri.Authority
import akka.http.scaladsl.server.Route
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink, Source}
+import com.typesafe.sslconfig.akka.AkkaSSLConfig
import common.{WskActorSystem, WskProps}
-import common.rest.SSL
+import common.rest.{AcceptAllHostNameVerifier, SSL}
+import javax.net.ssl.HostnameVerifier
import org.scalatest.Suite
import org.scalatest.concurrent.ScalaFutures
@@ -85,12 +87,21 @@ trait HttpProxy extends WskActorSystem with ScalaFutures {
Http(actorSystem).outgoingConnectionHttps(
uri.authority.host.address(),
uri.effectivePort,
- connectionContext = SSL.httpsConnectionContext)
+ connectionContext = httpsConnectionContext())
} else {
Http(actorSystem).outgoingConnection(uri.authority.host.address(), uri.effectivePort)
}
}
+ private def httpsConnectionContext() = {
+ val sslConfig = AkkaSSLConfig().mapSettings { s =>
+ s.withHostnameVerifierClass(classOf[AcceptAllHostNameVerifier].asInstanceOf[Class[HostnameVerifier]])
+ }
+ //SSL.httpsConnectionContext initializes config which is not there in cli test
+ //So inline the flow as we do not need client auth for this case
+ new HttpsConnectionContext(SSL.nonValidatingContext(false), Some(sslConfig))
+ }
+
private def proxyRequest(req: HttpRequest, uri: Uri): HttpRequest = {
//https://github.com/akka/akka-http/issues/64
req
diff --git a/tests/src/test/scala/system/basic/WskCliActivationTests.scala b/tests/src/test/scala/system/basic/WskCliActivationTests.scala
index 7eb8765..f840c3e 100644
--- a/tests/src/test/scala/system/basic/WskCliActivationTests.scala
+++ b/tests/src/test/scala/system/basic/WskCliActivationTests.scala
@@ -60,6 +60,7 @@ class WskCliActivationTests extends TestHelpers with WskTestHelpers with HttpPro
println(s"Running poll for $pollDuration")
val consoleFuture = Future {
+ //pass the `proxyProps` such that calls from poll cli command go via our proxy
wsk.activation.console(pollDuration, actionName = Some(name))(proxyProps)
}