cov: Improve jwt claims test-cases
This commit is contained in:
committed by
Steve Chavez
parent
130dcc4f66
commit
9f09a6547d
@@ -89,6 +89,13 @@ runPgLocals conf claims app req jsonDbS actualPgVersion = do
|
|||||||
_ -> mempty
|
_ -> mempty
|
||||||
usesLegacyGucs = configDbUseLegacyGucs conf && actualPgVersion < pgVersion140
|
usesLegacyGucs = configDbUseLegacyGucs conf && actualPgVersion < pgVersion140
|
||||||
|
|
||||||
|
unquoted :: JSON.Value -> Text
|
||||||
|
unquoted (JSON.String t) = t
|
||||||
|
unquoted (JSON.Number n) =
|
||||||
|
toS $ formatScientific Fixed (if isInteger n then Just 0 else Nothing) n
|
||||||
|
unquoted (JSON.Bool b) = show b
|
||||||
|
unquoted v = T.decodeUtf8 . LBS.toStrict $ JSON.encode v
|
||||||
|
|
||||||
-- | Log in apache format. Only requests that have a status greater than minStatus are logged.
|
-- | Log in apache format. Only requests that have a status greater than minStatus are logged.
|
||||||
-- | There's no way to filter logs in the apache format on wai-extra: https://hackage.haskell.org/package/wai-extra-3.0.29.2/docs/Network-Wai-Middleware-RequestLogger.html#t:OutputFormat.
|
-- | There's no way to filter logs in the apache format on wai-extra: https://hackage.haskell.org/package/wai-extra-3.0.29.2/docs/Network-Wai-Middleware-RequestLogger.html#t:OutputFormat.
|
||||||
-- | So here we copy wai-logger apacheLogStr function: https://github.com/kazu-yamamoto/logger/blob/a4f51b909a099c51af7a3f75cf16e19a06f9e257/wai-logger/Network/Wai/Logger/Apache.hs#L45
|
-- | So here we copy wai-logger apacheLogStr function: https://github.com/kazu-yamamoto/logger/blob/a4f51b909a099c51af7a3f75cf16e19a06f9e257/wai-logger/Network/Wai/Logger/Apache.hs#L45
|
||||||
@@ -153,13 +160,6 @@ corsPolicy req = case lookup "origin" headers of
|
|||||||
Just hdrs -> map (CI.mk . BS.strip) $ BS.split ',' hdrs
|
Just hdrs -> map (CI.mk . BS.strip) $ BS.split ',' hdrs
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
|
|
||||||
unquoted :: JSON.Value -> Text
|
|
||||||
unquoted (JSON.String t) = t
|
|
||||||
unquoted (JSON.Number n) =
|
|
||||||
toS $ formatScientific Fixed (if isInteger n then Just 0 else Nothing) n
|
|
||||||
unquoted (JSON.Bool b) = show b
|
|
||||||
unquoted v = T.decodeUtf8 . LBS.toStrict $ JSON.encode v
|
|
||||||
|
|
||||||
-- | Set a transaction to eventually roll back if requested and set respective
|
-- | Set a transaction to eventually roll back if requested and set respective
|
||||||
-- headers on the response.
|
-- headers on the response.
|
||||||
optionalRollback
|
optionalRollback
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ roleclaims:
|
|||||||
data:
|
data:
|
||||||
postgrest:
|
postgrest:
|
||||||
a_role: postgrest_test_author
|
a_role: postgrest_test_author
|
||||||
|
other: claims
|
||||||
expected_status: 200
|
expected_status: 200
|
||||||
- key: '.customObject.manyRoles[1]'
|
- key: '.customObject.manyRoles[1]'
|
||||||
data:
|
data:
|
||||||
@@ -151,21 +152,25 @@ roleclaims:
|
|||||||
manyRoles:
|
manyRoles:
|
||||||
- other
|
- other
|
||||||
- postgrest_test_author
|
- postgrest_test_author
|
||||||
|
other: {}
|
||||||
expected_status: 200
|
expected_status: 200
|
||||||
- key: '."https://www.example.com/roles"[0].value'
|
- key: '."https://www.example.com/roles"[0].value'
|
||||||
data:
|
data:
|
||||||
'https://www.example.com/roles':
|
'https://www.example.com/roles':
|
||||||
- value: postgrest_test_author
|
- value: postgrest_test_author
|
||||||
|
other: 666
|
||||||
expected_status: 200
|
expected_status: 200
|
||||||
- key: '.myDomain[3]'
|
- key: '.myDomain[3]'
|
||||||
data:
|
data:
|
||||||
myDomain:
|
myDomain:
|
||||||
- other
|
- other
|
||||||
- postgrest_test_author
|
- postgrest_test_author
|
||||||
|
other: 1.23
|
||||||
expected_status: 401
|
expected_status: 401
|
||||||
- key: '.myRole'
|
- key: '.myRole'
|
||||||
data:
|
data:
|
||||||
role: postgrest_test_author
|
role: postgrest_test_author
|
||||||
|
other: true
|
||||||
expected_status: 401
|
expected_status: 401
|
||||||
|
|
||||||
invalidroleclaimkeys:
|
invalidroleclaimkeys:
|
||||||
|
|||||||
Reference in New Issue
Block a user