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

[incubator-openwhisk-cli] branch master updated: Test cases sync (#81)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 193c3c5  Test cases sync (#81)
193c3c5 is described below

commit 193c3c5731439eb0f1f03d56ee79f5b3a1e3734b
Author: Vincent <sh...@us.ibm.com>
AuthorDate: Tue Jul 11 22:18:33 2017 -0400

    Test cases sync (#81)
    
    * Create swagger operationId values for code tooling consumption (#2388)
    
    * Display CORS Headers for Non-Options Requests (Review) (#2444)
    
    * Normalize rate checks to the identity namespace (uuid). (#2433)
    
    * Add default allow headers. (#2451)
    
    * 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
---
 Godeps/Godeps.json                                 |  2 +-
 tests/dat/actions/corsHeaderMod.js                 |  5 +-
 .../apigw/endpoints.without.action.swagger.json    | 76 ++++++++++++++++++++++
 .../scala/whisk/core/cli/test/ApiGwTests.scala     | 37 ++++++++++-
 .../whisk/core/cli/test/WskWebActionsTests.scala   | 46 +++++++++----
 wski18n/i18n_resources.go                          | 23 +++----
 6 files changed, 164 insertions(+), 25 deletions(-)

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 3cb00de..2a0a1d5 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
@@ -640,7 +640,7 @@ class ApiGwTests
     it should "verify successful creation and deletion of a new API" in {
         val testName = "CLI_APIGWTEST1"
         val testbasepath = "/"+testName+"_bp"
-        val testrelpath = "/path"
+        val testrelpath = "/path/with/sub_paths/in/it"
         val testnewrelpath = "/path_new"
         val testurlop = "get"
         val testapiname = testName+" API Name"
@@ -658,6 +658,8 @@ class ApiGwTests
             rr.stdout should include("ok: APIs")
             rr.stdout should include regex (s"/${clinamespace}/${actionName}\\s+${testurlop}\\s+${testapiname}\\s+")
             rr.stdout should include(testbasepath + testrelpath)
+            rr = apiGet(basepathOrApiName = Some(testbasepath))
+            rr.stdout should include regex (s""""operationId":\\s+"getPathWithSub_pathsInIt"""")
             val deleteresult = apiDelete(basepathOrApiName = testbasepath)
             deleteresult.stdout should include("ok: deleted API")
         }
@@ -1210,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 c8a4883..1f38acd 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -89,8 +89,7 @@ class WskWebActionsTestsV2 extends WskWebActionsTests with BeforeAndAfterAll {
 
             val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
             assetHelper.withCleaner(wsk.action, actionName) {
-                (action, _) =>
-                    action.create(actionName, file, web = Some(true.toString))(wp)
+                (action, _) => action.create(actionName, file, web = Some(true.toString))(wp)
             }
 
             val url = getServiceApiHost(vanitySubdomain, true) + s"/default/$actionName.text/a?a=A"
@@ -148,8 +147,7 @@ trait WskWebActionsTests
             val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
 
             assetHelper.withCleaner(wsk.action, name) {
-                (action, _) =>
-                    action.create(name, file, web = Some("true"))
+                (action, _) => action.create(name, file, web = Some("true"))
             }
 
             val host = getServiceURL()
@@ -215,19 +213,47 @@ trait WskWebActionsTests
         (wp, assetHelper) =>
             val name = "webaction"
             val file = Some(TestCLIUtils.getTestActionFilename("corsHeaderMod.js"))
+            val host = getServiceURL()
+            val url = host + s"$testRoutePath/$namespace/default/webaction.http"
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) =>
                     action.create(name, file, web = Some("true"), annotations = Map("web-custom-options" -> true.toJson))
             }
 
-            val host = getServiceURL()
-            val url = host + s"$testRoutePath/$namespace/default/webaction.http"
-
             val response = RestAssured.given().config(sslconfig).options(url)
+
             response.statusCode shouldBe 200
             response.header("Access-Control-Allow-Origin") shouldBe "Origin set from Web Action"
+            response.header("Access-Control-Allow-Methods") shouldBe "Methods set from Web Action"
             response.header("Access-Control-Allow-Headers") shouldBe "Headers set from Web Action"
+            response.header("Location") shouldBe "openwhisk.org"
+            response.header("Set-Cookie") shouldBe "cookie-cookie-cookie"
+    }
+
+    it should "ensure that default CORS header is preserved" in withAssetCleaner(wskprops) {
+        (wp, assetHelper) =>
+            val name = "webaction"
+            val file = Some(TestCLIUtils.getTestActionFilename("corsHeaderMod.js"))
+            val host = getServiceURL()
+            val url = host + s"$testRoutePath/$namespace/default/webaction"
+
+            assetHelper.withCleaner(wsk.action, name) {
+                (action, _) => action.create(name, file, web = Some("true"))
+            }
+
+            val responses = Seq(
+                RestAssured.given().config(sslconfig).options(s"$url.http"),
+                RestAssured.given().config(sslconfig).get(s"$url.json"))
+
+            responses.foreach { response =>
+                response.statusCode shouldBe 200
+                response.header("Access-Control-Allow-Origin") shouldBe "*"
+                response.header("Access-Control-Allow-Methods") shouldBe "OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH"
+                response.header("Access-Control-Allow-Headers") shouldBe "Authorization, Content-Type"
+                response.header("Location") shouldBe null
+                response.header("Set-Cookie") shouldBe null
+            }
     }
 
     it should "invoke web action to ensure the returned body argument is correct" in withAssetCleaner(wskprops) {
@@ -237,8 +263,7 @@ trait WskWebActionsTests
             val bodyContent = "This is the body"
 
             assetHelper.withCleaner(wsk.action, name) {
-                (action, _) =>
-                    action.create(name, file, web = Some("true"))
+                (action, _) => action.create(name, file, web = Some("true"))
             }
 
             val host = getServiceURL()
@@ -263,8 +288,7 @@ trait WskWebActionsTests
             val file = Some(TestCLIUtils.getTestActionFilename("textBody.js"))
 
             assetHelper.withCleaner(wsk.action, name) {
-                (action, _) =>
-                    action.create(name, file, web = Some("true"))
+                (action, _) => action.create(name, file, web = Some("true"))
             }
 
             val host = getServiceURL()
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>'].