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 <[email protected]> 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 "[email protected]" <[email protected]>.
