Skip to content

Commit 2f16296

Browse files
authored
Merge branch 'main' into update-toolbox
2 parents 58b5794 + 0ff650a commit 2f16296

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

packages/toolbox-core/tests/test_tool.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ def auth_getters(auth_token_value) -> dict[str, Callable[[], str]]:
8787
return {"test-auth": lambda: auth_token_value}
8888

8989

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-
9590
@pytest.fixture
9691
def auth_header_key() -> str:
9792
return "test-auth_token"
@@ -397,3 +392,37 @@ def test_tool_init_header_auth_conflict(
397392
bound_params={},
398393
client_headers=conflicting_client_header,
399394
)
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

Comments
 (0)