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/06 16:19:03 UTC

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

jessealva 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_r155284254
 
 

 ##########
 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:
   @mdeuser I thought about this and did it initially, but each of the swagger files I would inline is about 62 lines long.  Considering I have 9 swagger files, at 62 lines each, thats about 560 NEW lines of "code" that are just the swagger definitions that we'd be adding to a test class thats already 1000 lines long.  Seems like it would make it a bit more unwieldy to read later on as we add more tests.  
   
   So i decided to extract the swagger to an external file to try to keep the test class at a reasonable size.

----------------------------------------------------------------
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