feat: support OPTIONS on RPC and root path
This commit is contained in:
committed by
Steve Chavez
parent
71a5748718
commit
2eb7c803e3
@@ -22,6 +22,9 @@ spec actualPgVersion = describe "Allow header" $ do
|
||||
simpleHeaders r `shouldSatisfy`
|
||||
matchHeader "Allow" "OPTIONS,GET,HEAD,POST,PUT,PATCH,DELETE"
|
||||
|
||||
it "fails with 404 for an unknown table" $
|
||||
request methodOptions "/unknown" [] "" `shouldRespondWith` 404
|
||||
|
||||
when (actualPgVersion >= pgVersion100) $
|
||||
context "a partitioned table" $ do
|
||||
it "includes read/write methods for writeable partitioned tables" $ do
|
||||
@@ -85,3 +88,29 @@ spec actualPgVersion = describe "Allow header" $ do
|
||||
liftIO $
|
||||
simpleHeaders r `shouldSatisfy`
|
||||
matchHeader "Allow" "OPTIONS,GET,HEAD,DELETE"
|
||||
|
||||
context "a function" $ do
|
||||
it "includes the POST method for a volatile function" $ do
|
||||
r <- request methodOptions "/rpc/reset_items_tables" [] ""
|
||||
liftIO $
|
||||
simpleHeaders r `shouldSatisfy`
|
||||
matchHeader "Allow" "OPTIONS,POST"
|
||||
|
||||
it "includes the GET/HEAD/POST method for a stable function" $ do
|
||||
r <- request methodOptions "/rpc/getallusers" [] ""
|
||||
liftIO $
|
||||
simpleHeaders r `shouldSatisfy`
|
||||
matchHeader "Allow" "OPTIONS,GET,HEAD,POST"
|
||||
|
||||
it "includes the GET/HEAD/POST method for a immutable function" $ do
|
||||
r <- request methodOptions "/rpc/jwt_test" [] ""
|
||||
liftIO $
|
||||
simpleHeaders r `shouldSatisfy`
|
||||
matchHeader "Allow" "OPTIONS,GET,HEAD,POST"
|
||||
|
||||
context "root endpoint" $ do
|
||||
it "includes the GET/HEAD method " $ do
|
||||
r <- request methodOptions "/" [] ""
|
||||
liftIO $
|
||||
simpleHeaders r `shouldSatisfy`
|
||||
matchHeader "Allow" "OPTIONS,GET,HEAD"
|
||||
|
||||
@@ -541,10 +541,6 @@ spec actualPgVersion =
|
||||
it "PATCH fails" $
|
||||
request methodPatch "/rpc/sayhello" [] ""
|
||||
`shouldRespondWith` 405
|
||||
it "OPTIONS fails" $
|
||||
-- TODO: should return info about the function
|
||||
request methodOptions "/rpc/sayhello" [] ""
|
||||
`shouldRespondWith` 405
|
||||
|
||||
it "executes the proc exactly once per request" $ do
|
||||
-- callcounter is persistent even with rollback, because it uses a sequence
|
||||
|
||||
Reference in New Issue
Block a user