Files
azuredatastudio/src/sql/platform/capabilities/test/common/testCapabilitiesService.ts
Alex Ma ef8164e5c2 Changed connection title generation to use getConnections (including recent and saved). (#22954)
* remove advanced options for table designer and notebook Actions title (unnecessary in usage context)

* Revert "remove advanced options for table designer and notebook Actions title (unnecessary in usage context)"

This reverts commit e30aee5151319863aebbb4738fb30354c179c2c5.

* added changes based on feedback

* added null check and updated tests

* WIP change to connection title generation

* WIP connection management service update

* fix to connectionManagementService test

* fix editorConnectionTitles

* renamed nondefault to distinguishing options

* use stored connections for options

* removed erroneous connection name set to null

* added title by ID search for title generation

* Add recent connection title

* added fix for stub bug

* added child title options appended

* WIP rework of getEditorTitle

* more work done

* WIP changes for 5-2-2023

* moved server info to generate titles.

* added reworked title generation

* added working active connection title generation and cleanup

* added comments to argument

* remove unnecessary spaces

* added id fix assign

* added fromEditor save

* Revert "Revert new connection string format (#22997)"

This reverts commit 898bb73a34.

* added small fix to tests and exclude empty properties

* made small fixes for tests

* update expected ID

* added support for old password key and removed empty options

* added in authenticationType core property

* fix for whitespace indentation

* added connection save profile to thing

* made some small fixes to connection options

* added small change to connectionDialogService

* added nullcheck for saveProfile

* added negation for connection saveProfile

* remove duplicate editor title generation

* added edit profile handling for titles

* Cleanup serverCapabilities property

* fixed dependency issues

* removed connectionproviderproperties

* added fix for treeupdateutils

* made update to title generation

* added recent connections change

* Revert "Cleanup serverCapabilities property"

This reverts commit 2c7b94f98cabddb34116dcdd83177614a484c026.

* added dashboard text and fix for connection store test

* added group name to end also temporary added dashboard changes based on feedback

* added in new SQL version

* added fix to edit connections

* added clarifying information to title generation

---------

Co-authored-by: Cheena Malhotra <cmalhotra@microsoft.com>
2023-06-21 09:59:58 -07:00

181 lines
5.6 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
import { ICapabilitiesService, ProviderFeatures, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { Event, Emitter } from 'vs/base/common/event';
import { Action } from 'vs/base/common/actions';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/platform/connection/common/interfaces';
import { IDisposable } from 'vs/base/common/lifecycle';
export class TestCapabilitiesService implements ICapabilitiesService {
private pgsqlProviderName = 'PGSQL';
private fakeProviderName = 'FAKE';
public _serviceBrand: undefined;
public capabilities: { [id: string]: ProviderFeatures } = {};
constructor() {
let connectionProvider: azdata.ConnectionOption[] = [
{
name: 'connectionName',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.connectionName,
valueType: ServiceOptionType.string
},
{
name: 'serverName',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.serverName,
valueType: ServiceOptionType.string
},
{
name: 'databaseName',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.databaseName,
valueType: ServiceOptionType.string
},
{
name: 'userName',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.userName,
valueType: ServiceOptionType.string
},
{
name: 'authenticationType',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.authType,
valueType: ServiceOptionType.string
},
{
name: 'password',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.password,
valueType: ServiceOptionType.string
}
];
let mssqlAdvancedOptions: azdata.ConnectionOption[] = [
{
name: 'trustServerCertificate',
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: 'false',
isIdentity: false,
isRequired: false,
specialValueType: undefined!,
valueType: ServiceOptionType.boolean
}
];
let msSQLCapabilities = {
providerId: mssqlProviderName,
displayName: 'MSSQL',
connectionOptions: connectionProvider.concat(mssqlAdvancedOptions),
useFullOptions: true,
};
let pgSQLCapabilities = {
providerId: this.pgsqlProviderName,
displayName: 'PostgreSQL',
connectionOptions: connectionProvider,
};
let fakeCapabilities = {
providerId: this.fakeProviderName,
displayName: 'fakeName',
connectionOptions: connectionProvider,
notebookKernelAlias: 'fakeAlias'
};
this.capabilities[mssqlProviderName] = { connection: msSQLCapabilities };
this.capabilities[this.pgsqlProviderName] = { connection: pgSQLCapabilities };
this.capabilities[this.fakeProviderName] = { connection: fakeCapabilities };
}
registerConnectionProvider(id: string, properties: ConnectionProviderProperties): IDisposable {
throw new Error('Method not implemented.');
}
/**
* Retrieve a list of registered server capabilities
*/
public getCapabilities(provider: string): ProviderFeatures {
return this.capabilities[provider];
}
public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities {
throw new Error('Method not implemented.');
}
public get providers(): { [id: string]: ProviderFeatures } {
return this.capabilities;
}
/**
* Register the capabilities provider and query the provider for its capabilities
*/
public registerProvider(provider: azdata.CapabilitiesProvider): void {
}
// Event Emitters
public get onProviderRegisteredEvent(): Event<azdata.DataProtocolServerCapabilities> {
return Event.None;
}
public isFeatureAvailable(featureName: Action, connectionManagementInfo: ConnectionManagementInfo): boolean {
return true;
}
public onCapabilitiesReady(): Promise<void> {
return Promise.resolve();
}
public fireCapabilitiesRegistered(id: string, features: ProviderFeatures): void {
this._onCapabilitiesRegistered.fire({ id, features });
}
private _onCapabilitiesRegistered = new Emitter<{ id: string; features: ProviderFeatures }>();
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
}