Skip to content

Commit d5b27d6

Browse files
committed
test(kernel): cover federation client ID forwarding
1 parent ff25e44 commit d5b27d6

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

tests/unit/test_kernel_auth_bridge.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,46 @@ def test_u2m_forwards_scopes(self, auth_type):
272272
assert kwargs["oauth_scopes"] == ["all-apis", "offline_access"]
273273

274274

275+
class TestKernelIdentityFederationClientId:
276+
@pytest.mark.parametrize(
277+
"auth_provider,auth_options",
278+
[
279+
pytest.param(AccessTokenAuthProvider("dapi-xyz"), {}, id="pat"),
280+
pytest.param(
281+
_FakeOAuthProvider(),
282+
{"oauth_client_id": "sp-uuid", "oauth_client_secret": "shh"},
283+
id="m2m",
284+
),
285+
pytest.param(
286+
_FakeOAuthProvider(),
287+
{"auth_type": "databricks-oauth"},
288+
id="u2m",
289+
),
290+
],
291+
)
292+
@pytest.mark.parametrize(
293+
"federation_client_id",
294+
[
295+
pytest.param(None, id="omitted"),
296+
pytest.param("", id="empty"),
297+
pytest.param("federation-client", id="supplied"),
298+
],
299+
)
300+
def test_forwards_only_non_empty_value(
301+
self, auth_provider, auth_options, federation_client_id
302+
):
303+
options = dict(auth_options)
304+
if federation_client_id is not None:
305+
options["identity_federation_client_id"] = federation_client_id
306+
307+
kwargs = kernel_auth_kwargs(auth_provider, options)
308+
309+
if federation_client_id:
310+
assert kwargs["identity_federation_client_id"] == federation_client_id
311+
else:
312+
assert "identity_federation_client_id" not in kwargs
313+
314+
275315
class TestKernelAuthAmbiguity:
276316
"""Conflicting auth signals must fail loudly at session-open rather
277317
than silently resolving to one flow (which would surface later as a

0 commit comments

Comments
 (0)