File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,22 @@ def test_client_config_from_env_rejects_newline_header_values(monkeypatch):
9191 ClientConfig .from_env ()
9292
9393
94+ def test_client_config_from_env_rejects_duplicate_header_names_after_normalization (
95+ monkeypatch ,
96+ ):
97+ monkeypatch .setenv ("HYPERBROWSER_API_KEY" , "test-key" )
98+ monkeypatch .setenv (
99+ "HYPERBROWSER_HEADERS" ,
100+ '{"X-Correlation-Id":"one"," X-Correlation-Id ":"two"}' ,
101+ )
102+
103+ with pytest .raises (
104+ HyperbrowserError ,
105+ match = "duplicate header names are not allowed after normalization" ,
106+ ):
107+ ClientConfig .from_env ()
108+
109+
94110def test_client_config_from_env_ignores_blank_headers (monkeypatch ):
95111 monkeypatch .setenv ("HYPERBROWSER_API_KEY" , "test-key" )
96112 monkeypatch .setenv ("HYPERBROWSER_HEADERS" , " " )
@@ -216,3 +232,10 @@ def test_client_config_accepts_mapping_header_inputs():
216232 config = ClientConfig (api_key = "test-key" , headers = headers )
217233
218234 assert config .headers == {"X-Correlation-Id" : "abc123" }
235+
236+
237+ def test_client_config_parse_headers_from_env_rejects_non_string_input ():
238+ with pytest .raises (
239+ HyperbrowserError , match = "HYPERBROWSER_HEADERS must be a string"
240+ ):
241+ ClientConfig .parse_headers_from_env (123 ) # type: ignore[arg-type]
You can’t perform that action at this time.
0 commit comments