Skip to content

Commit

Permalink
Add cache-control header in test
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed Dec 27, 2023
1 parent 9c6fd09 commit 7c3019e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/test_http_ext_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def log_message(self, *args):
pass


ResponseType = tuple[str, int]
ResponseType = tuple[str, int] | tuple[str, int, dict[str, str]]


class MockAuthProvider:
Expand Down Expand Up @@ -261,12 +261,21 @@ def handle_request(

if callable(registered_handler):
try:
response, status = registered_handler(handler)
handler_result = registered_handler(handler)
if len(handler_result) == 2:
response, status = handler_result
additional_headers = None
elif len(handler_result) == 3:
response, status, additional_headers = handler_result
except Exception:
handler.send_error(500)
raise
else:
response, status = registered_handler
if len(registered_handler) == 2:
response, status = registered_handler
additional_headers = None
elif len(registered_handler) == 3:
response, status, additional_headers = registered_handler

if "headers" in request_details and isinstance(
request_details["headers"], dict
Expand Down Expand Up @@ -300,6 +309,9 @@ def handle_request(
handler.send_response(status)
handler.send_header('Content-Type', content_type)
handler.send_header('Content-Length', str(len(data)))
if additional_headers is not None:
for header, value in additional_headers.items():
handler.send_header(header, value)
handler.end_headers()
handler.wfile.write(data)

Expand Down Expand Up @@ -991,6 +1003,7 @@ async def test_http_auth_ext_google_callback_01(self) -> None:
(
json.dumps(GOOGLE_DISCOVERY_DOCUMENT),
200,
{"cache-control": "max-age=3600"},
)
)

Expand Down

0 comments on commit 7c3019e

Please sign in to comment.