Repository navigation
Honor Auth_Scope for OAuth M2M client credentials #1707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2b1c93
eca5627
cc9af76
0dc3b59
71292c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,52 @@ void getWorkspaceClient_OAuthWithClientCredentials_AuthenticatesCorrectly() | |
| assertEquals("client-id", config.getClientId()); | ||
| assertEquals("client-secret", config.getClientSecret()); | ||
| assertEquals(DatabricksJdbcConstants.M2M_AUTH_TYPE, config.getAuthType()); | ||
| assertEquals(List.of("all-apis"), config.getScopes()); | ||
| } | ||
|
|
||
| @Test | ||
| void getWorkspaceClient_OAuthWithClientCredentials_UsesConfiguredScope() | ||
| throws DatabricksSQLException { | ||
| String jdbcUrl = | ||
| "jdbc:databricks://sample-host.cloud.databricks.com:443/default;SSL=1;AuthMech=11;" | ||
| + "Auth_Flow=1;httpPath=/sql/1.0/warehouses/99999999;" | ||
| + "OAuth2ClientId=client-id;OAuth2Secret=client-secret;Auth_Scope= sql "; | ||
| IDatabricksConnectionContext connectionContext = | ||
| DatabricksConnectionContextFactory.create(jdbcUrl, new Properties()); | ||
| assertEquals(" sql ", connectionContext.getAuthScope()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — The new client-secret M2M scope tests assert only |
||
| configurator = new ClientConfigurator(connectionContext); | ||
|
|
||
| assertEquals(List.of("sql"), configurator.getDatabricksConfig().getScopes()); | ||
| } | ||
|
|
||
| @Test | ||
| void getWorkspaceClient_OAuthWithClientCredentials_BlankScopeUsesDefault() | ||
| throws DatabricksSQLException { | ||
| String jdbcUrl = | ||
| "jdbc:databricks://sample-host.cloud.databricks.com:443/default;SSL=1;AuthMech=11;" | ||
| + "Auth_Flow=1;httpPath=/sql/1.0/warehouses/99999999;" | ||
| + "OAuth2ClientId=client-id;OAuth2Secret=client-secret;Auth_Scope="; | ||
| IDatabricksConnectionContext connectionContext = | ||
| DatabricksConnectionContextFactory.create(jdbcUrl, new Properties()); | ||
| assertEquals("", connectionContext.getAuthScope()); | ||
| configurator = new ClientConfigurator(connectionContext); | ||
|
|
||
| assertEquals(List.of("all-apis"), configurator.getDatabricksConfig().getScopes()); | ||
| } | ||
|
|
||
| @Test | ||
| void getWorkspaceClient_OAuthWithClientCredentials_UsesMultipleScopes() | ||
| throws DatabricksSQLException { | ||
| String jdbcUrl = | ||
| "jdbc:databricks://sample-host.cloud.databricks.com:443/default;SSL=1;AuthMech=11;" | ||
| + "Auth_Flow=1;httpPath=/sql/1.0/warehouses/99999999;" | ||
| + "OAuth2ClientId=client-id;OAuth2Secret=client-secret;Auth_Scope= sql jobs "; | ||
| IDatabricksConnectionContext connectionContext = | ||
| DatabricksConnectionContextFactory.create(jdbcUrl, new Properties()); | ||
| assertEquals(" sql jobs ", connectionContext.getAuthScope()); | ||
| configurator = new ClientConfigurator(connectionContext); | ||
|
|
||
| assertEquals(List.of("jobs", "sql"), configurator.getDatabricksConfig().getScopes()); | ||
| } | ||
|
|
||
| @Test | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.