Skip to content

Commit fdc20e5

Browse files
ai: apply changes for #914 (1 review thread)
Addresses: - #3799379619 at src/databricks/sql/backend/kernel/auth_bridge.py:283 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 26d6e74 commit fdc20e5

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

tests/unit/test_kernel_auth_bridge.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,13 @@ def test_bare_azure_oauth_forwards_full_azure_bundle(self):
284284
"oauth_scopes": list(PYSQL_OAUTH_SCOPES),
285285
}
286286

287-
def test_u2m_custom_client_id_scopes_and_port_honored(self):
288-
# A caller overriding the app supplies the full coupled bundle;
289-
# every field is forwarded verbatim.
287+
def test_u2m_custom_client_id_and_port_honored_scopes_fixed(self):
288+
# A caller overriding the app supplies the coupled client_id +
289+
# redirect_port, which are forwarded verbatim. oauth_scopes is NOT
290+
# caller-overridable: the Thrift path hardcodes PYSQL_OAUTH_SCOPES
291+
# for U2M (it never reads an oauth_scopes kwarg), so the kernel
292+
# path forwards the same fixed scopes for parity even when the
293+
# caller passes their own.
290294
kwargs = kernel_auth_kwargs(
291295
_FakeOAuthProvider(),
292296
{
@@ -300,7 +304,7 @@ def test_u2m_custom_client_id_scopes_and_port_honored(self):
300304
"auth_type": "oauth-u2m",
301305
"client_id": "custom-client",
302306
"redirect_port": 9999,
303-
"oauth_scopes": ["custom-scope", "offline_access"],
307+
"oauth_scopes": list(PYSQL_OAUTH_SCOPES),
304308
}
305309

306310
def test_u2m_custom_client_id_only_falls_back_to_connector_defaults(self):
@@ -353,12 +357,16 @@ def test_u2m_redirect_port_ignored_without_client_id(self):
353357
assert kwargs["redirect_port"] == PYSQL_OAUTH_REDIRECT_PORT_RANGE[0]
354358

355359
@pytest.mark.parametrize("auth_type", ["databricks-oauth", "azure-oauth"])
356-
def test_u2m_forwards_custom_scopes(self, auth_type):
360+
def test_u2m_ignores_custom_scopes_for_thrift_parity(self, auth_type):
361+
# The Thrift path hardcodes PYSQL_OAUTH_SCOPES for U2M and never
362+
# reads a caller's oauth_scopes; the kernel path forwards the same
363+
# fixed scopes for parity rather than honoring an override the
364+
# other backend silently ignores.
357365
kwargs = kernel_auth_kwargs(
358366
_FakeOAuthProvider(),
359367
{"auth_type": auth_type, "oauth_scopes": ["all-apis", "offline_access"]},
360368
)
361-
assert kwargs["oauth_scopes"] == ["all-apis", "offline_access"]
369+
assert kwargs["oauth_scopes"] == list(PYSQL_OAUTH_SCOPES)
362370

363371

364372
class TestKernelIdentityFederationClientId:

0 commit comments

Comments
 (0)