Skip to content

Commit

Permalink
Reflect WPS and DCS caching headers in mock responses
Browse files Browse the repository at this point in the history
  • Loading branch information
TheByronHimes committed Jan 7, 2025
1 parent a9dc247 commit e373e9e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/fixtures/mock_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self, *, envelope: str, status_code: int = 200):

def create_caching_headers(expires_after: int = 60) -> dict[str, str]:
"""Return headers used in responses for caching by `hishel`"""
cache_control_header = ("Cache-Control", f"max-age={expires_after}")
cache_control_header = ("Cache-Control", f"max-age={expires_after}, private")
date_header = ("date", format_datetime(now_as_utc()))
return {k: v for k, v in [cache_control_header, date_header]}

Expand Down Expand Up @@ -200,7 +200,8 @@ async def drs3_objects(file_id: str, request: Request, expires_after: UrlLifespa

if file_id == "retry":
return Response(
status_code=status.HTTP_202_ACCEPTED, headers={"Retry-After": "10"}
status_code=status.HTTP_202_ACCEPTED,
headers={"Retry-After": "10", "Cache-Control": "no-store"},
)

if file_id in ("downloadable", "big-downloadable", "envelope-missing"):
Expand Down Expand Up @@ -236,7 +237,9 @@ async def drs3_objects_envelopes(file_id: str):
if file_id in ("downloadable", "big-downloadable"):
response_str = str.encode(os.environ["FAKE_ENVELOPE"])
envelope = base64.b64encode(response_str).decode("utf-8")
return HttpEnvelopeResponse(envelope=envelope)
response = HttpEnvelopeResponse(envelope=envelope)
response.headers["Cache-Control"] = "no-store"
return response

raise HttpException(
status_code=404,
Expand Down

0 comments on commit e373e9e

Please sign in to comment.