This is an automated email from the ASF dual-hosted git repository. rabbah 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 33bb0e7 Update to Spray-json 1.3.5 security fix release (#4106) 33bb0e7 is described below commit 33bb0e7c876548bdd68eee194f1f9bfd58ed0ef1 Author: Chetan Mehrotra <chet...@apache.org> AuthorDate: Mon Nov 12 16:25:03 2018 +0530 Update to Spray-json 1.3.5 security fix release (#4106) Adapt test to use json object comparison instead of string comparison --- common/scala/build.gradle | 2 +- .../openwhisk/core/entity/test/SchemaTests.scala | 34 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/scala/build.gradle b/common/scala/build.gradle index 2d550ed..2ae4a29 100644 --- a/common/scala/build.gradle +++ b/common/scala/build.gradle @@ -33,7 +33,7 @@ dependencies { compile "org.scala-lang:scala-library:${gradle.scala.version}" compile 'com.github.pureconfig:pureconfig_2.12:0.9.0' - compile 'io.spray:spray-json_2.12:1.3.4' + compile 'io.spray:spray-json_2.12:1.3.5' compile 'com.lihaoyi:fastparse_2.12:1.0.0' compile 'com.typesafe.akka:akka-actor_2.12:2.5.12' diff --git a/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala index 05e7a6a..dfafb07 100644 --- a/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala +++ b/tests/src/test/scala/org/apache/openwhisk/core/entity/test/SchemaTests.scala @@ -46,6 +46,10 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with ExecHelpers with Mat behavior of "Privilege" + private implicit class ExecJson(e: Exec) { + def asJson: JsObject = Exec.serdes.write(e).asJsObject + } + it should "serdes a right" in { Privilege.serdes.read("READ".toJson) shouldBe Privilege.READ Privilege.serdes.read("read".toJson) shouldBe Privilege.READ @@ -490,11 +494,11 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with ExecHelpers with Mat Exec.serdes.read(e) } - assert(execs(0) == jsDefault("js1") && json(0).compactPrint == jsDefault("js1").toString) - assert(execs(1) == jsDefault("js2") && json(1).compactPrint != jsDefault("js2").toString) // ignores unknown properties - assert(execs(2) == swift("swift1") && json(2).compactPrint == swift("swift1").toString) - assert(execs(3) == swift3(b64Body) && json(3).compactPrint == swift3(b64Body).toString) - assert(execs(4) == jsDefault(b64Body) && json(4).compactPrint == jsDefault(b64Body).toString) + assert(execs(0) == jsDefault("js1") && json(0) == jsDefault("js1").asJson) + assert(execs(1) == jsDefault("js2") && json(1) != jsDefault("js2").asJson) // ignores unknown properties + assert(execs(2) == swift("swift1") && json(2) == swift("swift1").asJson) + assert(execs(3) == swift3(b64Body) && json(3) == swift3(b64Body).asJson) + assert(execs(4) == jsDefault(b64Body) && json(4) == jsDefault(b64Body).asJson) } it should "properly deserialize and reserialize JSON blackbox" in { @@ -522,9 +526,9 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with ExecHelpers with Mat execs(1) shouldBe bb("container1", contents) execs(2) shouldBe bb("container1", contents, Some("naim")) - json(0).compactPrint shouldBe bb("container1").toString - json(1).compactPrint shouldBe bb("container1", contents).toString - json(2).compactPrint shouldBe bb("container1", contents, Some("naim")).toString + json(0) shouldBe bb("container1").asJson + json(1) shouldBe bb("container1", contents).asJson + json(2) shouldBe bb("container1", contents, Some("naim")).asJson execs(0) shouldBe Exec.serdes.read( JsObject( @@ -608,15 +612,11 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with ExecHelpers with Mat } it should "serialize to json" in { - val execs = Seq(bb("container"), jsDefault("js"), jsDefault("js"), swift("swift")).map { _.toString } - assert( - execs(0) == JsObject("kind" -> "blackbox".toJson, "image" -> "container".toJson, "binary" -> false.toJson).compactPrint) - assert( - execs(1) == JsObject("kind" -> "nodejs:6".toJson, "code" -> "js".toJson, "binary" -> false.toJson).compactPrint) - assert( - execs(2) == JsObject("kind" -> "nodejs:6".toJson, "code" -> "js".toJson, "binary" -> false.toJson).compactPrint) - assert( - execs(3) == JsObject("kind" -> "swift".toJson, "code" -> "swift".toJson, "binary" -> false.toJson).compactPrint) + val execs = Seq(bb("container"), jsDefault("js"), jsDefault("js"), swift("swift")).map { _.asJson } + assert(execs(0) == JsObject("kind" -> "blackbox".toJson, "image" -> "container".toJson, "binary" -> false.toJson)) + assert(execs(1) == JsObject("kind" -> "nodejs:6".toJson, "code" -> "js".toJson, "binary" -> false.toJson)) + assert(execs(2) == JsObject("kind" -> "nodejs:6".toJson, "code" -> "js".toJson, "binary" -> false.toJson)) + assert(execs(3) == JsObject("kind" -> "swift".toJson, "code" -> "swift".toJson, "binary" -> false.toJson)) } behavior of "Parameter"