Skip to content

Commit 6740434

Browse files
committed
chore: Rename identify_required_authn_params to better reflect its updated functionality
1 parent 752d16d commit 6740434

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

packages/toolbox-core/src/toolbox_core/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from .protocol import ManifestSchema, ToolSchema
2020
from .tool import ToolboxTool
21-
from .utils import identify_required_authn_params, resolve_value
21+
from .utils import identify_auth_requirements, resolve_value
2222

2323

2424
class ToolboxClient:
@@ -79,7 +79,7 @@ def __parse_tool(
7979
else: # regular parameter
8080
params.append(p)
8181

82-
authn_params, authz_tokens, used_auth_keys = identify_required_authn_params(
82+
authn_params, authz_tokens, used_auth_keys = identify_auth_requirements(
8383
authn_params,
8484
schema.authRequired,
8585
auth_token_getters.keys(),

packages/toolbox-core/src/toolbox_core/tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .protocol import ParameterSchema
2323
from .utils import (
2424
create_func_docstring,
25-
identify_required_authn_params,
25+
identify_auth_requirements,
2626
params_to_pydantic_model,
2727
resolve_value,
2828
)
@@ -309,9 +309,9 @@ def add_auth_token_getters(
309309

310310
new_getters = dict(self.__auth_service_token_getters, **auth_token_getters)
311311

312-
# find the updated required authn params and the auth token getters used
312+
# find the updated requirements
313313
new_req_authn_params, new_req_authz_tokens, used_auth_token_getters = (
314-
identify_required_authn_params(
314+
identify_auth_requirements(
315315
self.__required_authn_params,
316316
self.__required_authz_tokens,
317317
auth_token_getters.keys(),

packages/toolbox-core/src/toolbox_core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def create_func_docstring(description: str, params: Sequence[ParameterSchema]) -
4444
return docstring
4545

4646

47-
def identify_required_authn_params(
47+
def identify_auth_requirements(
4848
req_authn_params: Mapping[str, list[str]],
4949
req_authz_tokens: Sequence[str],
5050
auth_service_names: Iterable[str],

packages/toolbox-core/tests/test_utils.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from toolbox_core.protocol import ParameterSchema
2424
from toolbox_core.utils import (
2525
create_func_docstring,
26-
identify_required_authn_params,
26+
identify_auth_requirements,
2727
params_to_pydantic_model,
2828
resolve_value,
2929
)
@@ -82,15 +82,15 @@ def test_create_func_docstring_empty_description():
8282
assert create_func_docstring(description, params) == expected_docstring
8383

8484

85-
def test_identify_required_authn_params_none_required():
85+
def test_identify_auth_requirements_none_required():
8686
"""Test when no authentication parameters or authorization tokens are required initially."""
8787
req_authn_params: dict[str, list[str]] = {}
8888
req_authz_tokens: list[str] = []
8989
auth_service_names = ["service_a", "service_b"]
9090
expected_params = {}
9191
expected_authz: list[str] = []
9292
expected_used = set()
93-
result = identify_required_authn_params(
93+
result = identify_auth_requirements(
9494
req_authn_params, req_authz_tokens, auth_service_names
9595
)
9696
assert result == (
@@ -100,7 +100,7 @@ def test_identify_required_authn_params_none_required():
100100
)
101101

102102

103-
def test_identify_required_authn_params_all_covered():
103+
def test_identify_auth_requirements_all_covered():
104104
"""Test when all required authn parameters are covered, no authz tokens."""
105105
req_authn_params = {
106106
"token_a": ["service_a"],
@@ -111,7 +111,7 @@ def test_identify_required_authn_params_all_covered():
111111
expected_params = {}
112112
expected_authz: list[str] = []
113113
expected_used = {"service_a", "service_b"}
114-
result = identify_required_authn_params(
114+
result = identify_auth_requirements(
115115
req_authn_params, req_authz_tokens, auth_service_names
116116
)
117117
assert result == (
@@ -121,7 +121,7 @@ def test_identify_required_authn_params_all_covered():
121121
)
122122

123123

124-
def test_identify_required_authn_params_some_covered():
124+
def test_identify_auth_requirements_some_covered():
125125
"""Test when some authn parameters are covered, and some are not, no authz tokens."""
126126
req_authn_params = {
127127
"token_a": ["service_a"],
@@ -138,7 +138,7 @@ def test_identify_required_authn_params_some_covered():
138138
expected_authz: list[str] = []
139139
expected_used = {"service_a", "service_b"}
140140

141-
result = identify_required_authn_params(
141+
result = identify_auth_requirements(
142142
req_authn_params, req_authz_tokens, auth_service_names
143143
)
144144
assert result == (
@@ -148,7 +148,7 @@ def test_identify_required_authn_params_some_covered():
148148
)
149149

150150

151-
def test_identify_required_authn_params_none_covered():
151+
def test_identify_auth_requirements_none_covered():
152152
"""Test when none of the required authn parameters are covered, no authz tokens."""
153153
req_authn_params = {
154154
"token_d": ["service_d"],
@@ -162,7 +162,7 @@ def test_identify_required_authn_params_none_covered():
162162
}
163163
expected_authz: list[str] = []
164164
expected_used = set()
165-
result = identify_required_authn_params(
165+
result = identify_auth_requirements(
166166
req_authn_params, req_authz_tokens, auth_service_names
167167
)
168168
assert result == (
@@ -172,7 +172,7 @@ def test_identify_required_authn_params_none_covered():
172172
)
173173

174174

175-
def test_identify_required_authn_params_no_available_services():
175+
def test_identify_auth_requirements_no_available_services():
176176
"""Test when no authn services are available, no authz tokens."""
177177
req_authn_params = {
178178
"token_a": ["service_a"],
@@ -186,7 +186,7 @@ def test_identify_required_authn_params_no_available_services():
186186
}
187187
expected_authz: list[str] = []
188188
expected_used = set()
189-
result = identify_required_authn_params(
189+
result = identify_auth_requirements(
190190
req_authn_params, req_authz_tokens, auth_service_names
191191
)
192192
assert result == (
@@ -196,7 +196,7 @@ def test_identify_required_authn_params_no_available_services():
196196
)
197197

198198

199-
def test_identify_required_authn_params_empty_services_for_param():
199+
def test_identify_auth_requirements_empty_services_for_param():
200200
"""Test edge case: authn param requires an empty list of services, no authz tokens."""
201201
req_authn_params = {
202202
"token_x": [],
@@ -208,7 +208,7 @@ def test_identify_required_authn_params_empty_services_for_param():
208208
}
209209
expected_authz: list[str] = []
210210
expected_used = set()
211-
result = identify_required_authn_params(
211+
result = identify_auth_requirements(
212212
req_authn_params, req_authz_tokens, auth_service_names
213213
)
214214
assert result == (
@@ -223,7 +223,7 @@ def test_identify_auth_params_only_authz_empty():
223223
req_authn_params: dict[str, list[str]] = {}
224224
req_authz_tokens: list[str] = []
225225
auth_service_names = ["s1"]
226-
result = identify_required_authn_params(
226+
result = identify_auth_requirements(
227227
req_authn_params, req_authz_tokens, auth_service_names
228228
)
229229
assert result == ({}, [], set())
@@ -234,7 +234,7 @@ def test_identify_auth_params_authz_all_covered():
234234
req_authn_params: dict[str, list[str]] = {}
235235
req_authz_tokens = ["s1", "s2"]
236236
auth_service_names = ["s1", "s2", "s3"]
237-
result = identify_required_authn_params(
237+
result = identify_auth_requirements(
238238
req_authn_params, req_authz_tokens, auth_service_names
239239
)
240240
assert result == ({}, [], {"s1", "s2"})
@@ -245,7 +245,7 @@ def test_identify_auth_params_authz_partially_covered_by_available():
245245
req_authn_params: dict[str, list[str]] = {}
246246
req_authz_tokens = ["s1", "s2"]
247247
auth_service_names = ["s1", "s3"]
248-
result = identify_required_authn_params(
248+
result = identify_auth_requirements(
249249
req_authn_params, req_authz_tokens, auth_service_names
250250
)
251251
assert result == ({}, [], {"s1"})
@@ -256,7 +256,7 @@ def test_identify_auth_params_authz_none_covered():
256256
req_authn_params: dict[str, list[str]] = {}
257257
req_authz_tokens = ["s1", "s2"]
258258
auth_service_names = ["s3", "s4"]
259-
result = identify_required_authn_params(
259+
result = identify_auth_requirements(
260260
req_authn_params, req_authz_tokens, auth_service_names
261261
)
262262
assert result == ({}, ["s1", "s2"], set())
@@ -267,7 +267,7 @@ def test_identify_auth_params_authz_none_covered_empty_available():
267267
req_authn_params: dict[str, list[str]] = {}
268268
req_authz_tokens = ["s1", "s2"]
269269
auth_service_names: list[str] = []
270-
result = identify_required_authn_params(
270+
result = identify_auth_requirements(
271271
req_authn_params, req_authz_tokens, auth_service_names
272272
)
273273
assert result == ({}, ["s1", "s2"], set())
@@ -281,7 +281,7 @@ def test_identify_auth_params_authn_covered_authz_uncovered():
281281
expected_params = {}
282282
expected_authz: list[str] = ["s_authz_needed1", "s_authz_needed2"]
283283
expected_used = {"s_authn1"}
284-
result = identify_required_authn_params(
284+
result = identify_auth_requirements(
285285
req_authn_params, req_authz_tokens, auth_service_names
286286
)
287287
assert result == (expected_params, expected_authz, expected_used)
@@ -296,7 +296,7 @@ def test_identify_auth_params_authn_uncovered_authz_covered():
296296
expected_authz: list[str] = []
297297
expected_used = {"s_authz1"}
298298

299-
result = identify_required_authn_params(
299+
result = identify_auth_requirements(
300300
req_authn_params, req_authz_tokens, auth_service_names
301301
)
302302
assert result == (expected_params, expected_authz, expected_used)
@@ -310,7 +310,7 @@ def test_identify_auth_params_authn_and_authz_covered_no_overlap():
310310
expected_params = {}
311311
expected_authz: list[str] = []
312312
expected_used = {"s_authn1", "s_authz1"}
313-
result = identify_required_authn_params(
313+
result = identify_auth_requirements(
314314
req_authn_params, req_authz_tokens, auth_service_names
315315
)
316316
assert result == (expected_params, expected_authz, expected_used)
@@ -328,7 +328,7 @@ def test_identify_auth_params_authn_and_authz_covered_with_overlap():
328328
expected_params = {}
329329
expected_authz: list[str] = []
330330
expected_used = {"s_common", "s_authz_specific_avail", "s_authn_specific_avail"}
331-
result = identify_required_authn_params(
331+
result = identify_auth_requirements(
332332
req_authn_params, req_authz_tokens, auth_service_names
333333
)
334334
assert result == (expected_params, expected_authz, expected_used)
@@ -346,7 +346,7 @@ def test_identify_auth_params_authn_and_authz_covered_with_overlap_same_param():
346346
expected_params = {}
347347
expected_authz: list[str] = []
348348
expected_used = {"s_common", "s_authz_specific_avail", "s_authn_specific_avail"}
349-
result = identify_required_authn_params(
349+
result = identify_auth_requirements(
350350
req_authn_params, req_authz_tokens, auth_service_names
351351
)
352352
assert result == (expected_params, expected_authz, expected_used)
@@ -360,7 +360,7 @@ def test_identify_auth_params_complex_scenario():
360360
expected_params = {"p2": ["s3"]}
361361
expected_authz: list[str] = []
362362
expected_used = {"s1", "s4"}
363-
result = identify_required_authn_params(
363+
result = identify_auth_requirements(
364364
req_authn_params, req_authz_tokens, auth_service_names
365365
)
366366
assert result == (

0 commit comments

Comments
 (0)