Ensure payload parse errors are not suppressed

Fixes #490
This commit is contained in:
Joe Nelson
2016-02-11 16:24:02 -08:00
parent ce6e52e9ba
commit 8b3d224b80
3 changed files with 29 additions and 15 deletions
+10
View File
@@ -386,6 +386,16 @@ spec struct c = around (withApp cfgDefault struct c) $ do
post "/rpc/sayhello" [json| { "name": "world" } |] `shouldRespondWith`
[json| [{"sayhello":"Hello, world"}] |]
context "improper input" $ do
it "rejects unknown content type even if payload is good" $
request methodPost "/rpc/sayhello"
(acceptHdrs "audio/mpeg3") [json| { "name": "world" } |]
`shouldRespondWith` 415
it "rejects malformed json payload" $
request methodPost "/rpc/sayhello"
(acceptHdrs "application/json") "sdfsdf"
`shouldRespondWith` 400
context "unsupported verbs" $ do
it "DELETE fails" $
request methodDelete "/rpc/sayhello" [] ""