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:10 UTC

[incubator-openwhisk-cli] 30/36: Update OPTIONS Respones for Web Actions (Review) (#2327)

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 adf726252da20196c6834403504d5980ff6f22a0
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Mon Jun 19 10:23:14 2017 -0400

    Update OPTIONS Respones for Web Actions (Review) (#2327)
    
    Web actions may now optionally elect to respond to OPTIONS verb.
---
 .../whisk/core/cli/test/WskWebActionsTests.scala   | 38 ++++++++++------------
 1 file changed, 18 insertions(+), 20 deletions(-)

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 547d8eb..31c776a 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -148,7 +148,7 @@ trait WskWebActionsTests
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) =>
-                    action.create(name, file, annotations = Map("web-export" -> true.toJson))
+                    action.create(name, file, web = Some("true"))
             }
 
             val host = getServiceURL()
@@ -187,7 +187,7 @@ trait WskWebActionsTests
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) =>
-                    action.create(name, file, annotations = Map("web-export" -> true.toJson, "require-whisk-auth" -> true.toJson))
+                    action.create(name, file, web = Some("true"), annotations = Map("require-whisk-auth" -> true.toJson))
             }
 
             val host = getServiceURL()
@@ -210,25 +210,23 @@ trait WskWebActionsTests
             authorizedResponse.body.asString shouldBe namespace
     }
 
-    if (testRoutePath == "/api/v1/web") {
-        it should "ensure that CORS header is preserved" in withAssetCleaner(wskprops) {
-            (wp, assetHelper) =>
-                val name = "webaction"
-                val file = Some(TestUtils.getTestActionFilename("corsHeaderMod.js"))
+    it should "ensure that CORS header is preserved for custom options" in withAssetCleaner(wskprops) {
+        (wp, assetHelper) =>
+            val name = "webaction"
+            val file = Some(TestUtils.getTestActionFilename("corsHeaderMod.js"))
 
-                assetHelper.withCleaner(wsk.action, name) {
-                    (action, _) =>
-                        action.create(name, file, annotations = Map("web-export" -> true.toJson))
-                }
+            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 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-Headers") shouldBe "Headers set from Web Action"
-        }
+            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-Headers") shouldBe "Headers set from Web Action"
     }
 
     it should "invoke web action to ensure the returned body argument is correct" in withAssetCleaner(wskprops) {
@@ -239,7 +237,7 @@ trait WskWebActionsTests
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) =>
-                    action.create(name, file, annotations = Map("web-export" -> true.toJson))
+                    action.create(name, file, web = Some("true"))
             }
 
             val host = getServiceURL()
@@ -265,7 +263,7 @@ trait WskWebActionsTests
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) =>
-                    action.create(name, file, annotations = Map("web-export" -> true.toJson))
+                    action.create(name, file, web = Some("true"))
             }
 
             val host = getServiceURL()

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