core - fix cors tests with the preflight request

This commit is contained in:
Théophile Diot 2023-05-18 18:01:18 -04:00
parent dbb8840992
commit 1d126e1d0e
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
2 changed files with 5 additions and 3 deletions

View File

@ -17,6 +17,7 @@ services:
LOG_LEVEL: "info"
GENERATE_SELF_SIGNED_SSL: "no"
ALLOWED_METHODS: "GET|POST|HEAD|OPTIONS"
CUSTOM_CONF_SEVER_HTTP_main: "location /options { default_type 'text/plain'; content_by_lua_block { if ngx.var.request_method == \"OPTIONS\" then ngx.say(\"Hello, world!\") end } }"
# ? CORS settings
USE_CORS: "no"

View File

@ -113,19 +113,20 @@ try:
sleep(1)
print(
f" Sending a preflight request to http{'s' if ssl else ''}://www.example.com ...",
f" Sending a preflight request to http{'s' if ssl else ''}://www.example.com/options ...",
flush=True,
)
response = options(
f"http{'s' if ssl else ''}://www.example.com",
f"http{'s' if ssl else ''}://www.example.com/options",
headers={
"Host": "www.example.com",
"Origin": f"http{'s' if ssl else ''}://bwadm.example.com",
},
verify=False,
)
response.raise_for_status()
if response.status_code != 404:
response.raise_for_status()
if use_cors:
if (