@@ -74,30 +74,6 @@ def static_client_header() -> dict[str, str]:
74
74
return {"X-Client-Static" : "client-static-value" }
75
75
76
76
77
- @pytest .fixture
78
- def sync_callable_client_header_value () -> str :
79
- return "client-sync-callable-value"
80
-
81
-
82
- @pytest .fixture
83
- def sync_callable_client_header (sync_callable_client_header_value ) -> dict [str , Mock ]:
84
- return {"X-Client-Sync" : Mock (return_value = sync_callable_client_header_value )}
85
-
86
-
87
- @pytest .fixture
88
- def async_callable_client_header_value () -> str :
89
- return "client-async-callable-value"
90
-
91
-
92
- @pytest .fixture
93
- def async_callable_client_header (
94
- async_callable_client_header_value ,
95
- ) -> dict [str , AsyncMock ]:
96
- return {
97
- "X-Client-Async" : AsyncMock (return_value = async_callable_client_header_value )
98
- }
99
-
100
-
101
77
# --- Fixtures for Auth Getters ---
102
78
103
79
@@ -111,11 +87,6 @@ def auth_getters(auth_token_value) -> dict[str, Callable[[], str]]:
111
87
return {"test-auth" : lambda : auth_token_value }
112
88
113
89
114
- @pytest .fixture
115
- def auth_getters_mock (auth_token_value ) -> dict [str , Mock ]:
116
- return {"test-auth" : Mock (return_value = auth_token_value )}
117
-
118
-
119
90
@pytest .fixture
120
91
def auth_header_key () -> str :
121
92
return "test-auth_token"
@@ -421,3 +392,37 @@ def test_tool_init_header_auth_conflict(
421
392
bound_params = {},
422
393
client_headers = conflicting_client_header ,
423
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