You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/06/26 16:00:00 UTC

[incubator-openwhisk-cli] 20/36: Remove "COMING SOON" from `wsk api` help plus critical fixes (#2149)

This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git

commit 763babadfe5e47fa927d24e759ba44f19ad4786a
Author: Mark Deuser <md...@us.ibm.com>
AuthorDate: Sat Apr 22 07:06:39 2017 -0400

    Remove "COMING SOON" from `wsk api` help plus critical fixes (#2149)
    
    * Remove "COMING SOON" from `wsk api` help
    
    * Auto supply a dummy API GW token when working against the open api gw
    
    * Correct API GW error response handling
    
    * Add --response-type to `wsk api create`
    
    * When api is created without a web action, provide sample command to convert action to web action
---
 .../apigw/healthtests/ApiGwEndToEndTests.scala     |  1 +
 .../actions/test/ApiGwRoutemgmtActionTests.scala   |  6 ++--
 .../scala/whisk/core/cli/test/ApiGwTests.scala     | 41 ++++++++++++++++++++--
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
index aa918ea..cb61f0f 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
@@ -167,6 +167,7 @@ class ApiGwEndToEndTests
                 operation = Some(testurlop),
                 action = Some(actionName),
                 apiname = Some(testapiname),
+                responsetype = Some("http"),
                 cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())
             )
             rr.stdout should include("ok: created API")
diff --git a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
index 96a1002..32a572a 100644
--- a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
+++ b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
@@ -484,7 +484,7 @@ class ApiGwRoutemgmtActionTests
         val testapiname = testName + " API Name"
         val actionName = testName + "_action"
         val actionNamespace = wskprops.namespace
-        val actionUrl = "https://some.whisk.host/api/v1/web/" + actionNamespace + "/default/" + actionName + ".http"
+        val actionUrl = "https://some.whisk.host/api/v1/web/" + actionNamespace + "/default/" + actionName + ".json"
         val actionAuthKey = testName + "_authkey"
         val testaction = ApiAction(name = actionName, namespace = actionNamespace, backendUrl = actionUrl, authkey = actionAuthKey)
 
@@ -508,7 +508,7 @@ class ApiGwRoutemgmtActionTests
         val testapiname = testName + " API Name"
         val actionName = testName + "_action"
         val actionNamespace = wskprops.namespace
-        val actionUrl = "https://some.whisk.host/api/v1/web/" + actionNamespace + "/default/" + actionName + ".http"
+        val actionUrl = "https://some.whisk.host/api/v1/web/" + actionNamespace + "/default/" + actionName + ".json"
         val actionAuthKey = testName + "_authkey"
         val testaction = ApiAction(name = actionName, namespace = actionNamespace, backendUrl = actionUrl, authkey = actionAuthKey)
 
@@ -537,7 +537,7 @@ class ApiGwRoutemgmtActionTests
         val testapiname = testName + " API Name"
         val actionName = testName + "_action"
         val actionNamespace = wskprops.namespace
-        val actionUrl = "https://some.whisk.host/api/v1/web/" + actionNamespace + "/default/" + actionName + ".http"
+        val actionUrl = "https://some.whisk.host/api/v1/web/" + actionNamespace + "/default/" + actionName + ".json"
         val actionAuthKey = testName + "_authkey"
         val testaction = ApiAction(name = actionName, namespace = actionNamespace, backendUrl = actionUrl, authkey = actionAuthKey)
 
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
index 249292f..fb02b83 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
@@ -159,10 +159,11 @@ class ApiGwTests
       action: Option[String] = None,
       apiname: Option[String] = None,
       swagger: Option[String] = None,
+      responsetype: Option[String] = None,
       expectedExitCode: Int = SUCCESS_EXIT,
       cliCfgFile: Option[String] = Some(cliWskPropsFile.getCanonicalPath())): RunResult = {
         checkThrottle()
-        wsk.api.create(basepath, relpath, operation, action, apiname, swagger, expectedExitCode, cliCfgFile)
+        wsk.api.create(basepath, relpath, operation, action, apiname, swagger, responsetype, expectedExitCode, cliCfgFile)
     }
 
     def apiList(
@@ -670,6 +671,7 @@ class ApiGwTests
       rr = apiGet(basepathOrApiName = Some(testapiname))
       rr.stdout should include(testbasepath)
       rr.stdout should include(s"${actionName}")
+      rr.stdout should include regex (s""""target-url":\\s+.*${actionName}.json""")
     }
     finally {
       val finallydeleteActionResult = wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT)
@@ -1019,7 +1021,7 @@ class ApiGwTests
     }
   }
 
-  it should "reject an API created with an action that is not a web-action" in {
+  it should "reject an API created with an action that is not a web action" in {
     val testName = "CLI_APIGWTEST16"
     val testbasepath = "/" + testName + "_bp"
     val testbasepath2 = "/" + testName + "_bp2"
@@ -1034,11 +1036,44 @@ class ApiGwTests
       wsk.action.create(name = actionName, artifact = Some(file), expectedExitCode = SUCCESS_EXIT)
 
       var rr = apiCreate(basepath = Some(testbasepath), relpath = Some(testrelpath), operation = Some(testurlop), action = Some(actionName), apiname = Some(testapiname), expectedExitCode = ANY_ERROR_EXIT)
-      rr.stderr should include("API action is not a web-action")
+      rr.stderr should include("is not a web action")
     } finally {
       val finallydeleteActionResult = wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT)
       var deleteresult = apiDelete(basepathOrApiName = testbasepath, expectedExitCode = DONTCARE_EXIT)
     }
   }
 
+  it should "verify API with http response type " in {
+    val testName = "CLI_APIGWTEST17"
+    val testbasepath = "/"+testName+"_bp"
+    val testrelpath = "/path"
+    val testnewrelpath = "/path_new"
+    val testurlop = "get"
+    val testapiname = testName+" API Name"
+    val actionName = testName+"_action"
+    val responseType = "http"
+    try {
+      // Create the action for the API.  It must be a "web-action" action.
+      val file = TestUtils.getTestActionFilename(s"echo.js")
+      wsk.action.create(name = actionName, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, annotations = Map("web-export" -> true.toJson))
+
+      var rr = apiCreate(
+          basepath = Some(testbasepath),
+          relpath = Some(testrelpath),
+          operation = Some(testurlop),
+          action = Some(actionName),
+          apiname = Some(testapiname),
+          responsetype = Some(responseType)
+      )
+      rr.stdout should include("ok: created API")
+      rr = apiGet(basepathOrApiName = Some(testapiname))
+      rr.stdout should include(testbasepath)
+      rr.stdout should include(s"${actionName}")
+      rr.stdout should include regex (s""""target-url":\\s+.*${actionName}.${responseType}""")
+    }
+    finally {
+      val finallydeleteActionResult = wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT)
+      val deleteresult = apiDelete(basepathOrApiName = testbasepath, expectedExitCode = DONTCARE_EXIT)
+    }
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.