You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/12/05 20:33:00 UTC

[GitHub] mdeuser commented on a change in pull request #2966: WIP: Path parameter support for API GW

mdeuser commented on a change in pull request #2966: WIP: Path parameter support for API GW
URL: https://github.com/apache/incubator-openwhisk/pull/2966#discussion_r155067799
 
 

 ##########
 File path: tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
 ##########
 @@ -163,6 +163,127 @@ abstract class ApiGwTests extends BaseApiGwTests {
     rr.stderr should include("The supplied authentication is invalid")
   }
 
+  behavior of "Wsk api creation with path parameters no swagger"
+
+  it should "fail to create an Api if the base path contains path parameters" in {
+    val badBasePath = "/bad/{path}/value"
+    var rr = apiCreate(
+      basepath = Some(badBasePath),
+      relpath = Some("/good/path"),
+      operation = Some("GET"),
+      action = Some("action"),
+      expectedExitCode = ANY_ERROR_EXIT)
+    rr.stderr should include(
+      s"The base path (${badBasePath}) cannot have parameters. Only the relative path supports path parameters.")
+  }
+
+  it should "fail to create an Api if the relative path contains invalid parameters" in withAssetCleaner(wskprops) {
+    (wp, assetHelper) =>
+      val badBasePath = "/bad/path/value"
+      val errMsg =
+        "Relative path '%s' does not include valid path parameters.  Each parameter must be enclosed in curly braces{}"
+      val actionName = "test_Invalid_params_action"
+
+      val file = TestUtils.getTestActionFilename(s"echo-web-http.js")
+      assetHelper.withCleaner(wsk.action, actionName, confirmDelete = true) { (action, _) =>
+        action.create(actionName, Some(file), web = Some("true"))
+      }
+
+      var testPath = "/good/{path"
+      var rr = apiCreate(
+        basepath = Some(badBasePath),
+        relpath = Some(testPath),
+        operation = Some("GET"),
+        action = Some(actionName),
+        expectedExitCode = ANY_ERROR_EXIT,
+        responsetype = Some("http"))
+      rr.stderr should include(errMsg.format(testPath))
+
+      testPath = "/good/path}"
+      rr = apiCreate(
+        basepath = Some(badBasePath),
+        relpath = Some(testPath),
+        operation = Some("GET"),
+        action = Some(actionName),
+        expectedExitCode = ANY_ERROR_EXIT,
+        responsetype = Some("http"))
+      rr.stderr should include(errMsg.format(testPath))
+
+      testPath = "/{good/path"
+      rr = apiCreate(
+        basepath = Some(badBasePath),
+        relpath = Some(testPath),
+        operation = Some("GET"),
+        action = Some(actionName),
+        expectedExitCode = ANY_ERROR_EXIT,
+        responsetype = Some("http"))
+      rr.stderr should include(errMsg.format(testPath))
+
+      testPath = "/good}/path"
+      rr = apiCreate(
+        basepath = Some(badBasePath),
+        relpath = Some(testPath),
+        operation = Some("GET"),
+        action = Some(actionName),
+        expectedExitCode = ANY_ERROR_EXIT,
+        responsetype = Some("http"))
+      rr.stderr should include(errMsg.format(testPath))
+  }
+
+  behavior of "Wsk api creation with path parameters using swagger"
+
+  it should "fail to create API when swagger file contains invalid action response type" in {
+    val file = TestUtils.getTestApiGwFilename("invalidActionType.json")
 
 Review comment:
   should we start to inline our swagger with the test case?
   see https://github.com/apache/incubator-openwhisk/blob/2467c6bc10658f5c4f8520e474a4418beb284d32/tests/src/test/scala/actionContainers/NodeJs8ActionContainerTests.scala#L31 for example of inline action code.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services