rabbah commented on a change in pull request #2444: Display CORS Headers for
Non-Options Requests (Review)
URL:
https://github.com/apache/incubator-openwhisk/pull/2444#discussion_r125084292
##########
File path: tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
##########
@@ -215,19 +215,46 @@ trait WskWebActionsTests
(wp, assetHelper) =>
val name = "webaction"
val file =
Some(TestUtils.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-Headers") shouldBe "Headers
set from Web Action"
+ response.header("Access-Control-Allow-Methods") shouldBe "Methods
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(TestUtils.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"))
Review comment:
i find this a little easier to parse:
```
val responses = Seq(
RestAssured.given().config(sslconfig).options(s"$url.http"),
RestAssured.given().config(sslconfig).get(s"$url.json"))
```
----------------------------------------------------------------
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