@@ -397,3 +397,34 @@ def test_tool_init_header_auth_conflict(
397
397
bound_params = {},
398
398
client_headers = conflicting_client_header ,
399
399
)
400
+
401
+ def test_tool_add_auth_token_getters_conflict_with_existing_client_header (
402
+ http_session : ClientSession ,
403
+ sample_tool_params : list [ParameterSchema ],
404
+ sample_tool_description : str ,
405
+ ):
406
+ """
407
+ Tests ValueError when add_auth_token_getters introduces an auth service
408
+ whose token name conflicts with an existing client header.
409
+ """
410
+ tool_instance = ToolboxTool (
411
+ session = http_session ,
412
+ base_url = TEST_BASE_URL ,
413
+ name = "tool_with_client_header" ,
414
+ description = sample_tool_description ,
415
+ params = sample_tool_params ,
416
+ required_authn_params = {},
417
+ auth_service_token_getters = {},
418
+ bound_params = {},
419
+ client_headers = { "X-Shared-Auth-Token_token" : "value_from_initial_client_headers" },
420
+ )
421
+ new_auth_getters_causing_conflict = {
422
+ "X-Shared-Auth-Token" : lambda : "token_value_from_new_getter"
423
+ }
424
+ expected_error_message = (
425
+ f"Client header\\ (s\\ ) `X-Shared-Auth-Token_token` already registered in client. "
426
+ f"Cannot register client the same headers in the client as well as tool."
427
+ )
428
+
429
+ with pytest .raises (ValueError , match = expected_error_message ):
430
+ tool_instance .add_auth_token_getters (new_auth_getters_causing_conflict )
0 commit comments