23
23
from toolbox_core .protocol import ParameterSchema
24
24
from toolbox_core .utils import (
25
25
create_func_docstring ,
26
- identify_required_authn_params ,
26
+ identify_auth_requirements ,
27
27
params_to_pydantic_model ,
28
28
resolve_value ,
29
29
)
@@ -82,15 +82,15 @@ def test_create_func_docstring_empty_description():
82
82
assert create_func_docstring (description , params ) == expected_docstring
83
83
84
84
85
- def test_identify_required_authn_params_none_required ():
85
+ def test_identify_auth_requirements_none_required ():
86
86
"""Test when no authentication parameters or authorization tokens are required initially."""
87
87
req_authn_params : dict [str , list [str ]] = {}
88
88
req_authz_tokens : list [str ] = []
89
89
auth_service_names = ["service_a" , "service_b" ]
90
90
expected_params = {}
91
91
expected_authz : list [str ] = []
92
92
expected_used = set ()
93
- result = identify_required_authn_params (
93
+ result = identify_auth_requirements (
94
94
req_authn_params , req_authz_tokens , auth_service_names
95
95
)
96
96
assert result == (
@@ -100,7 +100,7 @@ def test_identify_required_authn_params_none_required():
100
100
)
101
101
102
102
103
- def test_identify_required_authn_params_all_covered ():
103
+ def test_identify_auth_requirements_all_covered ():
104
104
"""Test when all required authn parameters are covered, no authz tokens."""
105
105
req_authn_params = {
106
106
"token_a" : ["service_a" ],
@@ -111,7 +111,7 @@ def test_identify_required_authn_params_all_covered():
111
111
expected_params = {}
112
112
expected_authz : list [str ] = []
113
113
expected_used = {"service_a" , "service_b" }
114
- result = identify_required_authn_params (
114
+ result = identify_auth_requirements (
115
115
req_authn_params , req_authz_tokens , auth_service_names
116
116
)
117
117
assert result == (
@@ -121,7 +121,7 @@ def test_identify_required_authn_params_all_covered():
121
121
)
122
122
123
123
124
- def test_identify_required_authn_params_some_covered ():
124
+ def test_identify_auth_requirements_some_covered ():
125
125
"""Test when some authn parameters are covered, and some are not, no authz tokens."""
126
126
req_authn_params = {
127
127
"token_a" : ["service_a" ],
@@ -138,7 +138,7 @@ def test_identify_required_authn_params_some_covered():
138
138
expected_authz : list [str ] = []
139
139
expected_used = {"service_a" , "service_b" }
140
140
141
- result = identify_required_authn_params (
141
+ result = identify_auth_requirements (
142
142
req_authn_params , req_authz_tokens , auth_service_names
143
143
)
144
144
assert result == (
@@ -148,7 +148,7 @@ def test_identify_required_authn_params_some_covered():
148
148
)
149
149
150
150
151
- def test_identify_required_authn_params_none_covered ():
151
+ def test_identify_auth_requirements_none_covered ():
152
152
"""Test when none of the required authn parameters are covered, no authz tokens."""
153
153
req_authn_params = {
154
154
"token_d" : ["service_d" ],
@@ -162,7 +162,7 @@ def test_identify_required_authn_params_none_covered():
162
162
}
163
163
expected_authz : list [str ] = []
164
164
expected_used = set ()
165
- result = identify_required_authn_params (
165
+ result = identify_auth_requirements (
166
166
req_authn_params , req_authz_tokens , auth_service_names
167
167
)
168
168
assert result == (
@@ -172,7 +172,7 @@ def test_identify_required_authn_params_none_covered():
172
172
)
173
173
174
174
175
- def test_identify_required_authn_params_no_available_services ():
175
+ def test_identify_auth_requirements_no_available_services ():
176
176
"""Test when no authn services are available, no authz tokens."""
177
177
req_authn_params = {
178
178
"token_a" : ["service_a" ],
@@ -186,7 +186,7 @@ def test_identify_required_authn_params_no_available_services():
186
186
}
187
187
expected_authz : list [str ] = []
188
188
expected_used = set ()
189
- result = identify_required_authn_params (
189
+ result = identify_auth_requirements (
190
190
req_authn_params , req_authz_tokens , auth_service_names
191
191
)
192
192
assert result == (
@@ -196,7 +196,7 @@ def test_identify_required_authn_params_no_available_services():
196
196
)
197
197
198
198
199
- def test_identify_required_authn_params_empty_services_for_param ():
199
+ def test_identify_auth_requirements_empty_services_for_param ():
200
200
"""Test edge case: authn param requires an empty list of services, no authz tokens."""
201
201
req_authn_params = {
202
202
"token_x" : [],
@@ -208,7 +208,7 @@ def test_identify_required_authn_params_empty_services_for_param():
208
208
}
209
209
expected_authz : list [str ] = []
210
210
expected_used = set ()
211
- result = identify_required_authn_params (
211
+ result = identify_auth_requirements (
212
212
req_authn_params , req_authz_tokens , auth_service_names
213
213
)
214
214
assert result == (
@@ -223,7 +223,7 @@ def test_identify_auth_params_only_authz_empty():
223
223
req_authn_params : dict [str , list [str ]] = {}
224
224
req_authz_tokens : list [str ] = []
225
225
auth_service_names = ["s1" ]
226
- result = identify_required_authn_params (
226
+ result = identify_auth_requirements (
227
227
req_authn_params , req_authz_tokens , auth_service_names
228
228
)
229
229
assert result == ({}, [], set ())
@@ -234,7 +234,7 @@ def test_identify_auth_params_authz_all_covered():
234
234
req_authn_params : dict [str , list [str ]] = {}
235
235
req_authz_tokens = ["s1" , "s2" ]
236
236
auth_service_names = ["s1" , "s2" , "s3" ]
237
- result = identify_required_authn_params (
237
+ result = identify_auth_requirements (
238
238
req_authn_params , req_authz_tokens , auth_service_names
239
239
)
240
240
assert result == ({}, [], {"s1" , "s2" })
@@ -245,7 +245,7 @@ def test_identify_auth_params_authz_partially_covered_by_available():
245
245
req_authn_params : dict [str , list [str ]] = {}
246
246
req_authz_tokens = ["s1" , "s2" ]
247
247
auth_service_names = ["s1" , "s3" ]
248
- result = identify_required_authn_params (
248
+ result = identify_auth_requirements (
249
249
req_authn_params , req_authz_tokens , auth_service_names
250
250
)
251
251
assert result == ({}, [], {"s1" })
@@ -256,7 +256,7 @@ def test_identify_auth_params_authz_none_covered():
256
256
req_authn_params : dict [str , list [str ]] = {}
257
257
req_authz_tokens = ["s1" , "s2" ]
258
258
auth_service_names = ["s3" , "s4" ]
259
- result = identify_required_authn_params (
259
+ result = identify_auth_requirements (
260
260
req_authn_params , req_authz_tokens , auth_service_names
261
261
)
262
262
assert result == ({}, ["s1" , "s2" ], set ())
@@ -267,7 +267,7 @@ def test_identify_auth_params_authz_none_covered_empty_available():
267
267
req_authn_params : dict [str , list [str ]] = {}
268
268
req_authz_tokens = ["s1" , "s2" ]
269
269
auth_service_names : list [str ] = []
270
- result = identify_required_authn_params (
270
+ result = identify_auth_requirements (
271
271
req_authn_params , req_authz_tokens , auth_service_names
272
272
)
273
273
assert result == ({}, ["s1" , "s2" ], set ())
@@ -281,7 +281,7 @@ def test_identify_auth_params_authn_covered_authz_uncovered():
281
281
expected_params = {}
282
282
expected_authz : list [str ] = ["s_authz_needed1" , "s_authz_needed2" ]
283
283
expected_used = {"s_authn1" }
284
- result = identify_required_authn_params (
284
+ result = identify_auth_requirements (
285
285
req_authn_params , req_authz_tokens , auth_service_names
286
286
)
287
287
assert result == (expected_params , expected_authz , expected_used )
@@ -296,7 +296,7 @@ def test_identify_auth_params_authn_uncovered_authz_covered():
296
296
expected_authz : list [str ] = []
297
297
expected_used = {"s_authz1" }
298
298
299
- result = identify_required_authn_params (
299
+ result = identify_auth_requirements (
300
300
req_authn_params , req_authz_tokens , auth_service_names
301
301
)
302
302
assert result == (expected_params , expected_authz , expected_used )
@@ -310,7 +310,7 @@ def test_identify_auth_params_authn_and_authz_covered_no_overlap():
310
310
expected_params = {}
311
311
expected_authz : list [str ] = []
312
312
expected_used = {"s_authn1" , "s_authz1" }
313
- result = identify_required_authn_params (
313
+ result = identify_auth_requirements (
314
314
req_authn_params , req_authz_tokens , auth_service_names
315
315
)
316
316
assert result == (expected_params , expected_authz , expected_used )
@@ -328,7 +328,7 @@ def test_identify_auth_params_authn_and_authz_covered_with_overlap():
328
328
expected_params = {}
329
329
expected_authz : list [str ] = []
330
330
expected_used = {"s_common" , "s_authz_specific_avail" , "s_authn_specific_avail" }
331
- result = identify_required_authn_params (
331
+ result = identify_auth_requirements (
332
332
req_authn_params , req_authz_tokens , auth_service_names
333
333
)
334
334
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():
346
346
expected_params = {}
347
347
expected_authz : list [str ] = []
348
348
expected_used = {"s_common" , "s_authz_specific_avail" , "s_authn_specific_avail" }
349
- result = identify_required_authn_params (
349
+ result = identify_auth_requirements (
350
350
req_authn_params , req_authz_tokens , auth_service_names
351
351
)
352
352
assert result == (expected_params , expected_authz , expected_used )
@@ -360,7 +360,7 @@ def test_identify_auth_params_complex_scenario():
360
360
expected_params = {"p2" : ["s3" ]}
361
361
expected_authz : list [str ] = []
362
362
expected_used = {"s1" , "s4" }
363
- result = identify_required_authn_params (
363
+ result = identify_auth_requirements (
364
364
req_authn_params , req_authz_tokens , auth_service_names
365
365
)
366
366
assert result == (
0 commit comments