|
|
|
|
@@ -33,7 +33,6 @@ import { TestEnvironmentService, TestEditorService } from 'vs/workbench/test/bro
|
|
|
|
|
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
|
|
|
|
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
|
|
|
|
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
|
|
|
|
import { assign } from 'vs/base/common/objects';
|
|
|
|
|
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
|
|
|
|
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
|
|
|
|
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
|
|
|
|
@@ -74,9 +73,9 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
id: undefined
|
|
|
|
|
};
|
|
|
|
|
let connectionProfileWithEmptySavedPassword: IConnectionProfile =
|
|
|
|
|
assign({}, connectionProfile, { password: '', serverName: connectionProfile.serverName + 1 });
|
|
|
|
|
Object.assign({}, connectionProfile, { password: '', serverName: connectionProfile.serverName + 1 });
|
|
|
|
|
let connectionProfileWithEmptyUnsavedPassword: IConnectionProfile =
|
|
|
|
|
assign({}, connectionProfile, { password: '', serverName: connectionProfile.serverName + 2, savePassword: false });
|
|
|
|
|
Object.assign({}, connectionProfile, { password: '', serverName: connectionProfile.serverName + 2, savePassword: false });
|
|
|
|
|
|
|
|
|
|
let connectionManagementService: ConnectionManagementService;
|
|
|
|
|
let configResult: { [key: string]: any } = {};
|
|
|
|
|
@@ -482,7 +481,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('changeGroupIdForconnection should change the groupId for a connection profile', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
profile.options = { password: profile.password };
|
|
|
|
|
profile.id = 'test_id';
|
|
|
|
|
let newGroupId = 'new_group_id';
|
|
|
|
|
@@ -504,7 +503,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('findExistingConnection should find connection for connectionProfile with same info', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri1 = 'connection:connectionId';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -535,7 +534,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('deleteConnection should delete the connection properly', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri1 = 'connection:connectionId';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -566,7 +565,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('deleteConnectionGroup should delete connections in connection group', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let profileGroup = createConnectionGroup('original_id');
|
|
|
|
|
profileGroup.addConnections([profile]);
|
|
|
|
|
let uri1 = 'connection:connectionId';
|
|
|
|
|
@@ -601,13 +600,13 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
connectionStore.setup(x => x.canChangeConnectionConfig(TypeMoq.It.isAny(), TypeMoq.It.isAnyString())).returns(() => {
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let newGroupId = 'test_group_id';
|
|
|
|
|
assert(connectionManagementService.canChangeConnectionConfig(profile, newGroupId));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('isProfileConnecting should return false for already connected profile', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'Editor Uri';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -635,7 +634,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('disconnect should disconnect the profile when given ConnectionProfile', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -664,7 +663,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('disconnect should disconnect the profile when given uri string', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -693,7 +692,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('cancelConnection should disconnect the profile', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -751,7 +750,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getConnection should grab connection that is connected', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let badString = 'bad_string';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
@@ -784,7 +783,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('connectIfNotConnected should not try to connect with already connected profile', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -818,7 +817,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getConnectionString should get connection string of connectionId', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let badString = 'bad_string';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
@@ -858,7 +857,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('rebuildIntellisenseCache should call rebuildIntelliSenseCache on provider', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -893,7 +892,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('buildConnectionInfo should get connection string of connectionId', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -928,9 +927,9 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('removeConnectionProfileCredentials should return connection profile without password', () => {
|
|
|
|
|
let profile = assign({}, connectionProfile);
|
|
|
|
|
let profile = Object.assign({}, connectionProfile);
|
|
|
|
|
connectionStore.setup(x => x.getProfileWithoutPassword(TypeMoq.It.isAny())).returns(() => {
|
|
|
|
|
let profileWithoutPass = assign({}, connectionProfile);
|
|
|
|
|
let profileWithoutPass = Object.assign({}, connectionProfile);
|
|
|
|
|
profileWithoutPass.password = undefined;
|
|
|
|
|
return <ConnectionProfile>profileWithoutPass;
|
|
|
|
|
});
|
|
|
|
|
@@ -939,7 +938,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getConnectionProfileById should return profile when given profileId', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let uri = 'connection:connectionId'; // must use default connection uri for test to work.
|
|
|
|
|
let badString = 'bad_string';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
@@ -973,7 +972,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Edit Connection - Changing connection profile name for same URI should persist after edit', async () => {
|
|
|
|
|
let profile = assign({}, connectionProfile);
|
|
|
|
|
let profile = Object.assign({}, connectionProfile);
|
|
|
|
|
let uri1 = 'test_uri1';
|
|
|
|
|
let newname = 'connection renamed';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
@@ -998,7 +997,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await connect(uri1, options, true, profile);
|
|
|
|
|
let newProfile = assign({}, connectionProfile);
|
|
|
|
|
let newProfile = Object.assign({}, connectionProfile);
|
|
|
|
|
newProfile.connectionName = newname;
|
|
|
|
|
options.params.isEditConnection = true;
|
|
|
|
|
await connect(uri1, options, true, newProfile);
|
|
|
|
|
@@ -1008,7 +1007,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
test('Edit Connection - Connecting a different URI with same profile via edit should not change profile ID.', async () => {
|
|
|
|
|
let uri1 = 'test_uri1';
|
|
|
|
|
let uri2 = 'test_uri2';
|
|
|
|
|
let profile = assign({}, connectionProfile);
|
|
|
|
|
let profile = Object.assign({}, connectionProfile);
|
|
|
|
|
profile.id = '0451';
|
|
|
|
|
let options: IConnectionCompletionOptions = {
|
|
|
|
|
params: {
|
|
|
|
|
@@ -1320,7 +1319,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('registerIconProvider should register icon provider for connectionManagementService', async () => {
|
|
|
|
|
let profile = <ConnectionProfile>assign({}, connectionProfile);
|
|
|
|
|
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
|
|
|
|
let serverInfo: azdata.ServerInfo = {
|
|
|
|
|
serverMajorVersion: 0,
|
|
|
|
|
serverMinorVersion: 0,
|
|
|
|
|
@@ -1464,9 +1463,9 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
let dbName = 'master';
|
|
|
|
|
let serverName = 'test_server';
|
|
|
|
|
let userName = 'test_user';
|
|
|
|
|
let connectionProfileWithoutDb: IConnectionProfile = assign(connectionProfile,
|
|
|
|
|
let connectionProfileWithoutDb: IConnectionProfile = Object.assign(connectionProfile,
|
|
|
|
|
{ serverName: serverName, databaseName: '', userName: userName, getOptionsKey: () => undefined });
|
|
|
|
|
let connectionProfileWithDb: IConnectionProfile = assign(connectionProfileWithoutDb, { databaseName: dbName });
|
|
|
|
|
let connectionProfileWithDb: IConnectionProfile = Object.assign(connectionProfileWithoutDb, { databaseName: dbName });
|
|
|
|
|
// Save the database with a URI that has the database name filled in, to mirror Carbon's behavior
|
|
|
|
|
let ownerUri = Utils.generateUri(connectionProfileWithDb);
|
|
|
|
|
await connect(ownerUri, undefined, false, connectionProfileWithoutDb);
|
|
|
|
|
@@ -1486,9 +1485,9 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
let newDbName = 'renamed_master';
|
|
|
|
|
let serverName = 'test_server';
|
|
|
|
|
let userName = 'test_user';
|
|
|
|
|
let connectionProfileWithoutDb: IConnectionProfile = assign(connectionProfile,
|
|
|
|
|
let connectionProfileWithoutDb: IConnectionProfile = Object.assign(connectionProfile,
|
|
|
|
|
{ serverName: serverName, databaseName: '', userName: userName, getOptionsKey: () => undefined });
|
|
|
|
|
let connectionProfileWithDb: IConnectionProfile = assign(connectionProfileWithoutDb, { databaseName: dbName });
|
|
|
|
|
let connectionProfileWithDb: IConnectionProfile = Object.assign(connectionProfileWithoutDb, { databaseName: dbName });
|
|
|
|
|
// Save the database with a URI that has the database name filled in, to mirror Carbon's behavior
|
|
|
|
|
let ownerUri = Utils.generateUri(connectionProfileWithDb);
|
|
|
|
|
let listDatabasesThenable = (connectionUri: string) => {
|
|
|
|
|
@@ -1545,7 +1544,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getConnectionCredentials returns the credentials dictionary for an active connection profile', async () => {
|
|
|
|
|
let profile = assign({}, connectionProfile);
|
|
|
|
|
let profile = Object.assign({}, connectionProfile);
|
|
|
|
|
profile.options = { password: profile.password };
|
|
|
|
|
profile.id = 'test_id';
|
|
|
|
|
connectionStatusManager.addConnection(profile, 'test_uri');
|
|
|
|
|
@@ -1607,7 +1606,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getConnectionUriFromId returns a URI of an active connection with the given id', () => {
|
|
|
|
|
let profile = assign({}, connectionProfile);
|
|
|
|
|
let profile = Object.assign({}, connectionProfile);
|
|
|
|
|
profile.options = { password: profile.password };
|
|
|
|
|
profile.id = 'test_id';
|
|
|
|
|
let uri = 'test_initial_uri';
|
|
|
|
|
@@ -1626,7 +1625,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getConectionUriFromId returns undefined if the given connection is not active', () => {
|
|
|
|
|
let profile = assign({}, connectionProfile);
|
|
|
|
|
let profile = Object.assign({}, connectionProfile);
|
|
|
|
|
profile.options = { password: profile.password };
|
|
|
|
|
profile.id = 'test_id';
|
|
|
|
|
connectionStatusManager.addConnection(profile, Utils.generateUri(profile));
|
|
|
|
|
|