Skip to content

Commit 4d4078b

Browse files
[PECO-1433] Support Databricks OAuth on GCP (#224)
Signed-off-by: Levko Kravets <levko.ne@gmail.com>
1 parent f3c53a5 commit 4d4078b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/connection/auth/DatabricksOAuth/OAuthManager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ export default abstract class OAuthManager {
197197
return new DatabricksOAuthManager(options);
198198
}
199199

200+
const gcpDomains = ['.gcp.databricks.com'];
201+
const isGCPDomain = gcpDomains.some((domain) => host.endsWith(domain));
202+
if (isGCPDomain) {
203+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
204+
return new DatabricksOAuthManager(options);
205+
}
206+
200207
if (options.useDatabricksOAuthInAzure) {
201208
const domains = ['.azuredatabricks.net'];
202209
const isSupportedDomain = domains.some((domain) => host.endsWith(domain));

tests/unit/DBSQLClient.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,19 @@ describe('DBSQLClient.initAuthProvider', () => {
363363
expect(provider.manager).to.be.instanceOf(AzureOAuthManager);
364364
});
365365

366+
it('should use Databricks OAuth method (GCP)', () => {
367+
const client = new DBSQLClient();
368+
369+
const provider = client.initAuthProvider({
370+
authType: 'databricks-oauth',
371+
// host is used when creating OAuth manager, so make it look like a real AWS instance
372+
host: 'example.gcp.databricks.com',
373+
});
374+
375+
expect(provider).to.be.instanceOf(DatabricksOAuth);
376+
expect(provider.manager).to.be.instanceOf(DatabricksOAuthManager);
377+
});
378+
366379
it('should use Databricks InHouse OAuth method (Azure)', () => {
367380
const client = new DBSQLClient();
368381

0 commit comments

Comments
 (0)