You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ho...@apache.org on 2017/07/12 03:18:33 UTC

[incubator-openwhisk-cli] 05/05: wsk CLI should tolerate APIs that do not yet have a mapped action (#2458)

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 93a09ce891e47d2ccd691ad3f5137cd81eef2987
Author: Mark Deuser <md...@us.ibm.com>
AuthorDate: Fri Jul 7 14:40:19 2017 -0400

    wsk CLI should tolerate APIs that do not yet have a mapped action (#2458)
    
    * wsk CLI should tolerate APIs that do not yet have a mapped action
    - bump API GW version so that action-less APIs can be created via cli/swagger
    
    * Add `wsk api list --full` test for action-less apis
---
 .idea/libraries/GOPATH__openwhisk_.xml             | 20 ------
 Godeps/Godeps.json                                 |  2 +-
 tests/dat/actions/corsHeaderMod.js                 |  5 +-
 .../apigw/endpoints.without.action.swagger.json    | 76 ++++++++++++++++++++++
 .../scala/whisk/core/cli/test/ApiGwTests.scala     | 33 ++++++++++
 .../whisk/core/cli/test/WskWebActionsTests.scala   |  2 +-
 wski18n/i18n_resources.go                          | 23 +++----
 7 files changed, 127 insertions(+), 34 deletions(-)

diff --git a/.idea/libraries/GOPATH__openwhisk_.xml b/.idea/libraries/GOPATH__openwhisk_.xml
deleted file mode 100644
index d91fdc8..0000000
--- a/.idea/libraries/GOPATH__openwhisk_.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<component name="libraryTable">
-  <library name="GOPATH &lt;openwhisk&gt;">
-    <CLASSES>
-      <root url="file://$USER_HOME$/go/src/github.com" />
-      <root url="file://$USER_HOME$/go/src/github.ibm.com" />
-      <root url="file://$USER_HOME$/go/src/gopkg.in" />
-      <root url="file://$USER_HOME$/go/src/golang.org" />
-    </CLASSES>
-    <JAVADOC />
-    <SOURCES>
-      <root url="file://$USER_HOME$/go/src/github.com" />
-      <root url="file://$USER_HOME$/go/src/github.ibm.com" />
-      <root url="file://$USER_HOME$/go/src/gopkg.in" />
-      <root url="file://$USER_HOME$/go/src/golang.org" />
-    </SOURCES>
-    <excluded>
-      <root url="file://$PROJECT_DIR$" />
-    </excluded>
-  </library>
-</component>
\ No newline at end of file
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index 8c53ce4..23af91a 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -65,7 +65,7 @@
 		},
         {
             "ImportPath": "github.com/apache/incubator-openwhisk-client-go/...",
-            "Rev": "a75fb9114e60a10b42dcc351ffba280fc989caa6"
+            "Rev": "c997fa3bc91903113eeee087a13f2a0b27fe1f6a"
         }
 	]
 }
diff --git a/tests/dat/actions/corsHeaderMod.js b/tests/dat/actions/corsHeaderMod.js
index b85b4a1..a658160 100644
--- a/tests/dat/actions/corsHeaderMod.js
+++ b/tests/dat/actions/corsHeaderMod.js
@@ -2,7 +2,10 @@ function main() {
     return {
         headers: {
             "Access-Control-Allow-Origin": "Origin set from Web Action",
-            "Access-Control-Allow-Headers": "Headers set from Web Action"
+            "Access-Control-Allow-Headers": "Headers set from Web Action",
+            "Access-Control-Allow-Methods": "Methods set from Web Action",
+            "Location": "openwhisk.org",
+            "Set-Cookie": "cookie-cookie-cookie"
         },
         code: 200
     }
diff --git a/tests/dat/apigw/endpoints.without.action.swagger.json b/tests/dat/apigw/endpoints.without.action.swagger.json
new file mode 100644
index 0000000..2305643
--- /dev/null
+++ b/tests/dat/apigw/endpoints.without.action.swagger.json
@@ -0,0 +1,76 @@
+{
+    "swagger": "2.0",
+    "basePath": "/NoActions",
+    "info": {
+        "title": "A descriptive name",
+        "version": "1.0"
+    },
+    "paths": {
+        "/": {
+            "delete": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            },
+            "get": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            },
+            "head": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            },
+            "options": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            },
+            "patch": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            },
+            "post": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            },
+            "put": {
+                "operationId": "",
+                "responses": {
+                    "200": {
+                        "description": "A successful invocation response"
+                    }
+                }
+            }
+        }
+    },
+    "x-ibm-configuration": {
+        "assembly": {
+            "execute": []
+        },
+        "cors": {
+            "enabled": true
+        }
+    }
+}
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 a2d0a3c..2a0a1d5 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
@@ -1212,4 +1212,37 @@ class ApiGwTests
         var rr = apiDelete(basepathOrApiName = nonexistentApi, expectedExitCode = ANY_ERROR_EXIT)
         rr.stderr should include (s"API '${nonexistentApi}' does not exist")
     }
+
+    it should "successfully list an API whose endpoints are not mapped to actions" in {
+        val testName = "CLI_APIGWTEST23"
+        var testapiname = "A descriptive name"
+        val testbasepath = "/NoActions"
+        val testrelpath = "/"
+        val testops: Seq[String] = Seq("put", "delete", "get", "head", "options", "patch", "post")
+        val swaggerPath = TestCLIUtils.getTestApiGwFilename(s"endpoints.without.action.swagger.json")
+
+        try {
+            var rr = apiCreate(swagger = Some(swaggerPath))
+            println("api create stdout: " + rr.stdout)
+            println("api create stderror: " + rr.stderr)
+            rr.stdout should include("ok: created API")
+
+            rr = apiList(basepathOrApiName = Some(testbasepath))
+            println("api list:\n" + rr.stdout)
+            testops foreach { testurlop =>
+                rr.stdout should include regex (s"\\s+${testurlop}\\s+${testapiname}\\s+")
+            }
+            rr.stdout should include(testbasepath + testrelpath)
+
+            rr = apiList(basepathOrApiName = Some(testbasepath), full = Some(true))
+            println("api full list:\n" + rr.stdout)
+            testops foreach { testurlop =>
+                rr.stdout should include regex (s"Verb:\\s+${testurlop}")
+            }
+            rr.stdout should include(testbasepath + testrelpath)
+
+        } finally {
+            val deleteresult = apiDelete(basepathOrApiName = testbasepath, expectedExitCode = DONTCARE_EXIT)
+        }
+    }
 }
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
index b250e67..1f38acd 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -234,7 +234,7 @@ trait WskWebActionsTests
     it should "ensure that default CORS header is preserved" in withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
             val name = "webaction"
-            val file = Some(TestUtils.getTestActionFilename("corsHeaderMod.js"))
+            val file = Some(TestCLIUtils.getTestActionFilename("corsHeaderMod.js"))
             val host = getServiceURL()
             val url = host + s"$testRoutePath/$namespace/default/webaction"
 
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index eda4f46..39ebbc8 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -109,12 +109,12 @@ func wski18nResourcesDe_deAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
 
-var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x5d\x5f\x73\xdb\x38\x92\x7f\x9f\x4f\xd1\x95\x17\x3b\x55\xb2\xb3\xfb\x74\x75\x99\x9a\x07\x4d\xec\xd9\x78\x93\xd8\xae\xc8\x99\xdd\xa9\x9b\xab\x11\x4c\x42\x12\xc6\x14\xc0\x01\x40\x2b\x4a\xd6\xdf\xfd\x0a\x00\x49\x91\x12\xfe\x92\x72\x72\x4f\x71\xc4\xee\x5f\x37\xfe\x37\x1a\xdd\xc0\xff\xfc\x00\xf0\xf5\x07\x00\x80\x17\x24\x7f\xf1\x1a\x5e\x4c\xcb\xb2\x20\x19\x92\x84\x51\xc0\x9f\x89\xc4\x39\x54\x14\x7f\x2e\x71 [...]
+var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x5d\x5f\x73\xdb\x38\x92\x7f\x9f\x4f\xd1\x95\x17\x3b\x55\xb2\xb3\xfb\x74\x75\x99\x9a\x07\x4d\xec\xd9\x78\x93\xd8\xae\xc8\x99\xdd\xa9\x9b\xab\x11\x4c\x42\x12\xc6\x14\xc0\x01\x40\x2b\x4a\xd6\xdf\xfd\x0a\x00\x49\x91\x12\xfe\x92\x72\x72\x4f\x71\xc4\xee\x5f\x37\xfe\x37\x1a\xdd\xc0\xff\xfc\x00\xf0\xf5\x07\x00\x80\x17\x24\x7f\xf1\x1a\x5e\x4c\xcb\xb2\x20\x19\x92\x84\x51\xc0\x9f\x89\xc4\x39\x54\x14\x7f\x2e\x71 [...]
 
 func wski18nResourcesEn_usAllJsonBytes() ([]byte, error) {
     return bindataRead(
@@ -129,7 +129,7 @@ func wski18nResourcesEn_usAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 48166, mode: os.FileMode(420), modTime: time.Unix(1498103751, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 48413, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -149,7 +149,7 @@ func wski18nResourcesEs_esAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -169,7 +169,7 @@ func wski18nResourcesFr_frAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -189,7 +189,7 @@ func wski18nResourcesIt_itAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -209,7 +209,7 @@ func wski18nResourcesJa_jaAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -229,7 +229,7 @@ func wski18nResourcesKo_krAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -249,7 +249,7 @@ func wski18nResourcesPt_brAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -269,7 +269,7 @@ func wski18nResourcesZh_hansAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -289,7 +289,7 @@ func wski18nResourcesZh_hantAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1498102835, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1499746842, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -460,3 +460,4 @@ func _filePath(dir, name string) string {
     cannonicalName := strings.Replace(name, "\\", "/", -1)
     return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
 }
+

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