Allow http status override through response.status guc (#1541)

Fixes https://github.com/PostgREST/postgrest/issues/1525
This commit is contained in:
Steve Chavez
2020-06-05 13:01:36 -05:00
committed by GitHub
parent 69b09e312a
commit 0f0d617951
8 changed files with 137 additions and 50 deletions
+21
View File
@@ -161,6 +161,27 @@ spec =
let respHeaders = simpleHeaders r
respHeaders `shouldSatisfy` noBlankHeader
context "GUC status override" $ do
it "can override the status on RPC" $
get "/rpc/send_body_status_403"
`shouldRespondWith`
[json|{"message" : "invalid user or password"}|]
{ matchStatus = 403
, matchHeaders = [ matchContentTypeJson ]
}
it "can override the status through trigger" $
request methodPatch "/stuff?id=eq.1" [] [json|[{"name": "updated stuff 1"}]|]
`shouldRespondWith` 205
it "fails when setting invalid status guc" $
get "/rpc/send_bad_status"
`shouldRespondWith`
[json|{"message":"response.status guc must be a valid status code"}|]
{ matchStatus = 500
, matchHeaders = [ matchContentTypeJson ]
}
context "Use of the phraseto_tsquery function" $ do
it "finds matches" $
get "/tsearch?text_search_vector=phfts.The%20Fat%20Cats" `shouldRespondWith`