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 2017/09/22 15:03:40 UTC
[incubator-openwhisk-cli] 05/07: Don't assume apihost is https for
sdk and action urls (#2748)
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 95e67fc1842e08f6e551092b3090b21a5921703e
Author: Ben Browning <be...@gmail.com>
AuthorDate: Wed Sep 20 15:21:51 2017 -0400
Don't assume apihost is https for sdk and action urls (#2748)
* Don't assume apihost is https for sdk and action urls
Reuse the getURLBase utility method when computing the URL for sdk
downloads and action URLs.
This fixes #2720 and fixes #2719.
* Cleanup some trailing whitespace I missed
* Missed this import in last-second rebase
* Update debug messages to match `GetURLBase` method name
---
.../src/test/scala/system/basic/WskSdkTests.scala | 19 +++++++++-
.../whisk/core/cli/test/WskBasicUsageTests.scala | 42 ++++++++++++++++++----
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/tests/src/test/scala/system/basic/WskSdkTests.scala b/tests/src/test/scala/system/basic/WskSdkTests.scala
index 62c8d60..df550b8 100644
--- a/tests/src/test/scala/system/basic/WskSdkTests.scala
+++ b/tests/src/test/scala/system/basic/WskSdkTests.scala
@@ -24,8 +24,8 @@ import scala.collection.JavaConversions.asScalaBuffer
import org.apache.commons.io.FileUtils
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
import common.TestHelpers
+import common.TestUtils.ERROR_EXIT
import common.TestUtils.SUCCESS_EXIT
import common.WhiskProperties
import common.Wsk
@@ -40,6 +40,23 @@ class WskSdkTests extends TestHelpers with WskTestHelpers {
behavior of "Wsk SDK"
+ it should "prefix https to apihost if no scheme given" in {
+ val result = wsk.cli(Seq("--apihost", "localhost:54321", "sdk", "install", "docker"), expectedExitCode = ERROR_EXIT)
+ result.stderr should include regex ("""(?i)Get https://localhost:54321/""")
+ }
+
+ it should "not prefix https to http apihost" in {
+ val result =
+ wsk.cli(Seq("--apihost", "http://localhost:54321", "sdk", "install", "docker"), expectedExitCode = ERROR_EXIT)
+ result.stderr should include regex ("""(?i)Get http://localhost:54321/""")
+ }
+
+ it should "not double prefix https to https apihost" in {
+ val result =
+ wsk.cli(Seq("--apihost", "https://localhost:54321", "sdk", "install", "docker"), expectedExitCode = ERROR_EXIT)
+ result.stderr should include regex ("""(?i)Get https://localhost:54321/""")
+ }
+
it should "download docker action sdk" in {
val dir = File.createTempFile("wskinstall", ".tmp")
dir.delete()
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
index 82c3693..ea23ce3 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -653,9 +653,10 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers {
val encodedPackageName = URLEncoder.encode(packageName, StandardCharsets.UTF_8.name).replace("+", "%20")
val encodedWebActionName = URLEncoder.encode(webActionName, StandardCharsets.UTF_8.name).replace("+", "%20")
val encodedNamespace = URLEncoder.encode(namespace, StandardCharsets.UTF_8.name).replace("+", "%20")
- val actionPath = "https://%s/api/%s/namespaces/%s/actions/%s"
+ val scheme = "https"
+ val actionPath = "%s://%s/api/%s/namespaces/%s/actions/%s"
val packagedActionPath = s"$actionPath/%s"
- val webActionPath = "https://%s/api/%s/web/%s/%s/%s"
+ val webActionPath = "%s://%s/api/%s/web/%s/%s/%s"
assetHelper.withCleaner(wsk.action, actionName) { (action, _) =>
action.create(actionName, defaultAction)
@@ -678,25 +679,52 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers {
}
wsk.action.get(actionName, url = Some(true)).stdout should include(
- actionPath.format(wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedActionName))
+ actionPath.format(scheme, wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedActionName))
// Ensure url flag works when a field filter and summary flag are specified
wsk.action.get(actionName, url = Some(true), fieldFilter = Some("field"), summary = true).stdout should include(
- actionPath.format(wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedActionName))
+ actionPath.format(scheme, wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedActionName))
wsk.action.get(webActionName, url = Some(true)).stdout should include(
webActionPath
- .format(wskprops.apihost, wskprops.apiversion, encodedNamespace, defaultPackageName, encodedWebActionName))
+ .format(
+ scheme,
+ wskprops.apihost,
+ wskprops.apiversion,
+ encodedNamespace,
+ defaultPackageName,
+ encodedWebActionName))
wsk.action.get(packagedAction, url = Some(true)).stdout should include(
packagedActionPath
- .format(wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedPackageName, encodedActionName))
+ .format(scheme, wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedPackageName, encodedActionName))
wsk.action.get(packagedWebAction, url = Some(true)).stdout should include(
webActionPath
- .format(wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedPackageName, encodedWebActionName))
+ .format(
+ scheme,
+ wskprops.apihost,
+ wskprops.apiversion,
+ encodedNamespace,
+ encodedPackageName,
+ encodedWebActionName))
wsk.action.get(nonExistentActionName, url = Some(true), expectedExitCode = NOT_FOUND)
+
+ val httpsProps = WskProps(apihost = "https://" + wskprops.apihost)
+ wsk.action.get(actionName, url = Some(true))(httpsProps).stdout should include(
+ actionPath
+ .format("https", wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedActionName))
+ wsk.action.get(webActionName, url = Some(true))(httpsProps).stdout should include(
+ webActionPath
+ .format(
+ "https",
+ wskprops.apihost,
+ wskprops.apiversion,
+ encodedNamespace,
+ defaultPackageName,
+ encodedWebActionName))
+
}
it should "limit length of HTTP request and response bodies for --verbose" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.