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/09/22 15:03:38 UTC

[incubator-openwhisk-cli] 03/07: Display content-type in __ow_headers for web actions (#2741)

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 300a2bb94098a9de003394c1c4d2a25865517c0a
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Mon Sep 18 16:32:14 2017 -0500

    Display content-type in __ow_headers for web actions (#2741)
---
 .../whisk/core/cli/test/WskWebActionsTests.scala   | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

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 1a8ff04..e24964b 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -59,6 +59,37 @@ class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil w
 
   behavior of "Wsk Web Actions"
 
+  it should "ensure __ow_headers contains the proper content-type" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
+    val name = "webContenttype"
+    val file = Some(TestUtils.getTestActionFilename("echo.js"))
+    val bodyContent = JsObject("key" -> "value".toJson)
+    val host = getServiceURL()
+    val url = s"$host$testRoutePath/$namespace/default/$name.json"
+
+    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+      action.create(name, file, web = Some("true"))
+    }
+
+    val resWithContentType =
+      RestAssured.given().contentType("application/json").body(bodyContent.compactPrint).config(sslconfig).post(url)
+
+    resWithContentType.statusCode shouldBe 200
+    resWithContentType.header("Content-type") shouldBe "application/json"
+    resWithContentType.body.asString.parseJson.asJsObject
+      .fields("__ow_headers")
+      .asJsObject
+      .fields("content-type") shouldBe "application/json".toJson
+
+    val resWithoutContentType =
+      RestAssured.given().config(sslconfig).get(url)
+
+    resWithoutContentType.statusCode shouldBe 200
+    resWithoutContentType.header("Content-type") shouldBe "application/json"
+    resWithoutContentType.body.asString.parseJson.asJsObject
+      .fields("__ow_headers")
+      .toString should not include ("content-type")
+  }
+
   /**
     * Tests web actions, plus max url limit.
     */

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