diff --git a/src/sql/platform/connection/common/connectionManagement.ts b/src/sql/platform/connection/common/connectionManagement.ts index 78827cf421..6c35a2c64d 100644 --- a/src/sql/platform/connection/common/connectionManagement.ts +++ b/src/sql/platform/connection/common/connectionManagement.ts @@ -310,9 +310,9 @@ export interface IConnectionManagementService { getConnectionString(connectionId: string, includePassword: boolean): Thenable; /** - * Serialize connection string with optional provider + * Deserialize connection string using the specified provider */ - buildConnectionInfo(connectionString: string, provider?: string): Thenable; + buildConnectionInfo(connectionString: string, provider: string): Promise; providerRegistered(providerId: string): boolean; /** diff --git a/src/sql/platform/connection/test/common/testConnectionManagementService.ts b/src/sql/platform/connection/test/common/testConnectionManagementService.ts index 41c24f36af..c990ca6bc4 100644 --- a/src/sql/platform/connection/test/common/testConnectionManagementService.ts +++ b/src/sql/platform/connection/test/common/testConnectionManagementService.ts @@ -286,7 +286,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer return undefined!; } - buildConnectionInfo(connectionString: string, provider?: string): Thenable { + buildConnectionInfo(connectionString: string, provider: string): Promise { return undefined!; } diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 4d4ec0c78d..d3e8245d68 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -1674,18 +1674,13 @@ export class ConnectionManagementService extends Disposable implements IConnecti }); } - /** - * Serialize connection with options provider - * TODO this could be a map reduce operation - */ - public buildConnectionInfo(connectionString: string, provider: string): Thenable { - let connectionProvider = this._providers.get(provider); - if (connectionProvider) { - return connectionProvider.onReady.then(e => { - return e.buildConnectionInfo(connectionString); - }); + public async buildConnectionInfo(connectionString: string, providerId: string): Promise { + const connectionProviderInfo = this._providers.get(providerId); + if (!connectionProviderInfo) { + throw new Error(nls.localize('connection.unknownProvider', "Unknown provider '{0}'", providerId)); } - return Promise.resolve(undefined); + const provider = await connectionProviderInfo.onReady; + return provider.buildConnectionInfo(connectionString) } public getProviderProperties(providerName: string): ConnectionProviderProperties { diff --git a/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts b/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts index cebdad39dd..3da07f667f 100644 --- a/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts +++ b/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts @@ -938,6 +938,11 @@ suite('SQL ConnectionManagementService tests', () => { assert.strictEqual(result.options, options); }); + test('buildConnectionInfo with unknown provider should throw', async () => { + let testConnectionString = 'test_connection_string'; + await assert.rejects(() => connectionManagementService.buildConnectionInfo(testConnectionString, 'INVALID')); + }); + test('removeConnectionProfileCredentials should return connection profile without password', () => { let profile = Object.assign({}, connectionProfile); connectionStore.setup(x => x.getProfileWithoutPassword(TypeMoq.It.isAny())).returns(() => {