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_r162449182
 
 

 ##########
 File path: tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
 ##########
 @@ -163,6 +164,67 @@ abstract class ApiGwTests extends BaseApiGwTests {
     rr.stderr should include("The supplied authentication is invalid")
   }
 
+  def replaceStringInFile(fileName: String, replacements: Map[Regex, String]): 
String = {
+    val encoding = "UTF-8"
+
+    val contents = FileUtils.readFileToString(new File(fileName), encoding)
+    var newContents = contents
+    replacements foreach ((regex) => newContents = 
regex._1.replaceAllIn(newContents, regex._2))
+    val tmpFileName = fileName + "-" + System.currentTimeMillis() + ".tmp"
+    val tmpFile = new File(tmpFileName)
+    if (tmpFile.exists()) {
+      FileUtils.forceDelete(tmpFile)
+    }
+    FileUtils.writeStringToFile(new File(tmpFileName), newContents, encoding)
+    tmpFileName
+  }
+
+  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.")
+  }
+
+  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("apigw_path_param_support_test_invalidActionType.json")
+    val rr = apiCreate(swagger = Some(file), expectedExitCode = ANY_ERROR_EXIT)
+    var errMsg = "API creation failure: The action must use a response type of 
"
+    errMsg += "'.http' in order to receive the path parameters."
 
 Review comment:
   possible to just use a single string instead of the `+=` ?

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


With regards,
Apache Git Services

Reply via email to