55
66from requests import Response
77from tests .sandbox .SandboxTest import SandboxTest
8- from tests .data import Actor
8+ from tests .data import Actor , RenamedHeader
99from tests .sandbox .utils import HttpMethod
10+ from pytest_check import check
1011
1112
1213@pytest .mark .sandbox
@@ -65,9 +66,15 @@ def test_success(
6566 ],
6667 actor : Actor ,
6768 id : str ,
69+ sandbox_url : str ,
70+ environment : str ,
6871 ):
72+ request_headers = (
73+ {"x-ers-sandbox-baseurl" : sandbox_url } if environment == "local" else {}
74+ )
75+
6976 actual_response = call_endpoint_url_with_pathParams (
70- actor , {"binaryId" : id }, allow_redirects = True
77+ actor , {"binaryId" : id }, request_headers , allow_redirects = True
7178 )
7279
7380 asserts .assert_status_code (200 , actual_response .status_code )
@@ -76,7 +83,6 @@ def test_success(
7683 "content-disposition" : """attachment; filename="=?UTF-8?Q?The_filenam=C3=A9.pdf?="; filename*=UTF-8''The%20filenam%C3%A9.pdf""" ,
7784 "content-type" : "application/pdf" ,
7885 "content-length" : "23681" ,
79- "x-request-id" : "58621d65-d5ad-4c3a-959f-0438e355990e-1" ,
8086 "vary" : "origin" ,
8187 "access-control-expose-headers" : "x-correlation-id,x-request-id,content-type,Location,ETag,Content-Disposition,Content-Length,Cache-Control" ,
8288 "cache-control" : "no-cache" ,
@@ -90,3 +96,34 @@ def test_success(
9096 assert_content_length = True ,
9197 assert_ignored_headers = False ,
9298 )
99+
100+ def test_with_correlation_id (
101+ self ,
102+ call_endpoint : Callable [[Actor ], Response ],
103+ authorised_actors : Iterable [Actor ],
104+ default_headers : Dict [str , str ],
105+ sandbox_url : str ,
106+ environment : str ,
107+ ):
108+ """
109+ Overrides parent test. It's expected that following the redirection will result in a response from the object store without a correlation id.
110+ """
111+ request_headers = {RenamedHeader .CORRELATION_ID .original : "test" }
112+
113+ if environment == "local" :
114+ request_headers ["x-ers-sandbox-baseurl" ] = sandbox_url
115+
116+ response = call_endpoint (
117+ authorised_actors [0 ],
118+ headers = request_headers ,
119+ )
120+
121+ # Check that the response completed successfully.
122+ assert (
123+ response .status_code // 200 == 1
124+ ), "Supplied request did not complete successfully."
125+
126+ with check :
127+ assert (
128+ RenamedHeader .CORRELATION_ID .original not in response .headers
129+ ), "Object store expected not to return a correlation id."
0 commit comments