@@ -87,11 +87,6 @@ def auth_getters(auth_token_value) -> dict[str, Callable[[], str]]:
87
87
return {"test-auth" : lambda : auth_token_value }
88
88
89
89
90
- @pytest .fixture
91
- def auth_getters_mock (auth_token_value ) -> dict [str , Mock ]:
92
- return {"test-auth" : Mock (return_value = auth_token_value )}
93
-
94
-
95
90
@pytest .fixture
96
91
def auth_header_key () -> str :
97
92
return "test-auth_token"
@@ -397,3 +392,37 @@ def test_tool_init_header_auth_conflict(
397
392
bound_params = {},
398
393
client_headers = conflicting_client_header ,
399
394
)
395
+
396
+
397
+ def test_tool_add_auth_token_getters_conflict_with_existing_client_header (
398
+ http_session : ClientSession ,
399
+ sample_tool_params : list [ParameterSchema ],
400
+ sample_tool_description : str ,
401
+ ):
402
+ """
403
+ Tests ValueError when add_auth_token_getters introduces an auth service
404
+ whose token name conflicts with an existing client header.
405
+ """
406
+ tool_instance = ToolboxTool (
407
+ session = http_session ,
408
+ base_url = TEST_BASE_URL ,
409
+ name = "tool_with_client_header" ,
410
+ description = sample_tool_description ,
411
+ params = sample_tool_params ,
412
+ required_authn_params = {},
413
+ auth_service_token_getters = {},
414
+ bound_params = {},
415
+ client_headers = {
416
+ "X-Shared-Auth-Token_token" : "value_from_initial_client_headers"
417
+ },
418
+ )
419
+ new_auth_getters_causing_conflict = {
420
+ "X-Shared-Auth-Token" : lambda : "token_value_from_new_getter"
421
+ }
422
+ expected_error_message = (
423
+ f"Client header\\ (s\\ ) `X-Shared-Auth-Token_token` already registered in client. "
424
+ f"Cannot register client the same headers in the client as well as tool."
425
+ )
426
+
427
+ with pytest .raises (ValueError , match = expected_error_message ):
428
+ tool_instance .add_auth_token_getters (new_auth_getters_causing_conflict )
0 commit comments