Skip to content

Commit

Permalink
Fixes d2iq-archive#4978 | AppDefinition.Conteiner validation (d2iq-ar…
Browse files Browse the repository at this point in the history
  • Loading branch information
janisz authored and unterstein committed Jan 31, 2017
1 parent 3babb4f commit 3c7bd74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ trait ContainerFormats {
}
case _ =>
if (aggregate.kind == ContainerInfo.Type.DOCKER) {
throw SerializationFailedException("docker must not be empty")
throw JsResultException(Seq((JsPath() \ "container" \ "docker", Seq(ValidationError("error.path.missing")))))
}

aggregate.appcOption match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ class AppsResourceTest extends AkkaUnitTest with GroupCreation {
stripMargin.getBytes("UTF-8")

Then("A serialization exception is thrown")
intercept[SerializationFailedException] {
intercept[JsResultException] {
appsResource.replace(app.id.toString, body, force = false, auth.
request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,5 +529,17 @@ class AppDefinitionFormatsTest extends UnitTest

(json \ "killSelection").as[String] should be("OLDEST_FIRST")
}

"FromJSON should fail for empty container (#4978)" in {
val json = Json.parse(
"""{
| "id": "docker-compose-demo",
| "cmd": "echo hello world",
| "container": {}
|}""".stripMargin)
the[JsResultException] thrownBy {
json.as[AppDefinition]
} should have message ("JsResultException(errors:List((/container/docker,List(ValidationError(List(error.path.missing),WrappedArray())))))")
}
}
}

0 comments on commit 3c7bd74

Please sign in to comment.