@@ -392,3 +392,37 @@ def test_tool_init_header_auth_conflict(
392
392
bound_params = {},
393
393
client_headers = conflicting_client_header ,
394
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