You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by gi...@git.apache.org on 2017/09/06 22:16:45 UTC

[GitHub] rabbah commented on a change in pull request #2676: Change response when entity is empty from 200 to 204.

rabbah commented on a change in pull request #2676: Change response when entity is empty from 200 to 204.
URL: https://github.com/apache/incubator-openwhisk/pull/2676#discussion_r137404360
 
 

 ##########
 File path: tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
 ##########
 @@ -699,20 +699,36 @@ trait WebActionsApiTests extends ControllerTestCommon with BeforeAndAfterEach wi
         it should s"handle http web action and provide defaults (auth? ${creds.isDefined})" in {
             implicit val tid = transid()
 
+            def confirmEmptyResponse() = {
+                status should be(NoContent)
+                response.entity shouldBe HttpEntity.Empty
+                withClue(headers) {
+                    headers.length shouldBe 0
+                }
+            }
+
             Seq(s"$systemId/proxy/export_c.http").
                 foreach { path =>
-                    allowedMethods.foreach { m =>
-                        invocationsAllowed += 1
-                        actionResult = Some(JsObject())
+                    Set(JsObject(), JsObject("body" -> "".toJson), JsObject("body" -> JsNull)).
+                        foreach { bodyResult =>
+                            allowedMethods.foreach { m =>
+                                invocationsAllowed += 2
+                                actionResult = Some(bodyResult)
+
+                                m(s"$testRoutePath/$path") ~> Route.seal(routes(creds)) ~> check {
+                                    withClue(s"failed for: $bodyResult") {
+                                        confirmEmptyResponse()
+                                    }
+                                }
 
-                        m(s"$testRoutePath/$path") ~> Route.seal(routes(creds)) ~> check {
-                            status should be(OK)
-                            response.entity shouldBe HttpEntity.Empty
-                            withClue(headers) {
-                                headers.length shouldBe 0
+                                // repeat with accept header, which should be ignored for content-negotiation
+                                m(s"$testRoutePath/$path") ~> addHeader("Accept", "application/json") ~> Route.seal(routes(creds)) ~> check {
 
 Review comment:
   I deliberately use the string when setting custom headers, but the constant when checking the expected result. I rather leave it this way since it mimics the actual header values one might set literally.
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services