Add 'PGRST' error code to differentiate from PostgreSQL errors
This commit is contained in:
@@ -106,7 +106,7 @@ spec actualPgVersion = describe "authorization" $ do
|
||||
it "fails with an expired token" $ do
|
||||
let auth = authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NDY2NzgxNDksInJvbGUiOiJwb3N0Z3Jlc3RfdGVzdF9hdXRob3IiLCJpZCI6Impkb2UifQ.f8__E6VQwYcDqwHmr9PG03uaZn8Zh1b0vbJ9DYS0AdM"
|
||||
request methodGet "/authors_only" [auth] ""
|
||||
`shouldRespondWith` [json| {"message":"JWT expired"} |]
|
||||
`shouldRespondWith` [json| {"message":"JWT expired","code":"PGRST301","hint":null,"details":null} |]
|
||||
{ matchStatus = 401
|
||||
, matchHeaders = [
|
||||
"WWW-Authenticate" <:>
|
||||
@@ -117,7 +117,7 @@ spec actualPgVersion = describe "authorization" $ do
|
||||
it "hides tables from users with invalid JWT" $ do
|
||||
let auth = authHeaderJWT "ey9zdGdyZXN0X3Rlc3RfYXV0aG9yIiwiaWQiOiJqZG9lIn0.y4vZuu1dDdwAl0-S00MCRWRYMlJ5YAMSir6Es6WtWx0"
|
||||
request methodGet "/authors_only" [auth] ""
|
||||
`shouldRespondWith` [json| {"message":"JWSError (CompactDecodeError Invalid number of parts: Expected 3 parts; got 2)"} |]
|
||||
`shouldRespondWith` [json| {"message":"JWSError (CompactDecodeError Invalid number of parts: Expected 3 parts; got 2)","code":"PGRST301","hint":null,"details":null} |]
|
||||
{ matchStatus = 401
|
||||
, matchHeaders = [
|
||||
"WWW-Authenticate" <:>
|
||||
|
||||
@@ -24,7 +24,11 @@ spec = describe "server started without anonymous role" $ do
|
||||
it "responds with error when user does not attempt auth" $
|
||||
get "/items"
|
||||
`shouldRespondWith`
|
||||
[json|{"message":"Anonymous access is disabled"}|]
|
||||
[json|
|
||||
{"hint": null,
|
||||
"details": null,
|
||||
"code": "PGRST302",
|
||||
"message":"Anonymous access is disabled"}|]
|
||||
{ matchStatus = 401
|
||||
, matchHeaders = ["WWW-Authenticate" <:> "Bearer"]
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@ spec = describe "server started without JWT secret" $ do
|
||||
[auth]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|{"message":"Server lacks JWT secret"}|]
|
||||
[json|
|
||||
{"hint": null,
|
||||
"details": null,
|
||||
"code": "PGRST300",
|
||||
"message": "Server lacks JWT secret"}|]
|
||||
{ matchStatus = 500 }
|
||||
|
||||
it "behaves normally when user does not attempt auth" $
|
||||
|
||||
Reference in New Issue
Block a user