mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
Revert new connection string format (#22997)
This commit is contained in:
@@ -185,11 +185,6 @@ export class MainThreadConnectionManagement extends Disposable implements MainTh
|
||||
return this._connectionManagementService.openChangePasswordDialog(convertedProfile);
|
||||
}
|
||||
|
||||
public $getEditorConnectionProfileTitle(profile: IConnectionProfile, getNonDefaultsOnly?: boolean): Thenable<string | undefined> {
|
||||
// Need to have access to getOptionsKey, so recreate profile from details.
|
||||
return Promise.resolve(this._connectionManagementService.getEditorConnectionProfileTitle(profile, getNonDefaultsOnly));
|
||||
}
|
||||
|
||||
public async $listDatabases(connectionId: string): Promise<string[]> {
|
||||
let connectionUri = await this.$getUriForConnection(connectionId);
|
||||
let result = await this._connectionManagementService.listDatabases(connectionUri);
|
||||
|
||||
@@ -78,10 +78,6 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
||||
return this._proxy.$openChangePasswordDialog(profile);
|
||||
}
|
||||
|
||||
public $getEditorConnectionProfileTitle(profile: azdata.IConnectionProfile, getNonDefaultsOnly?: boolean): Thenable<string> {
|
||||
return this._proxy.$getEditorConnectionProfileTitle(profile, getNonDefaultsOnly);
|
||||
}
|
||||
|
||||
public $listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return this._proxy.$listDatabases(connectionId);
|
||||
}
|
||||
|
||||
@@ -141,9 +141,6 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
openChangePasswordDialog(profile: azdata.IConnectionProfile): Thenable<string | undefined> {
|
||||
return extHostConnectionManagement.$openChangePasswordDialog(profile);
|
||||
},
|
||||
getEditorConnectionProfileTitle(profile: azdata.IConnectionProfile, getNonDefaultsOnly?: boolean): Thenable<string> {
|
||||
return extHostConnectionManagement.$getEditorConnectionProfileTitle(profile, getNonDefaultsOnly);
|
||||
},
|
||||
listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||
},
|
||||
|
||||
@@ -724,7 +724,6 @@ export interface MainThreadConnectionManagementShape extends IDisposable {
|
||||
$getServerInfo(connectedId: string): Thenable<azdata.ServerInfo>;
|
||||
$openConnectionDialog(providers: string[], initialConnectionProfile?: azdata.IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Thenable<azdata.connection.Connection>;
|
||||
$openChangePasswordDialog(profile: azdata.IConnectionProfile): Thenable<string | undefined>;
|
||||
$getEditorConnectionProfileTitle(profile: azdata.IConnectionProfile, getNonDefaultsOnly?: boolean): Thenable<string>;
|
||||
$listDatabases(connectionId: string): Thenable<string[]>;
|
||||
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||
$getUriForConnection(connectionId: string): Thenable<string>;
|
||||
|
||||
@@ -243,18 +243,11 @@ export abstract class QueryEditorInput extends EditorInput implements IConnectab
|
||||
title = this._description + ' ';
|
||||
}
|
||||
if (profile) {
|
||||
let fullTitleText = this.connectionManagementService.getEditorConnectionProfileTitle(profile);
|
||||
if (fullTitleText.length !== 0) {
|
||||
title += fullTitleText;
|
||||
}
|
||||
else {
|
||||
title += `${profile.serverName}`;
|
||||
if (profile.databaseName) {
|
||||
title += `.${profile.databaseName}`;
|
||||
}
|
||||
title += ` (${profile.userName || profile.authenticationType})`;
|
||||
title += profile.getOptionsKey();
|
||||
title += `${profile.serverName}`;
|
||||
if (profile.databaseName) {
|
||||
title += `.${profile.databaseName}`;
|
||||
}
|
||||
title += ` (${profile.userName || profile.authenticationType})`;
|
||||
} else {
|
||||
title += localize('disconnected', "disconnected");
|
||||
}
|
||||
|
||||
@@ -68,38 +68,23 @@ export class ConnectionStatusbarItem extends Disposable implements IWorkbenchCon
|
||||
|
||||
// Set connection info to connection status bar
|
||||
private _setConnectionText(connectionProfile: IConnectionProfile): void {
|
||||
let text: string = undefined;
|
||||
let fullEditorText: string = this.connectionManagementService.getEditorConnectionProfileTitle(connectionProfile);
|
||||
if (fullEditorText.length === 0) {
|
||||
text = connectionProfile.serverName;
|
||||
if (text) {
|
||||
if (connectionProfile.databaseName && connectionProfile.databaseName !== '') {
|
||||
text = text + ' : ' + connectionProfile.databaseName;
|
||||
} else {
|
||||
text = text + ' : ' + '<default>';
|
||||
}
|
||||
let text: string = connectionProfile.serverName;
|
||||
if (text) {
|
||||
if (connectionProfile.databaseName && connectionProfile.databaseName !== '') {
|
||||
text = text + ' : ' + connectionProfile.databaseName;
|
||||
} else {
|
||||
text = text + ' : ' + '<default>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
text = fullEditorText;
|
||||
|
||||
let tooltip: string =
|
||||
'Server: ' + connectionProfile.serverName + '\r\n' +
|
||||
'Database: ' + (connectionProfile.databaseName ? connectionProfile.databaseName : '<default>') + '\r\n';
|
||||
|
||||
if (connectionProfile.userName && connectionProfile.userName !== '') {
|
||||
tooltip = tooltip + 'Login: ' + connectionProfile.userName + '\r\n';
|
||||
}
|
||||
|
||||
let tooltip: string = undefined;
|
||||
|
||||
if (!fullEditorText) {
|
||||
tooltip = 'Server: ' + connectionProfile.serverName + '\r\n' +
|
||||
'Database: ' + (connectionProfile.databaseName ? connectionProfile.databaseName : '<default>') + '\r\n';
|
||||
|
||||
if (connectionProfile.userName && connectionProfile.userName !== '') {
|
||||
tooltip = tooltip + 'Login: ' + connectionProfile.userName + '\r\n';
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It is difficult to have every possible option that is different displayed as above with consistent naming, therefore the tooltip will show the full string.
|
||||
tooltip = fullEditorText;
|
||||
}
|
||||
|
||||
|
||||
this.statusItem.update({
|
||||
name: this.name,
|
||||
text: text,
|
||||
|
||||
@@ -731,10 +731,7 @@ export class AttachToDropdown extends SelectBox {
|
||||
} else {
|
||||
let connections: string[] = [];
|
||||
if (model.context && model.context.title && (connProviderIds.includes(this.model.context.providerName))) {
|
||||
let textResult = model.context.title;
|
||||
let fullTitleText = this._connectionManagementService.getEditorConnectionProfileTitle(model.context);
|
||||
textResult = fullTitleText.length !== 0 ? fullTitleText : textResult;
|
||||
connections.push(textResult);
|
||||
connections.push(model.context.title);
|
||||
} else if (this._configurationService.getValue(saveConnectionNameConfigName) && model.savedConnectionName) {
|
||||
connections.push(model.savedConnectionName);
|
||||
} else {
|
||||
|
||||
@@ -121,7 +121,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
// get the full ConnectionProfiles with the server info updated properly
|
||||
const treeInput = TreeUpdateUtils.getTreeInput(this._connectionManagementService)!;
|
||||
await this._tree.setInput(treeInput);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
this._treeSelectionHandler.onTreeActionStateChange(false);
|
||||
} else {
|
||||
if (this._connectionManagementService.hasRegisteredServers()) {
|
||||
@@ -269,7 +268,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (connectionParentGroup) {
|
||||
connectionParentGroup.addOrReplaceConnection(newConnection);
|
||||
await this._tree.updateChildren(connectionParentGroup);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(newConnection);
|
||||
await this._tree.expand(newConnection);
|
||||
}
|
||||
@@ -284,7 +282,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
await this._tree.rerender(connectionInTree);
|
||||
await this._tree.revealSelectFocusElement(connectionInTree);
|
||||
await this._tree.updateChildren(connectionInTree);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.expand(connectionInTree);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +294,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (parentGroup) {
|
||||
parentGroup.removeConnections([e]);
|
||||
await this._tree.updateChildren(parentGroup);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(parentGroup);
|
||||
}
|
||||
}
|
||||
@@ -315,14 +311,12 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
const newProfileParent = <ConnectionProfileGroup>this._tree.getElementById(e.profile.groupId);
|
||||
newProfileParent.addOrReplaceConnection(e.profile);
|
||||
await this._tree.updateChildren(newProfileParent);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(e.profile);
|
||||
await this._tree.expand(e.profile);
|
||||
} else {
|
||||
// If the profile was not moved to a different group then just update the profile in the group.
|
||||
oldProfileParent.replaceConnection(e.profile, e.oldProfileId);
|
||||
await this._tree.updateChildren(oldProfileParent)
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(e.profile);
|
||||
await this._tree.expand(e.profile);
|
||||
}
|
||||
@@ -344,7 +338,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
newParent.addOrReplaceConnection(movedConnection);
|
||||
await this._tree.updateChildren(newParent);
|
||||
}
|
||||
await this.refreshConnectionTreeTitles();
|
||||
const newConnection = this._tree.getElementById(movedConnection.id);
|
||||
if (newConnection) {
|
||||
await this._tree.revealSelectFocusElement(newConnection);
|
||||
@@ -359,7 +352,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
const parent = <ConnectionProfileGroup>this._tree.getElementById(e.parentId);
|
||||
parent.children = parent.children.filter(c => c.id !== e.id);
|
||||
await this._tree.updateChildren(parent);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(parent);
|
||||
}
|
||||
}));
|
||||
@@ -382,7 +374,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
e.parent = parent;
|
||||
e.parentId = parent.id;
|
||||
await this._tree.updateChildren(parent);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(e);
|
||||
}
|
||||
}));
|
||||
@@ -393,7 +384,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (newParent) {
|
||||
newParent.children[newParent.children.findIndex(c => c.id === e.id)] = e;
|
||||
await this._tree.updateChildren(newParent);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(e);
|
||||
}
|
||||
}
|
||||
@@ -412,7 +402,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
(<ConnectionProfileGroup>movedGroup).parent = newParent;
|
||||
(<ConnectionProfileGroup>movedGroup).parentId = newParent.id;
|
||||
await this._tree.updateChildren(newParent);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
await this._tree.revealSelectFocusElement(movedGroup);
|
||||
// Expanding the previously expanded children of the moved group after the move.
|
||||
this._tree.expandElements(profileExpandedState);
|
||||
@@ -652,7 +641,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
await this._tree.setInput(treeInput!);
|
||||
await this._tree.updateChildren(treeInput!);
|
||||
await this.refreshConnectionTreeTitles();
|
||||
return;
|
||||
}
|
||||
await this._tree.setInput(treeInput!);
|
||||
@@ -913,11 +901,4 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
}
|
||||
return actionContext;
|
||||
}
|
||||
|
||||
private async refreshConnectionTreeTitles(): Promise<void> {
|
||||
let treeInput = TreeUpdateUtils.getTreeInput(this._connectionManagementService);
|
||||
let treeArray = TreeUpdateUtils.alterTreeChildrenTitles([treeInput]);
|
||||
treeInput = treeArray[0];
|
||||
await this._tree!.setInput(treeInput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,22 +539,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
|
||||
let isEdit = options?.params?.isEditConnection ?? false;
|
||||
|
||||
let matcher: interfaces.ProfileMatcher;
|
||||
if (isEdit) {
|
||||
matcher = (a: interfaces.IConnectionProfile, b: interfaces.IConnectionProfile) => a.id === options.params.oldProfileId;
|
||||
|
||||
//Check to make sure the edits are not identical to another connection.
|
||||
await this._connectionStore.isDuplicateEdit(connection, matcher).then(result => {
|
||||
if (result) {
|
||||
// Must get connection group name here as it may not always be initialized and causes problems when deleting when included with options.
|
||||
this._logService.error(`Profile edit for '${connection.id}' exactly matches an existing profile with data: '${ConnectionProfile.getDisplayOptionsKey(connection.getOptionsKey())}'`);
|
||||
throw new Error(`Cannot save profile, the selected connection options are identical to an existing profile with details: \n
|
||||
${ConnectionProfile.getDisplayOptionsKey(connection.getOptionsKey())}${(connection.groupFullName !== undefined && connection.groupFullName !== '' && connection.groupFullName !== '/') ?
|
||||
ConnectionProfile.displayIdSeparator + 'groupName' + ConnectionProfile.displayNameValueSeparator + connection.groupFullName : ''}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!uri) {
|
||||
uri = Utils.generateUri(connection);
|
||||
}
|
||||
@@ -602,6 +586,11 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
callbacks.onConnectSuccess(options.params, connectionResult.connectionProfile);
|
||||
}
|
||||
if (options.saveTheConnection || isEdit) {
|
||||
let matcher: interfaces.ProfileMatcher;
|
||||
if (isEdit) {
|
||||
matcher = (a: interfaces.IConnectionProfile, b: interfaces.IConnectionProfile) => a.id === options.params.oldProfileId;
|
||||
}
|
||||
|
||||
await this.saveToSettings(uri, connection, matcher).then(value => {
|
||||
this._onAddConnectionProfile.fire(connection);
|
||||
if (isEdit) {
|
||||
@@ -709,20 +698,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
return result;
|
||||
}
|
||||
|
||||
public getEditorConnectionProfileTitle(profile: interfaces.IConnectionProfile, getNonDefaultsOnly?: boolean): string {
|
||||
let result = '';
|
||||
if (profile) {
|
||||
let tempProfile = new ConnectionProfile(this._capabilitiesService, profile);
|
||||
if (!getNonDefaultsOnly) {
|
||||
result = tempProfile.getEditorFullTitleWithOptions();
|
||||
}
|
||||
else {
|
||||
result = tempProfile.getNonDefaultOptionsString();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private doActionsAfterConnectionComplete(uri: string, options: IConnectionCompletionOptions): void {
|
||||
let connectionManagementInfo = this._connectionStatusManager.findConnection(uri);
|
||||
if (!connectionManagementInfo) {
|
||||
@@ -1295,7 +1270,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
this._connectionGlobalStatus.setStatusToConnected(info.connectionSummary);
|
||||
}
|
||||
|
||||
const connectionUniqueId = connection.connectionProfile.getOptionsKey();
|
||||
const connectionUniqueId = connection.connectionProfile.getConnectionInfoId();
|
||||
if (info.isSupportedVersion === false
|
||||
&& this._connectionsGotUnsupportedVersionWarning.indexOf(connectionUniqueId) === -1
|
||||
&& this._configurationService.getValue<boolean>('connection.showUnsupportedServerVersionWarning')) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import { IHandleFirewallRuleResult } from 'sql/workbench/services/resourceProvider/common/resourceProviderService';
|
||||
|
||||
import { IConnectionProfile, ServiceOptionType } from 'sql/platform/connection/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { TestConnectionProvider } from 'sql/platform/connection/test/common/testConnectionProvider';
|
||||
import { TestResourceProvider } from 'sql/workbench/services/resourceProvider/test/common/testResourceProviderService';
|
||||
@@ -68,7 +68,6 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
getOptionsKey: () => { return 'connectionId'; },
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
@@ -515,7 +514,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
assert.ok(called, 'expected changeGroupIdForConnectionGroup to be called on ConnectionStore');
|
||||
});
|
||||
|
||||
test('findExistingConnection should find connection for connectionProfile with same basic info', async () => {
|
||||
test('findExistingConnection should find connection for connectionProfile with same info', async () => {
|
||||
let profile = <ConnectionProfile>Object.assign({}, connectionProfile);
|
||||
let uri1 = 'connection:connectionId';
|
||||
let options: IConnectionCompletionOptions = {
|
||||
@@ -1014,15 +1013,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
|
||||
let originalProfileKey = '';
|
||||
connectionStore.setup(x => x.isDuplicateEdit(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((inputProfile, matcher) => {
|
||||
let newProfile = ConnectionProfile.fromIConnectionProfile(new TestCapabilitiesService(), inputProfile);
|
||||
let result = newProfile.getOptionsKey() === originalProfileKey;
|
||||
return Promise.resolve(result);
|
||||
});
|
||||
await connect(uri1, options, true, profile);
|
||||
let originalProfile = ConnectionProfile.fromIConnectionProfile(new TestCapabilitiesService(), connectionProfile);
|
||||
originalProfileKey = originalProfile.getOptionsKey();
|
||||
let newProfile = Object.assign({}, connectionProfile);
|
||||
newProfile.connectionName = newname;
|
||||
options.params.isEditConnection = true;
|
||||
@@ -1056,8 +1047,6 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
|
||||
// In an actual edit situation, the profile options would be different for different URIs, as a placeholder, we check the test uris instead here.
|
||||
connectionStore.setup(x => x.isDuplicateEdit(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(uri1 === uri2));
|
||||
await connect(uri1, options, true, profile);
|
||||
options.params.isEditConnection = true;
|
||||
await connect(uri2, options, true, profile);
|
||||
@@ -1066,51 +1055,6 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
assert.strictEqual(uri1info.connectionProfile.id, uri2info.connectionProfile.id);
|
||||
});
|
||||
|
||||
test('Edit Connection - Connecting with an already connected profile via edit should throw an error', async () => {
|
||||
let uri1 = 'test_uri1';
|
||||
let profile = Object.assign({}, connectionProfile);
|
||||
profile.id = '0451';
|
||||
let options: IConnectionCompletionOptions = {
|
||||
params: {
|
||||
connectionType: ConnectionType.editor,
|
||||
input: {
|
||||
onConnectSuccess: undefined,
|
||||
onConnectReject: undefined,
|
||||
onConnectStart: undefined,
|
||||
onDisconnect: undefined,
|
||||
onConnectCanceled: undefined,
|
||||
uri: uri1
|
||||
},
|
||||
queryRange: undefined,
|
||||
runQueryOnCompletion: RunQueryOnConnectionMode.none,
|
||||
isEditConnection: true
|
||||
},
|
||||
saveTheConnection: true,
|
||||
showDashboard: false,
|
||||
showConnectionDialogOnError: true,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
|
||||
let originalProfileKey = '';
|
||||
connectionStore.setup(x => x.isDuplicateEdit(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((inputProfile, matcher) => {
|
||||
let newProfile = ConnectionProfile.fromIConnectionProfile(new TestCapabilitiesService(), inputProfile);
|
||||
let result = newProfile.getOptionsKey() === originalProfileKey;
|
||||
return Promise.resolve(result)
|
||||
});
|
||||
|
||||
await connect(uri1, options, true, profile);
|
||||
let originalProfile = ConnectionProfile.fromIConnectionProfile(new TestCapabilitiesService(), connectionProfile);
|
||||
originalProfileKey = originalProfile.getOptionsKey();
|
||||
let newProfile = Object.assign({}, connectionProfile);
|
||||
options.params.isEditConnection = true;
|
||||
try {
|
||||
await connect(uri1, options, true, newProfile);
|
||||
assert.fail;
|
||||
}
|
||||
catch {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('failed firewall rule should open the firewall rule dialog', async () => {
|
||||
handleFirewallRuleResult.canHandleFirewallRule = true;
|
||||
@@ -2048,118 +1992,6 @@ test('clearRecentConnection and ConnectionsList should call connectionStore func
|
||||
assert(called);
|
||||
});
|
||||
|
||||
test('getEditorConnectionProfileTitle should return a correctly formatted title for a connection profile', () => {
|
||||
let profile: IConnectionProfile = {
|
||||
connectionName: 'new name',
|
||||
serverName: 'new server',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: Constants.AuthenticationType.Integrated,
|
||||
savePassword: true,
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
getOptionsKey: () => { return ''; },
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined
|
||||
};
|
||||
|
||||
let capabilitiesService = new TestCapabilitiesService();
|
||||
const testOption1 = {
|
||||
name: 'testOption1',
|
||||
displayName: 'testOption1',
|
||||
description: 'test description',
|
||||
groupName: 'test group name',
|
||||
valueType: ServiceOptionType.string,
|
||||
specialValueType: undefined,
|
||||
defaultValue: '',
|
||||
categoryValues: undefined,
|
||||
isIdentity: false,
|
||||
isRequired: false
|
||||
};
|
||||
|
||||
const testOption2 = {
|
||||
name: 'testOption2',
|
||||
displayName: 'testOption2',
|
||||
description: 'test description',
|
||||
groupName: 'test group name',
|
||||
valueType: ServiceOptionType.number,
|
||||
specialValueType: undefined,
|
||||
defaultValue: '10',
|
||||
categoryValues: undefined,
|
||||
isIdentity: false,
|
||||
isRequired: false
|
||||
};
|
||||
|
||||
const testOption3 = {
|
||||
name: 'testOption3',
|
||||
displayName: 'testOption3',
|
||||
description: 'test description',
|
||||
groupName: 'test group name',
|
||||
valueType: ServiceOptionType.string,
|
||||
specialValueType: undefined,
|
||||
defaultValue: 'default',
|
||||
categoryValues: undefined,
|
||||
isIdentity: false,
|
||||
isRequired: false
|
||||
};
|
||||
|
||||
profile.options['testOption1'] = 'test value';
|
||||
profile.options['testOption2'] = '50';
|
||||
profile.options['testOption3'] = 'default';
|
||||
|
||||
let mainProvider = capabilitiesService.capabilities['MSSQL'];
|
||||
let mainProperties = mainProvider.connection;
|
||||
let mainOptions = mainProperties.connectionOptions;
|
||||
|
||||
mainOptions.push(testOption1);
|
||||
mainOptions.push(testOption2);
|
||||
mainOptions.push(testOption3);
|
||||
|
||||
mainProperties.connectionOptions = mainOptions;
|
||||
mainProvider.connection = mainProperties;
|
||||
|
||||
capabilitiesService.capabilities['MSSQL'] = mainProvider;
|
||||
|
||||
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
||||
const testInstantiationService = new TestInstantiationService();
|
||||
testInstantiationService.stub(IStorageService, new TestStorageService());
|
||||
sinon.stub(testInstantiationService, 'createInstance').withArgs(ConnectionStore).returns(connectionStoreMock.object);
|
||||
const connectionManagementService = new ConnectionManagementService(undefined, testInstantiationService, undefined, undefined, undefined, capabilitiesService, undefined, undefined, undefined, new TestErrorDiagnosticsService(), undefined, undefined, undefined, undefined, getBasicExtensionService(), undefined, undefined, undefined);
|
||||
|
||||
// We should expect that non default options are returned when we try to get the nonDefaultOptions string.
|
||||
let result = connectionManagementService.getEditorConnectionProfileTitle(profile, true);
|
||||
let expectedNonDefaultOption = ' (testOption1=test value; testOption2=50)';
|
||||
assert.strictEqual(result, expectedNonDefaultOption, `Profile non default options contained incorrect options`);
|
||||
|
||||
// We should expect that the string contains the connection name and the server info (with all non default options appended).
|
||||
let generatedProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, profile);
|
||||
let profileServerInfo = generatedProfile.serverInfo;
|
||||
result = connectionManagementService.getEditorConnectionProfileTitle(profile);
|
||||
|
||||
assert.strictEqual(result, `${profile.connectionName}: ${profileServerInfo}`, `getEditorConnectionProfileTitle does not return the correct string for ${profile.connectionName}`);
|
||||
|
||||
// We should expect that the string contains only the server info (with non default options) if there is no connection name.
|
||||
profile.connectionName = undefined;
|
||||
|
||||
result = connectionManagementService.getEditorConnectionProfileTitle(profile);
|
||||
|
||||
assert.strictEqual(result, `${profileServerInfo}`, `getEditorConnectionProfileTitle included a connection name when it shouldn't`);
|
||||
|
||||
// We should expect that the string only contains the server info without any non default options if no such options exist.
|
||||
profile.options['testOption1'] = undefined;
|
||||
profile.options['testOption2'] = undefined;
|
||||
profile.options['testOption3'] = undefined;
|
||||
|
||||
result = connectionManagementService.getEditorConnectionProfileTitle(profile);
|
||||
|
||||
assert.notEqual(result, `${profileServerInfo}`, `getEditorConnectionProfileTitle included non default connection options when it shouldn't`);
|
||||
});
|
||||
|
||||
export function createConnectionProfile(id: string, password?: string): ConnectionProfile {
|
||||
const capabilitiesService = new TestCapabilitiesService();
|
||||
return new ConnectionProfile(capabilitiesService, {
|
||||
|
||||
@@ -75,7 +75,6 @@ suite('Insights Dialog Controller Tests', () => {
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
getOptionsKey: () => '',
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined,
|
||||
providerName: '',
|
||||
saveProfile: true,
|
||||
|
||||
@@ -76,8 +76,6 @@ export class TreeUpdateUtils {
|
||||
}
|
||||
const previousTreeInput = tree.getInput();
|
||||
if (treeInput) {
|
||||
let treeArray = TreeUpdateUtils.alterTreeChildrenTitles([treeInput]);
|
||||
treeInput = treeArray[0];
|
||||
await tree.setInput(treeInput);
|
||||
}
|
||||
if (previousTreeInput instanceof Disposable) {
|
||||
@@ -95,29 +93,13 @@ export class TreeUpdateUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls alterConnectionTitles on all levels of the Object Explorer Tree
|
||||
* so that profiles in connection groups can have distinguishing titles too.
|
||||
*/
|
||||
public static alterTreeChildrenTitles(inputGroups: ConnectionProfileGroup[]): ConnectionProfileGroup[] {
|
||||
inputGroups.forEach(group => {
|
||||
group.children = this.alterTreeChildrenTitles(group.children);
|
||||
let connections = group.connections;
|
||||
TreeUpdateUtils.alterConnectionTitles(connections);
|
||||
group.connections = connections;
|
||||
});
|
||||
return inputGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input for the registered servers tree.
|
||||
*/
|
||||
public static async registeredServerUpdate(tree: ITree | AsyncServerTree, connectionManagementService: IConnectionManagementService, elementToSelect?: any): Promise<void> {
|
||||
if (tree instanceof AsyncServerTree) {
|
||||
let treeInput = TreeUpdateUtils.getTreeInput(connectionManagementService);
|
||||
const treeInput = TreeUpdateUtils.getTreeInput(connectionManagementService);
|
||||
if (treeInput) {
|
||||
let treeArray = TreeUpdateUtils.alterTreeChildrenTitles([treeInput]);
|
||||
treeInput = treeArray[0];
|
||||
await tree.setInput(treeInput);
|
||||
}
|
||||
tree.rerender();
|
||||
@@ -146,8 +128,6 @@ export class TreeUpdateUtils {
|
||||
|
||||
let treeInput = TreeUpdateUtils.getTreeInput(connectionManagementService);
|
||||
if (treeInput) {
|
||||
let treeArray = TreeUpdateUtils.alterTreeChildrenTitles([treeInput]);
|
||||
treeInput = treeArray[0];
|
||||
const originalInput = tree.getInput();
|
||||
if (treeInput !== originalInput) {
|
||||
return tree.setInput(treeInput).then(async () => {
|
||||
@@ -390,85 +370,4 @@ export class TreeUpdateUtils {
|
||||
}
|
||||
return connectionProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the connection title to display only the unique properties among profiles.
|
||||
*/
|
||||
private static alterConnectionTitles(inputList: ConnectionProfile[]): void {
|
||||
let profileListMap = new Map<string, number[]>();
|
||||
|
||||
// Map the indices of profiles that share the same connection name.
|
||||
for (let i = 0; i < inputList.length; i++) {
|
||||
// do not add if the profile is still loading as that will result in erroneous entries.
|
||||
if (inputList[i].serverCapabilities && inputList[i].hasLoaded()) {
|
||||
let titleKey = inputList[i].getOriginalTitle();
|
||||
if (profileListMap.has(titleKey)) {
|
||||
let profilesForKey = profileListMap.get(titleKey);
|
||||
profilesForKey.push(i);
|
||||
profileListMap.set(titleKey, profilesForKey);
|
||||
}
|
||||
else {
|
||||
profileListMap.set(titleKey, [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
profileListMap.forEach(function (indexes, titleString) {
|
||||
if (profileListMap.get(titleString)?.length > 1) {
|
||||
let combinedOptions = [];
|
||||
let needSpecial = false;
|
||||
if (titleString === inputList[indexes[0]].connectionName) {
|
||||
// check for potential connections with the same name but technically different connections.
|
||||
let listOfDuplicates = indexes.filter(item => inputList[item].getOptionsKey() !== inputList[indexes[0]].getOptionsKey());
|
||||
if (listOfDuplicates.length > 0) {
|
||||
// if we do find duplicates, we will need to include the special properties.
|
||||
needSpecial = true;
|
||||
}
|
||||
}
|
||||
indexes.forEach((indexValue) => {
|
||||
// Add all possible options across all profiles with the same title to an option list.
|
||||
let valueOptions = inputList[indexValue].getConnectionOptionsList(needSpecial, false);
|
||||
combinedOptions = combinedOptions.concat(valueOptions.filter(item => combinedOptions.indexOf(item) < 0));
|
||||
});
|
||||
|
||||
// Generate list of non default option keys for each profile that shares the same basic connection name.
|
||||
let optionKeyMap = new Map<ConnectionProfile, string[]>();
|
||||
let optionValueOccuranceMap = new Map<string, number>();
|
||||
for (let p = 0; p < indexes.length; p++) {
|
||||
optionKeyMap.set(inputList[indexes[p]], []);
|
||||
for (let i = 0; i < combinedOptions.length; i++) {
|
||||
// See if the option is not default for the inputList profile or is.
|
||||
if (inputList[indexes[p]].getConnectionOptionsList(needSpecial, true).indexOf(combinedOptions[i]) > -1) {
|
||||
let optionValue = inputList[indexes[p]].getOptionValue(combinedOptions[i].name);
|
||||
let currentArray = optionKeyMap.get(inputList[indexes[p]]);
|
||||
let valueString = combinedOptions[i].name + ConnectionProfile.displayNameValueSeparator + optionValue;
|
||||
if (!optionValueOccuranceMap.get(valueString)) {
|
||||
optionValueOccuranceMap.set(valueString, 0);
|
||||
}
|
||||
optionValueOccuranceMap.set(valueString, optionValueOccuranceMap.get(valueString) + 1);
|
||||
currentArray.push(valueString);
|
||||
optionKeyMap.set(inputList[indexes[p]], currentArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out options that are found in ALL the entries with the same basic name.
|
||||
optionValueOccuranceMap.forEach(function (count, optionValue) {
|
||||
optionKeyMap.forEach(function (connOptionValues, profile) {
|
||||
if (count === optionKeyMap.size) {
|
||||
optionKeyMap.set(profile, connOptionValues.filter(value => value !== optionValue));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Generate the final unique connection string for each profile in the list.
|
||||
optionKeyMap.forEach(function (connOptionValues, profile) {
|
||||
let uniqueOptionString = connOptionValues.join(ConnectionProfile.displayIdSeparator);
|
||||
if (uniqueOptionString.length > 0) {
|
||||
profile.title += ' (' + uniqueOptionString + ')';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ suite('AsyncServerTreeDragAndDrop', () => {
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: mssqlProviderName,
|
||||
options: {},
|
||||
|
||||
@@ -41,7 +41,6 @@ suite('SQL Drag And Drop Controller tests', () => {
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: mssqlProviderName,
|
||||
options: {},
|
||||
@@ -60,7 +59,6 @@ suite('SQL Drag And Drop Controller tests', () => {
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: pgsqlProviderName,
|
||||
options: {},
|
||||
|
||||
@@ -1,625 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { TreeUpdateUtils } from 'sql/workbench/services/objectExplorer/browser/treeUpdateUtils';
|
||||
import * as assert from 'assert';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
suite('treeUpdateUtils alterConnection', () => {
|
||||
|
||||
let capabilitiesService: TestCapabilitiesService;
|
||||
|
||||
const testOption1 = {
|
||||
name: 'testOption1',
|
||||
displayName: 'testOption1',
|
||||
description: 'test description',
|
||||
groupName: 'test group name',
|
||||
valueType: 'string',
|
||||
specialValueType: undefined,
|
||||
defaultValue: '',
|
||||
categoryValues: undefined,
|
||||
isIdentity: false,
|
||||
isRequired: false
|
||||
};
|
||||
|
||||
const testOption2 = {
|
||||
name: 'testOption2',
|
||||
displayName: 'testOption2',
|
||||
description: 'test description',
|
||||
groupName: 'test group name',
|
||||
valueType: 'number',
|
||||
specialValueType: undefined,
|
||||
defaultValue: '10',
|
||||
categoryValues: undefined,
|
||||
isIdentity: false,
|
||||
isRequired: false
|
||||
};
|
||||
|
||||
const testOption3 = {
|
||||
name: 'testOption3',
|
||||
displayName: 'testOption3',
|
||||
description: 'test description',
|
||||
groupName: 'test group name',
|
||||
valueType: 'string',
|
||||
specialValueType: undefined,
|
||||
defaultValue: 'default',
|
||||
categoryValues: undefined,
|
||||
isIdentity: false,
|
||||
isRequired: false
|
||||
};
|
||||
|
||||
setup(() => {
|
||||
capabilitiesService = new TestCapabilitiesService();
|
||||
let mainProvider = capabilitiesService.capabilities[mssqlProviderName];
|
||||
let mainProperties = mainProvider.connection;
|
||||
let mainOptions = mainProperties.connectionOptions;
|
||||
|
||||
mainOptions.push((testOption1 as azdata.ConnectionOption));
|
||||
mainOptions.push((testOption2 as azdata.ConnectionOption));
|
||||
mainOptions.push((testOption3 as azdata.ConnectionOption));
|
||||
|
||||
mainProperties.connectionOptions = mainOptions;
|
||||
mainProvider.connection = mainProperties;
|
||||
|
||||
capabilitiesService.capabilities['MSSQL'] = mainProvider;
|
||||
});
|
||||
|
||||
test('Default properties should not be added to the altered title', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption3: 'default', testOption2: '10' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption3: 'nonDefault' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let connectionProfile1 = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2 = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
connectionProfileGroup.addConnections([connectionProfile1, connectionProfile2]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedTitleMap = updatedProfileGroup[0].connections.map(profile => profile.title);
|
||||
|
||||
assert.equal(connectionProfile1.title, updatedTitleMap[0]);
|
||||
assert.equal(connectionProfile1.title + ' (testOption3=nonDefault)', updatedTitleMap[1]);
|
||||
});
|
||||
|
||||
test('Similar connections should have different titles based on all differing properties', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption2: '15', testOption1: 'test string 1', testOption3: 'nonDefault' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption2: '50', testOption1: 'test string 1', testOption3: 'nonDefault' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile3: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption2: '15', testOption1: 'test string 2', testOption3: 'nonDefault' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile4: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption2: '50', testOption1: 'test string 2', testOption3: 'nonDefault' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let defaultProfile: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption3: 'nonDefault' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let defaultConnectionProfile = new ConnectionProfile(capabilitiesService, defaultProfile);
|
||||
let connectionProfile1 = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2 = new ConnectionProfile(capabilitiesService, profile2);
|
||||
let connectionProfile3 = new ConnectionProfile(capabilitiesService, profile3);
|
||||
let connectionProfile4 = new ConnectionProfile(capabilitiesService, profile4);
|
||||
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
let originalTitle = defaultConnectionProfile.title;
|
||||
connectionProfileGroup.addConnections([defaultConnectionProfile, connectionProfile1, connectionProfile2, connectionProfile3, connectionProfile4]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedTitleMap = updatedProfileGroup[0].connections.map(profile => profile.title);
|
||||
|
||||
assert.equal(originalTitle, updatedTitleMap[0]);
|
||||
assert.equal(originalTitle + ' (testOption1=test string 1; testOption2=15)', updatedTitleMap[1]);
|
||||
assert.equal(originalTitle + ' (testOption1=test string 1; testOption2=50)', updatedTitleMap[2]);
|
||||
assert.equal(originalTitle + ' (testOption1=test string 2; testOption2=15)', updatedTitleMap[3]);
|
||||
assert.equal(originalTitle + ' (testOption1=test string 2; testOption2=50)', updatedTitleMap[4]);
|
||||
});
|
||||
|
||||
test('identical connections should have same title if on different levels', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3-1',
|
||||
groupId: 'g3-1',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile3: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3-2',
|
||||
groupId: 'g3-2',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let connectionProfile1 = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2 = new ConnectionProfile(capabilitiesService, profile2);
|
||||
let connectionProfile3 = new ConnectionProfile(capabilitiesService, profile3);
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
let childConnectionProfileGroup = new ConnectionProfileGroup('g3-1', undefined, 'g3-1', undefined, undefined);
|
||||
let grandChildConnectionProfileGroup = new ConnectionProfileGroup('g3-2', undefined, 'g3-2', undefined, undefined);
|
||||
childConnectionProfileGroup.addConnections([connectionProfile2]);
|
||||
connectionProfileGroup.addConnections([connectionProfile1]);
|
||||
grandChildConnectionProfileGroup.addConnections([connectionProfile3]);
|
||||
childConnectionProfileGroup.addGroups([grandChildConnectionProfileGroup]);
|
||||
connectionProfileGroup.addGroups([childConnectionProfileGroup]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedTitleMap = updatedProfileGroup[0].connections.map(profile => profile.title);
|
||||
let updatedChildTitleMap = updatedProfileGroup[0].children[0].connections.map(profile => profile.title);
|
||||
let updatedGrandChildTitleMap = updatedProfileGroup[0].children[0].children[0].connections.map(profile => profile.title);
|
||||
|
||||
// Titles should be the same if they're in different levels.
|
||||
assert.equal(updatedTitleMap[0], updatedChildTitleMap[0]);
|
||||
assert.equal(updatedTitleMap[0], updatedGrandChildTitleMap[0]);
|
||||
assert.equal(updatedChildTitleMap[0], updatedGrandChildTitleMap[0]);
|
||||
});
|
||||
|
||||
test('connections should not affect connections on a different level', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption1: 'value1' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile1a: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption1: 'value2' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3-1',
|
||||
groupId: 'g3-1',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let connectionProfile1 = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile1a = new ConnectionProfile(capabilitiesService, profile1a);
|
||||
let connectionProfile2 = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
let childConnectionProfileGroup = new ConnectionProfileGroup('g3-1', undefined, 'g3-1', undefined, undefined);
|
||||
|
||||
childConnectionProfileGroup.addConnections([connectionProfile2]);
|
||||
connectionProfileGroup.addConnections([connectionProfile1, connectionProfile1a]);
|
||||
connectionProfileGroup.addGroups([childConnectionProfileGroup]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedTitleMap = updatedProfileGroup[0].connections.map(profile => profile.title);
|
||||
let updatedChildTitleMap = updatedProfileGroup[0].children[0].connections.map(profile => profile.title);
|
||||
|
||||
// Titles should be altered for the first group only.
|
||||
assert.equal(updatedChildTitleMap[0] + ' (testOption1=value1)', updatedTitleMap[0]);
|
||||
assert.equal(updatedChildTitleMap[0] + ' (testOption1=value2)', updatedTitleMap[1]);
|
||||
});
|
||||
|
||||
test('non default options should only be appended to the connection with non default options', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption1: 'value1', testOption2: '15' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let connectionProfile1 = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2 = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
|
||||
connectionProfileGroup.addConnections([connectionProfile1, connectionProfile2]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedTitleMap = updatedProfileGroup[0].connections.map(profile => profile.title);
|
||||
|
||||
//Title for second profile should be the same as the first but with non default options appended.
|
||||
assert.equal(updatedTitleMap[0] + ' (testOption1=value1; testOption2=15)', updatedTitleMap[1]);
|
||||
});
|
||||
|
||||
test('identical profiles added into one group and separate groups should have the same options appended', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption1: 'value1', testOption2: '15' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3',
|
||||
groupId: 'g3',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption1: 'value2', testOption2: '30' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let connectionProfile1Base = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2Base = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
|
||||
connectionProfileGroup.addConnections([connectionProfile1Base, connectionProfile2Base]);
|
||||
|
||||
profile1.groupFullName = 'g3-1';
|
||||
profile1.groupId = 'g3-1';
|
||||
profile2.groupFullName = 'g3-1';
|
||||
profile2.groupId = 'g3-1';
|
||||
|
||||
let connectionProfile1Child = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2Child = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let childConnectionProfileGroup = new ConnectionProfileGroup('g3-1', undefined, 'g3-1', undefined, undefined);
|
||||
|
||||
childConnectionProfileGroup.addConnections([connectionProfile1Child, connectionProfile2Child]);
|
||||
|
||||
profile1.groupFullName = 'g3-2';
|
||||
profile1.groupId = 'g3-2';
|
||||
profile2.groupFullName = 'g3-2';
|
||||
profile2.groupId = 'g3-2';
|
||||
|
||||
let connectionProfile1Grandchild = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2Grandchild = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let grandchildConnectionProfileGroup = new ConnectionProfileGroup('g3-2', undefined, 'g3-2', undefined, undefined);
|
||||
|
||||
grandchildConnectionProfileGroup.addConnections([connectionProfile1Grandchild, connectionProfile2Grandchild]);
|
||||
|
||||
childConnectionProfileGroup.addGroups([grandchildConnectionProfileGroup]);
|
||||
|
||||
connectionProfileGroup.addGroups([childConnectionProfileGroup]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedTitleMap = updatedProfileGroup[0].connections.map(profile => profile.title);
|
||||
let updatedChildTitleMap = updatedProfileGroup[0].children[0].connections.map(profile => profile.title);
|
||||
let updatedGrandchildTitleMap = updatedProfileGroup[0].children[0].children[0].connections.map(profile => profile.title);
|
||||
|
||||
//Titles for the same profile in different groups should be identical
|
||||
assert.equal(updatedTitleMap[0], updatedChildTitleMap[0]);
|
||||
assert.equal(updatedTitleMap[0], updatedGrandchildTitleMap[0]);
|
||||
assert.equal(updatedTitleMap[1], updatedChildTitleMap[1]);
|
||||
assert.equal(updatedTitleMap[1], updatedGrandchildTitleMap[1]);
|
||||
});
|
||||
|
||||
test('profiles in adjacent groups on the same layer should not affect titles on nearby groups', async () => {
|
||||
let profile1: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3a',
|
||||
groupId: 'g3a',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let profile2: IConnectionProfile = {
|
||||
serverName: 'server3',
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: '',
|
||||
savePassword: true,
|
||||
groupFullName: 'g3a',
|
||||
groupId: 'g3a',
|
||||
getOptionsKey: undefined!,
|
||||
serverCapabilities: undefined,
|
||||
matches: undefined!,
|
||||
providerName: 'MSSQL',
|
||||
options: { testOption1: 'value2', testOption2: '30' },
|
||||
saveProfile: true,
|
||||
id: undefined!,
|
||||
connectionName: undefined!
|
||||
};
|
||||
|
||||
let connectionProfile1a = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2a = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let connectionProfileGroup = new ConnectionProfileGroup('g3', undefined, 'g3', undefined, undefined);
|
||||
|
||||
let childConnectionProfileGroup1 = new ConnectionProfileGroup('g3a', undefined, 'g3a', undefined, undefined);
|
||||
childConnectionProfileGroup1.addConnections([connectionProfile1a, connectionProfile2a]);
|
||||
|
||||
profile1.groupFullName = 'g3b';
|
||||
profile1.groupId = 'g3b';
|
||||
profile2.groupFullName = 'g3b';
|
||||
profile2.groupId = 'g3b';
|
||||
|
||||
let connectionProfile1b = new ConnectionProfile(capabilitiesService, profile1);
|
||||
let connectionProfile2b = new ConnectionProfile(capabilitiesService, profile2);
|
||||
|
||||
let childConnectionProfileGroup2 = new ConnectionProfileGroup('g3b', undefined, 'g3b', undefined, undefined);
|
||||
|
||||
childConnectionProfileGroup2.addConnections([connectionProfile1b, connectionProfile2b]);
|
||||
|
||||
connectionProfileGroup.addGroups([childConnectionProfileGroup1]);
|
||||
|
||||
connectionProfileGroup.addGroups([childConnectionProfileGroup2]);
|
||||
|
||||
let updatedProfileGroup = TreeUpdateUtils.alterTreeChildrenTitles([connectionProfileGroup]);
|
||||
|
||||
let updatedChildATitleMap = updatedProfileGroup[0].children[0].connections.map(profile => profile.title);
|
||||
let updatedChildBTitleMap = updatedProfileGroup[0].children[1].connections.map(profile => profile.title);
|
||||
|
||||
//Check that titles are generated properly for the first group.
|
||||
assert.equal(updatedChildATitleMap[0] + ' (testOption1=value2; testOption2=30)', updatedChildATitleMap[1]);
|
||||
|
||||
//Titles for the same profile in adjacent groups should be identical
|
||||
assert.equal(updatedChildATitleMap[0], updatedChildBTitleMap[0]);
|
||||
assert.equal(updatedChildATitleMap[1], updatedChildBTitleMap[1]);
|
||||
});
|
||||
});
|
||||
@@ -89,7 +89,6 @@ suite('Firewall rule dialog controller tests', () => {
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
getOptionsKey: () => '',
|
||||
serverCapabilities: undefined,
|
||||
matches: () => false,
|
||||
providerName: mssqlProviderName,
|
||||
options: {},
|
||||
|
||||
Reference in New Issue
Block a user