Skip to content

Commit e0858b5

Browse files
ai: apply changes for #919 (1 review thread)
Addresses: - #3828404026 at src/databricks/sql/backend/kernel/auth_bridge.py:279 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 0fe8462 commit e0858b5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/unit/test_kernel_auth_bridge.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,32 @@ def test_azure_sp_m2m_forwards_federation_client_id(self):
735735
kwargs = kernel_auth_kwargs(_FakeOAuthProvider(), opts)
736736
assert kwargs["identity_federation_client_id"] == "fed-client"
737737

738+
@pytest.mark.parametrize(
739+
"conflicting_signal",
740+
[
741+
{"oauth_client_secret": "oauth-secret"},
742+
{"oauth_jwt_key_file": "/tmp/key.pem"},
743+
{"credentials_provider": object()},
744+
],
745+
)
746+
def test_azure_sp_m2m_ignores_conflicting_oauth_signal(self, conflicting_signal):
747+
# Intentional asymmetry: every OTHER flow treats a conflicting credential
748+
# signal as a hard "Ambiguous auth" error, but an explicit azure-sp-m2m
749+
# selector carries its creds in the azure_* namespace, so a stray
750+
# oauth_*/credentials_provider value is NOT a routing collision — it is
751+
# silently ignored (logger.debug breadcrumb only) and the Azure SP flow
752+
# still wins. This guards against a refactor accidentally promoting the
753+
# ignored signal to an error (see the routing note in auth_bridge.py).
754+
opts = dict(self._CREDS, **conflicting_signal)
755+
kwargs = kernel_auth_kwargs(_FakeOAuthProvider(), opts)
756+
# Does NOT raise, and routes to the Azure SP flow with only azure kwargs.
757+
assert kwargs == {
758+
"auth_type": "azure-sp-m2m",
759+
"azure_client_id": "azure-sp",
760+
"azure_client_secret": "azure-secret",
761+
"azure_tenant_id": "tenant-123",
762+
}
763+
738764

739765
class TestKernelScopesNormalization:
740766
def test_unknown_scope_type_raises(self):

0 commit comments

Comments
 (0)