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 2018/02/24 05:11:36 UTC
[incubator-openwhisk] branch master updated: Normalize a missing
body for raw actions to JsString.empty. (#3323)
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.git
The following commit(s) were added to refs/heads/master by this push:
new d182970 Normalize a missing body for raw actions to JsString.empty. (#3323)
d182970 is described below
commit d18297008a088f06aa68a23c349a54f3ef44488a
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Sat Feb 24 00:11:32 2018 -0500
Normalize a missing body for raw actions to JsString.empty. (#3323)
---
.../scala/whisk/core/controller/WebActions.scala | 4 ++--
.../core/controller/test/WebActionsApiTests.scala | 20 +++++++++++++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/core/controller/src/main/scala/whisk/core/controller/WebActions.scala b/core/controller/src/main/scala/whisk/core/controller/WebActions.scala
index cd3c68c..0bb6b77 100644
--- a/core/controller/src/main/scala/whisk/core/controller/WebActions.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/WebActions.scala
@@ -129,11 +129,11 @@ private case class Context(propertyMap: WebApiDirectives,
// if the body is a json object, merge with query parameters
// otherwise, this is an opaque body that will be nested under
// __ow_body in the parameters sent to the action as an argument
- val bodyParams = body match {
+ val bodyParams: Map[String, JsValue] = body match {
case Some(JsObject(fields)) if !boxQueryAndBody => fields
case Some(v) => Map(propertyMap.body -> v)
case None if !boxQueryAndBody => Map.empty
- case _ => Map(propertyMap.body -> JsObject())
+ case _ => Map(propertyMap.body -> JsString.empty)
}
// precedence order is: query params -> body (last wins)
diff --git a/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala b/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
index 2bcfe91..2f47595 100644
--- a/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
@@ -1536,7 +1536,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon with BeforeAndAfterEac
"action" -> "raw_export_c".toJson,
"content" -> metaPayload(
Post.method.name.toLowerCase,
- Map(webApiDirectives.body -> JsObject(), webApiDirectives.query -> queryString.toJson).toJson.asJsObject,
+ Map(webApiDirectives.body -> "".toJson, webApiDirectives.query -> queryString.toJson).toJson.asJsObject,
creds,
pkgName = "proxy"))
}
@@ -1589,6 +1589,24 @@ trait WebActionsApiBaseTests extends ControllerTestCommon with BeforeAndAfterEac
}
}
+ it should s"invoke raw action ensuring body and query arguments are empty strings when not specified in request (auth? ${creds.isDefined})" in {
+ implicit val tid = transid()
+
+ Post(s"$testRoutePath/$systemId/proxy/raw_export_c.json") ~> Route.seal(routes(creds)) ~> check {
+ status should be(OK)
+ invocationsAllowed += 1
+ val response = responseAs[JsObject]
+ response shouldBe JsObject(
+ "pkg" -> s"$systemId/proxy".toJson,
+ "action" -> "raw_export_c".toJson,
+ "content" -> metaPayload(
+ Post.method.name.toLowerCase,
+ Map(webApiDirectives.body -> "".toJson, webApiDirectives.query -> "".toJson).toJson.asJsObject,
+ creds,
+ pkgName = "proxy"))
+ }
+ }
+
it should s"reject invocation of web action with invalid accept header (auth? ${creds.isDefined})" in {
implicit val tid = transid()
--
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.