You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ho...@apache.org on 2017/07/17 14:10:30 UTC
[incubator-openwhisk-cli] 07/09: Get Action URL from CLI (#2461)
This is an automated email from the ASF dual-hosted git repository.
houshengbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 2339ec3f0e267b04a2562d53acd4f95f72957f96
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Wed Jul 12 13:20:40 2017 -0400
Get Action URL from CLI (#2461)
---
.../whisk/core/cli/test/WskBasicUsageTests.scala | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
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 faef3dd..ea2c8d4 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -21,6 +21,7 @@ import java.io.File
import java.io.BufferedWriter
import java.io.FileWriter
import java.time.Instant
+import java.net.URLEncoder
import scala.language.postfixOps
import scala.concurrent.duration.Duration
@@ -696,6 +697,63 @@ class WskBasicUsageTests
}
}
+ it should "get an action URL" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val actionName = "action name@_-."
+ val packageName = "package name@_-."
+ val defaultPackageName = "default"
+ val webActionName = "web action name@_-."
+ val nonExistentActionName = "non-existence action"
+ val packagedAction = s"$packageName/$actionName"
+ val packagedWebAction = s"$packageName/$webActionName"
+ val (user, namespace) = WskAdmin.getUser(wskprops.authKey)
+ val encodedActionName = URLEncoder.encode(actionName, "UTF-8").replace("+", "%20")
+ val encodedPackageName = URLEncoder.encode(packageName, "UTF-8").replace("+", "%20")
+ val encodedWebActionName = URLEncoder.encode(webActionName, "UTF-8").replace("+", "%20")
+ val encodedNamespace = URLEncoder.encode(namespace, "UTF-8").replace("+", "%20")
+ val actionPath = "https://%s/api/%s/namespaces/%s/actions/%s"
+ val packagedActionPath = s"$actionPath/%s"
+ val webActionPath = "https://%s/api/%s/web/%s/%s/%s"
+
+ assetHelper.withCleaner(wsk.action, actionName) {
+ (action, _) => action.create(actionName, defaultAction)
+ }
+
+ assetHelper.withCleaner(wsk.action, webActionName) {
+ (action, _) => action.create(webActionName, defaultAction, web = Some("true"))
+ }
+
+ assetHelper.withCleaner(wsk.pkg, packageName) {
+ (pkg, _) => pkg.create(packageName)
+ }
+
+ assetHelper.withCleaner(wsk.action, packagedAction) {
+ (action, _) => action.create(packagedAction, defaultAction)
+ }
+
+ assetHelper.withCleaner(wsk.action, packagedWebAction) {
+ (action, _) => action.create(packagedWebAction, defaultAction, web = Some("true"))
+ }
+
+ wsk.action.get(actionName, url = Some(true)).
+ stdout should include(actionPath.format(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))
+
+ wsk.action.get(webActionName, url = Some(true)).
+ stdout should include(webActionPath.format(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))
+
+ wsk.action.get(packagedWebAction, url = Some(true)).
+ stdout should include(webActionPath.format(wskprops.apihost, wskprops.apiversion, encodedNamespace, encodedPackageName, encodedWebActionName))
+
+ wsk.action.get(nonExistentActionName, url = Some(true), expectedExitCode = NOT_FOUND)
+ }
+
behavior of "Wsk packages"
it should "create, and delete a package" in {
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.