Skip to content

Commit aa7bc8c

Browse files
authored
test(toolbox-core): improve coverage (#217)
* tests: improve coverage * lint
1 parent 64e8609 commit aa7bc8c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

packages/toolbox-core/tests/test_tool.py

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

0 commit comments

Comments
 (0)