mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Clean up buildConnectionInfo (#22407)
* Clean up buildConnectionInfo * Add test and cleanup
This commit is contained in:
@@ -310,9 +310,9 @@ export interface IConnectionManagementService {
|
|||||||
getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize connection string with optional provider
|
* Deserialize connection string using the specified provider
|
||||||
*/
|
*/
|
||||||
buildConnectionInfo(connectionString: string, provider?: string): Thenable<azdata.ConnectionInfo>;
|
buildConnectionInfo(connectionString: string, provider: string): Promise<azdata.ConnectionInfo>;
|
||||||
|
|
||||||
providerRegistered(providerId: string): boolean;
|
providerRegistered(providerId: string): boolean;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer
|
|||||||
return undefined!;
|
return undefined!;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildConnectionInfo(connectionString: string, provider?: string): Thenable<azdata.ConnectionInfo> {
|
buildConnectionInfo(connectionString: string, provider: string): Promise<azdata.ConnectionInfo> {
|
||||||
return undefined!;
|
return undefined!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1674,18 +1674,13 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async buildConnectionInfo(connectionString: string, providerId: string): Promise<azdata.ConnectionInfo> {
|
||||||
* Serialize connection with options provider
|
const connectionProviderInfo = this._providers.get(providerId);
|
||||||
* TODO this could be a map reduce operation
|
if (!connectionProviderInfo) {
|
||||||
*/
|
throw new Error(nls.localize('connection.unknownProvider', "Unknown provider '{0}'", providerId));
|
||||||
public buildConnectionInfo(connectionString: string, provider: string): Thenable<azdata.ConnectionInfo> {
|
|
||||||
let connectionProvider = this._providers.get(provider);
|
|
||||||
if (connectionProvider) {
|
|
||||||
return connectionProvider.onReady.then(e => {
|
|
||||||
return e.buildConnectionInfo(connectionString);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return Promise.resolve(undefined);
|
const provider = await connectionProviderInfo.onReady;
|
||||||
|
return provider.buildConnectionInfo(connectionString)
|
||||||
}
|
}
|
||||||
|
|
||||||
public getProviderProperties(providerName: string): ConnectionProviderProperties {
|
public getProviderProperties(providerName: string): ConnectionProviderProperties {
|
||||||
|
|||||||
@@ -938,6 +938,11 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
assert.strictEqual(result.options, options);
|
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', () => {
|
test('removeConnectionProfileCredentials should return connection profile without password', () => {
|
||||||
let profile = Object.assign({}, connectionProfile);
|
let profile = Object.assign({}, connectionProfile);
|
||||||
connectionStore.setup(x => x.getProfileWithoutPassword(TypeMoq.It.isAny())).returns(() => {
|
connectionStore.setup(x => x.getProfileWithoutPassword(TypeMoq.It.isAny())).returns(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user