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 7230330f493de01d8056122b9fd32f5dd6bf501a Author: James Dubee <[email protected]> AuthorDate: Fri Jun 30 13:00:00 2017 -0400 Display CORS Headers for Non-Options Requests (Review) (#2444) --- .idea/libraries/GOPATH__openwhisk_.xml | 20 +++++++++++++ .../whisk/core/cli/test/WskWebActionsTests.scala | 33 ++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/.idea/libraries/GOPATH__openwhisk_.xml b/.idea/libraries/GOPATH__openwhisk_.xml new file mode 100644 index 0000000..d91fdc8 --- /dev/null +++ b/.idea/libraries/GOPATH__openwhisk_.xml @@ -0,0 +1,20 @@ +<component name="libraryTable"> + <library name="GOPATH <openwhisk>"> + <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/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala index c8a4883..8b39057 100644 --- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala @@ -215,19 +215,46 @@ 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-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")) + + 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("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) { -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
