Skip to content

Commit

Permalink
Update to Spray-json 1.3.5 security fix release (#4106)
Browse files Browse the repository at this point in the history
Adapt test to use json object comparison instead of string comparison
  • Loading branch information
chetanmeh authored and rabbah committed Nov 12, 2018
1 parent a800b5f commit 33bb0e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion common/scala/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 33bb0e7

Please sign in to comment.