feat: support OPTIONS on RPC and root path

This commit is contained in:
steve-chavez
2022-07-17 18:40:14 -05:00
committed by Steve Chavez
parent 71a5748718
commit 2eb7c803e3
6 changed files with 63 additions and 27 deletions
+15 -3
View File
@@ -140,7 +140,14 @@ def dumpconfig(configpath=None, env=None, stdin=None):
@contextlib.contextmanager
def run(configpath=None, stdin=None, env=None, port=None, host=None, no_pool_connection_available=False):
def run(
configpath=None,
stdin=None,
env=None,
port=None,
host=None,
no_pool_connection_available=False,
):
"Run PostgREST and yield an endpoint that is ready for connections."
env = env or {}
env["PGRST_DB_POOL"] = "1"
@@ -244,6 +251,7 @@ def sleep_pool_connection(url, seconds):
except requests.exceptions.ReadTimeout:
pass
def authheader(token):
"Bearer token HTTP authorization header."
return {"Authorization": f"Bearer {token}"}
@@ -982,9 +990,13 @@ def test_no_pool_connection_required_on_options(defaultenv):
response = postgrest.session.options("/projects")
assert response.status_code == 200
# OPTIONS on RPC is not implemented yet, still it shouldn't require opening a connection
# OPTIONS on RPC shouldn't require opening a connection
response = postgrest.session.options("/rpc/hello")
assert response.status_code == 405
assert response.status_code == 200
# OPTIONS on root shouldn't require opening a connection
response = postgrest.session.options("/")
assert response.status_code == 200
def test_no_pool_connection_required_on_bad_jwt_claim(defaultenv):