mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
Add AuthenticationType enum to typings (#20699)
* Add AuthenticationType enum to typings * fix * const * Add comments * fix comment * remove unused
This commit is contained in:
@@ -40,6 +40,7 @@ import { ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemet
|
||||
import { ExtHostAzureBlob } from 'sql/workbench/api/common/extHostAzureBlob';
|
||||
import { ExtHostAzureAccount } from 'sql/workbench/api/common/extHostAzureAccount';
|
||||
import { IExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { AuthenticationType } from 'sql/platform/connection/common/constants';
|
||||
|
||||
export interface IAzdataExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof azdata;
|
||||
@@ -106,6 +107,9 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
// namespace: connection
|
||||
const connection: typeof azdata.connection = {
|
||||
// "azdata" API definition
|
||||
|
||||
AuthenticationType: AuthenticationType,
|
||||
|
||||
ConnectionProfile: sqlExtHostTypes.ConnectionProfile,
|
||||
|
||||
getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
|
||||
|
||||
@@ -291,10 +291,10 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution,
|
||||
*/
|
||||
profile.authenticationType =
|
||||
args.authenticationType ? args.authenticationType :
|
||||
args.integrated ? Constants.integrated :
|
||||
args.aad ? Constants.azureMFA :
|
||||
(args.user && args.user.length > 0) ? args.user.includes('@') ? Constants.azureMFA : Constants.sqlLogin :
|
||||
Constants.integrated;
|
||||
args.integrated ? Constants.AuthenticationType.Integrated :
|
||||
args.aad ? Constants.AuthenticationType.AzureMFA :
|
||||
(args.user && args.user.length > 0) ? args.user.includes('@') ? Constants.AuthenticationType.AzureMFA : Constants.AuthenticationType.SqlLogin :
|
||||
Constants.AuthenticationType.Integrated;
|
||||
|
||||
profile.connectionName = '';
|
||||
profile.setOptionValue('applicationName', Constants.applicationName);
|
||||
|
||||
@@ -195,13 +195,13 @@ suite('commandLineService tests', () => {
|
||||
args.server = 'myserver';
|
||||
args.database = 'mydatabase';
|
||||
args.user = 'myuser';
|
||||
args.authenticationType = Constants.sqlLogin;
|
||||
args.authenticationType = Constants.AuthenticationType.SqlLogin;
|
||||
|
||||
connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never());
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.sqlLogin), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -308,7 +308,7 @@ suite('commandLineService tests', () => {
|
||||
connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never());
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.integrated), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.Integrated), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -333,7 +333,7 @@ suite('commandLineService tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'myserver',
|
||||
databaseName: 'mydatabase',
|
||||
authenticationType: Constants.integrated,
|
||||
authenticationType: Constants.AuthenticationType.Integrated,
|
||||
password: undefined,
|
||||
userName: '',
|
||||
groupId: undefined,
|
||||
@@ -351,7 +351,7 @@ suite('commandLineService tests', () => {
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(
|
||||
TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.integrated && p.connectionName === 'Test' && p.id === 'testID'), 'connection', true))
|
||||
TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.Integrated && p.connectionName === 'Test' && p.id === 'testID'), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -373,13 +373,13 @@ suite('commandLineService tests', () => {
|
||||
args.server = 'myserver';
|
||||
args.database = 'mydatabase';
|
||||
args.user = 'myuser';
|
||||
args.authenticationType = Constants.sqlLogin;
|
||||
args.authenticationType = Constants.AuthenticationType.SqlLogin;
|
||||
args._ = ['c:\\dir\\file.sql'];
|
||||
connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never());
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.sqlLogin), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -400,7 +400,7 @@ suite('commandLineService tests', () => {
|
||||
const editorService: TypeMoq.Mock<IEditorService> = TypeMoq.Mock.ofType<IEditorService>(TestEditorService, TypeMoq.MockBehavior.Strict);
|
||||
editorService.setup(e => e.editors).returns(() => [queryInput]);
|
||||
connectionManagementService.setup(c =>
|
||||
c.connect(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.sqlLogin),
|
||||
c.connect(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin),
|
||||
uri.toString(),
|
||||
TypeMoq.It.is<IConnectionCompletionOptions>(i => i.params.input === queryInput && i.params.connectionType === ConnectionType.editor))
|
||||
).verifiable(TypeMoq.Times.once());
|
||||
@@ -447,7 +447,7 @@ suite('commandLineService tests', () => {
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.sqlLogin), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -478,7 +478,7 @@ suite('commandLineService tests', () => {
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||
let originalProfile: IConnectionProfile = undefined;
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.sqlLogin), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin), 'connection', true))
|
||||
.returns((conn) => {
|
||||
originalProfile = conn;
|
||||
return Promise.resolve('unused');
|
||||
@@ -538,7 +538,7 @@ suite('commandLineService tests', () => {
|
||||
connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never());
|
||||
connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce());
|
||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.sqlLogin), 'connection', true))
|
||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver' && p.authenticationType === Constants.AuthenticationType.SqlLogin), 'connection', true))
|
||||
.returns((conn) => {
|
||||
return Promise.resolve('unused');
|
||||
})
|
||||
|
||||
@@ -15,8 +15,6 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { integrated, azureMFA } from 'sql/platform/connection/common/constants';
|
||||
import { AuthenticationType } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { ConnectionViewletPanel } from 'sql/workbench/contrib/dataExplorer/browser/connectionViewletPanel';
|
||||
@@ -31,6 +29,7 @@ workbenchRegistry.registerWorkbenchContribution(ConnectionStatusbarItem, Lifecyc
|
||||
|
||||
import 'sql/workbench/contrib/connection/common/connectionTreeProviderExentionPoint';
|
||||
import { ServerTreeViewView } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { AuthenticationType } from 'sql/platform/connection/common/constants';
|
||||
|
||||
// Connection Dashboard registration
|
||||
|
||||
@@ -124,8 +123,8 @@ CommandsRegistry.registerCommand('azdata.connect',
|
||||
const capabilitiesServices = accessor.get(ICapabilitiesService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
if (args && args.serverName && args.providerName
|
||||
&& (args.authenticationType === integrated
|
||||
|| args.authenticationType === azureMFA
|
||||
&& (args.authenticationType === AuthenticationType.Integrated
|
||||
|| args.authenticationType === AuthenticationType.AzureMFA
|
||||
|| (args.userName && args.password))) {
|
||||
const profile: azdata.IConnectionProfile = {
|
||||
serverName: args.serverName,
|
||||
@@ -178,7 +177,7 @@ configurationRegistry.registerConfiguration({
|
||||
},
|
||||
'sql.defaultAuthenticationType': {
|
||||
'type': 'string',
|
||||
'enum': ['SqlLogin', 'AzureMFA', `AzureMFAAndUser`, 'Integrated'],
|
||||
'enum': [AuthenticationType.SqlLogin, AuthenticationType.AzureMFA, AuthenticationType.AzureMFAAndUser, AuthenticationType.Integrated],
|
||||
'description': localize('sql.defaultAuthenticationTypeDescription', "Default authentication type to use when connecting to Azure resources. "),
|
||||
'enumDescriptions': [
|
||||
localize('sql.defaultAuthenticationType.SqlLogin', "Sql Login"),
|
||||
@@ -186,7 +185,7 @@ configurationRegistry.registerConfiguration({
|
||||
localize('sql.defaultAuthenticationType.AzureMFAAndUser', "Azure Active Directory - Password"),
|
||||
localize('sql.defaultAuthenticationType.Integrated', "Windows Authentication"),
|
||||
],
|
||||
'default': 'AzureMFA'
|
||||
'default': AuthenticationType.AzureMFA
|
||||
},
|
||||
'sql.defaultEngine': {
|
||||
'type': 'string',
|
||||
|
||||
@@ -10,7 +10,7 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
|
||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { AuthenticationType, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
|
||||
suite('Notebook Contexts', function (): void {
|
||||
const defaultContext = NotebookContexts.DefaultContext;
|
||||
@@ -23,7 +23,7 @@ suite('Notebook Contexts', function (): void {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
|
||||
@@ -33,7 +33,7 @@ import { TestConnectionManagementService } from 'sql/platform/connection/test/co
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { NotebookEditorContentLoader } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
import { SessionManager } from 'sql/workbench/contrib/notebook/test/emptySessionClasses';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { AuthenticationType, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { uriPrefixes } from 'sql/platform/connection/common/utils';
|
||||
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
||||
@@ -1071,7 +1071,7 @@ suite('notebook model', function (): void {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
@@ -1091,7 +1091,7 @@ suite('notebook model', function (): void {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
|
||||
@@ -25,7 +25,7 @@ import { ObjectExplorerActionsContext } from 'sql/workbench/services/objectExplo
|
||||
import { IConnectionResult, IConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { TreeSelectionHandler } from 'sql/workbench/services/objectExplorer/browser/treeSelectionHandler';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { UNSAVED_GROUP_ID, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { UNSAVED_GROUP_ID, mssqlProviderName, AuthenticationType } from 'sql/platform/connection/common/constants';
|
||||
import { $ } from 'vs/base/browser/dom';
|
||||
import { OEManageConnectionAction } from 'sql/workbench/contrib/dashboard/browser/dashboardActions';
|
||||
import { IViewsService, IView, ViewContainerLocation, ViewContainer, IViewPaneContainer } from 'vs/workbench/common/views';
|
||||
@@ -96,7 +96,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
@@ -183,7 +183,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
@@ -228,7 +228,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
@@ -304,7 +304,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
@@ -349,7 +349,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
@@ -746,7 +746,7 @@ suite('SQL Connection Tree Action tests', () => {
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: AuthenticationType.Integrated,
|
||||
password: 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
|
||||
@@ -23,7 +23,7 @@ import * as DOM from 'vs/base/browser/dom';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { OS, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ConnectionWidget, AuthenticationType } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
import { ConnectionWidget } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
|
||||
@@ -33,8 +33,8 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess
|
||||
export class CmsConnectionWidget extends ConnectionWidget {
|
||||
|
||||
private _serverDescriptionInputBox: InputBox;
|
||||
protected _authTypeMap: { [providerName: string]: AuthenticationType[] } = {
|
||||
[Constants.cmsProviderName]: [AuthenticationType.SqlLogin, AuthenticationType.Integrated]
|
||||
protected _authTypeMap: { [providerName: string]: Constants.AuthenticationType[] } = {
|
||||
[Constants.cmsProviderName]: [Constants.AuthenticationType.SqlLogin, Constants.AuthenticationType.Integrated]
|
||||
};
|
||||
|
||||
constructor(options: azdata.ConnectionOption[],
|
||||
@@ -92,17 +92,17 @@ export class CmsConnectionWidget extends ConnectionWidget {
|
||||
// True when opening a CMS dialog to add a registered server
|
||||
if (authTypeChanged) {
|
||||
// Registered Servers only support Integrated Auth
|
||||
newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name === AuthenticationType.Integrated);
|
||||
newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name === Constants.AuthenticationType.Integrated);
|
||||
this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName));
|
||||
authTypeOption.defaultValue = AuthenticationType.Integrated;
|
||||
authTypeOption.defaultValue = Constants.AuthenticationType.Integrated;
|
||||
} else {
|
||||
// CMS supports all auth types
|
||||
newAuthTypes = authTypeOption.categoryValues;
|
||||
this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName));
|
||||
if (OS === OperatingSystem.Windows) {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.Integrated);
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(Constants.AuthenticationType.Integrated);
|
||||
} else {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.SqlLogin);
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(Constants.AuthenticationType.SqlLogin);
|
||||
}
|
||||
}
|
||||
this._authTypeSelectBox.selectWithOptionName(authTypeOption.defaultValue);
|
||||
|
||||
@@ -158,7 +158,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
defaultAuthenticationType = WorkbenchUtils.getSqlConfigValue<string>(this._configurationService, Constants.defaultAuthenticationType);
|
||||
}
|
||||
|
||||
return defaultAuthenticationType || Constants.sqlLogin; // as a fallback, default to sql login if the value from settings is not available
|
||||
return defaultAuthenticationType || Constants.AuthenticationType.SqlLogin; // as a fallback, default to sql login if the value from settings is not available
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -865,9 +865,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
* @param connection The connection to fill in or update
|
||||
*/
|
||||
private async fillInOrClearToken(connection: interfaces.IConnectionProfile): Promise<boolean> {
|
||||
if (connection.authenticationType !== Constants.azureMFA
|
||||
&& connection.authenticationType !== Constants.azureMFAAndUser
|
||||
&& connection.authenticationType !== Constants.dstsAuth) {
|
||||
if (connection.authenticationType !== Constants.AuthenticationType.AzureMFA
|
||||
&& connection.authenticationType !== Constants.AuthenticationType.AzureMFAAndUser
|
||||
&& connection.authenticationType !== Constants.AuthenticationType.DSTSAuth) {
|
||||
connection.options['azureAccountToken'] = undefined;
|
||||
return true;
|
||||
}
|
||||
@@ -875,7 +875,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
let azureResource = this.getAzureResourceForConnection(connection);
|
||||
const accounts = await this._accountManagementService.getAccounts();
|
||||
|
||||
if (connection.authenticationType === Constants.dstsAuth) {
|
||||
if (connection.authenticationType === Constants.AuthenticationType.DSTSAuth) {
|
||||
let dstsAccounts = accounts.filter(a => a.key.providerId.startsWith('dstsAuth'));
|
||||
if (dstsAccounts.length <= 0) {
|
||||
connection.options['azureAccountToken'] = undefined;
|
||||
@@ -894,7 +894,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
|
||||
const azureAccounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
if (azureAccounts && azureAccounts.length > 0) {
|
||||
let accountId = (connection.authenticationType === Constants.azureMFA || connection.authenticationType === Constants.azureMFAAndUser) ? connection.azureAccount : connection.userName;
|
||||
let accountId = (connection.authenticationType === Constants.AuthenticationType.AzureMFA || connection.authenticationType === Constants.AuthenticationType.AzureMFAAndUser) ? connection.azureAccount : connection.userName;
|
||||
let account = azureAccounts.find(account => account.key.accountId === accountId);
|
||||
if (account) {
|
||||
this._logService.debug(`Getting security token for Azure account ${account.key.accountId}`);
|
||||
|
||||
@@ -35,15 +35,7 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { ConnectionStringOptions } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
|
||||
export enum AuthenticationType {
|
||||
SqlLogin = 'SqlLogin',
|
||||
Integrated = 'Integrated',
|
||||
AzureMFA = 'AzureMFA',
|
||||
AzureMFAAndUser = 'AzureMFAAndUser',
|
||||
dSTSAuth = 'dstsAuth',
|
||||
None = 'None' // Kusto supports no authentication
|
||||
}
|
||||
import { AuthenticationType } from 'sql/platform/connection/common/constants';
|
||||
|
||||
const ConnectionStringText = localize('connectionWidget.connectionString', "Connection string");
|
||||
|
||||
@@ -83,7 +75,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
protected _databaseNameInputBox: Dropdown;
|
||||
protected _advancedButton: Button;
|
||||
private static readonly _authTypes: AuthenticationType[] =
|
||||
[AuthenticationType.AzureMFA, AuthenticationType.AzureMFAAndUser, AuthenticationType.Integrated, AuthenticationType.SqlLogin, AuthenticationType.dSTSAuth, AuthenticationType.None];
|
||||
[AuthenticationType.AzureMFA, AuthenticationType.AzureMFAAndUser, AuthenticationType.Integrated, AuthenticationType.SqlLogin, AuthenticationType.DSTSAuth, AuthenticationType.None];
|
||||
private static readonly _osByName = {
|
||||
Windows: OperatingSystem.Windows,
|
||||
Macintosh: OperatingSystem.Macintosh,
|
||||
@@ -528,7 +520,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
// Immediately show/hide appropriate elements though so user gets immediate feedback while we load accounts
|
||||
this._tableContainer.classList.remove('hide-username');
|
||||
this._tableContainer.classList.remove('hide-azure-accounts');
|
||||
} else if (currentAuthType === AuthenticationType.dSTSAuth) {
|
||||
} else if (currentAuthType === AuthenticationType.DSTSAuth) {
|
||||
this._accountManagementService.getAccountsForProvider('dstsAuth').then(accounts => {
|
||||
if (accounts && accounts.length > 0) {
|
||||
accounts[0].key.providerArgs = {
|
||||
@@ -891,7 +883,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
if (this.authenticationType === AuthenticationType.AzureMFAAndUser || this.authenticationType === AuthenticationType.AzureMFA) {
|
||||
return this._azureAccountDropdown.value;
|
||||
}
|
||||
if (this.authenticationType === AuthenticationType.dSTSAuth) {
|
||||
if (this.authenticationType === AuthenticationType.DSTSAuth) {
|
||||
return this._token;
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@@ -61,7 +61,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
databaseName: 'database',
|
||||
userName: 'user',
|
||||
password: 'password',
|
||||
authenticationType: 'integrated',
|
||||
authenticationType: Constants.AuthenticationType.Integrated,
|
||||
savePassword: true,
|
||||
groupFullName: 'g2/g2-2',
|
||||
groupId: 'group id',
|
||||
@@ -121,7 +121,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
c => c.serverName === connectionProfileWithEmptyUnsavedPassword.serverName))).returns(
|
||||
() => Promise.resolve({ profile: connectionProfileWithEmptyUnsavedPassword, savedCred: false }));
|
||||
connectionStore.setup(x => x.isPasswordRequired(TypeMoq.It.isAny())).returns((profile) => {
|
||||
if (profile.authenticationType === Constants.azureMFA) {
|
||||
if (profile.authenticationType === Constants.AuthenticationType.AzureMFA) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1649,7 +1649,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
test('addSavedPassword fills in Azure access tokens for Azure accounts', async () => {
|
||||
// Set up a connection profile that uses Azure
|
||||
let azureConnectionProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile);
|
||||
azureConnectionProfile.authenticationType = 'AzureMFA';
|
||||
azureConnectionProfile.authenticationType = Constants.AuthenticationType.AzureMFA;
|
||||
let username = 'testuser@microsoft.com';
|
||||
azureConnectionProfile.azureAccount = username;
|
||||
let servername = 'test-database.database.windows.net';
|
||||
@@ -1688,7 +1688,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
token: testToken,
|
||||
tokenType: 'Bearer'
|
||||
}));
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is(profile => profile.authenticationType === 'AzureMFA'))).returns(profile => Promise.resolve({
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is(profile => profile.authenticationType === Constants.AuthenticationType.AzureMFA))).returns(profile => Promise.resolve({
|
||||
profile: profile,
|
||||
savedCred: false
|
||||
}));
|
||||
@@ -1705,7 +1705,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
const uri: string = 'Editor Uri';
|
||||
// Set up a connection profile that uses Azure
|
||||
const azureConnectionProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile);
|
||||
azureConnectionProfile.authenticationType = 'AzureMFA';
|
||||
azureConnectionProfile.authenticationType = Constants.AuthenticationType.AzureMFA;
|
||||
const username = 'testuser@microsoft.com';
|
||||
azureConnectionProfile.azureAccount = username;
|
||||
const servername = 'test-database.database.windows.net';
|
||||
@@ -1747,7 +1747,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is(profile => profile.authenticationType === 'AzureMFA'))).returns(profile => Promise.resolve({
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is(profile => profile.authenticationType === Constants.AuthenticationType.AzureMFA))).returns(profile => Promise.resolve({
|
||||
profile: profile,
|
||||
savedCred: false
|
||||
}));
|
||||
@@ -1776,7 +1776,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
test('addSavedPassword fills in Azure access token for selected tenant', async () => {
|
||||
// Set up a connection profile that uses Azure
|
||||
let azureConnectionProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile);
|
||||
azureConnectionProfile.authenticationType = 'AzureMFA';
|
||||
azureConnectionProfile.authenticationType = Constants.AuthenticationType.AzureMFA;
|
||||
let username = 'testuser@microsoft.com';
|
||||
azureConnectionProfile.azureAccount = username;
|
||||
let servername = 'test-database.database.windows.net';
|
||||
@@ -1814,7 +1814,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
|
||||
let returnedToken = { token: 'testToken', tokenType: 'Bearer' };
|
||||
accountManagementService.setup(x => x.getAccountSecurityToken(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(returnedToken));
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is(profile => profile.authenticationType === 'AzureMFA'))).returns(profile => Promise.resolve({
|
||||
connectionStore.setup(x => x.addSavedPassword(TypeMoq.It.is(profile => profile.authenticationType === Constants.AuthenticationType.AzureMFA))).returns(profile => Promise.resolve({
|
||||
profile: profile,
|
||||
savedCred: false
|
||||
}));
|
||||
@@ -1918,7 +1918,7 @@ export function createConnectionProfile(id: string, password?: string): Connecti
|
||||
groupFullName: 'testGroup',
|
||||
serverName: 'testServerName',
|
||||
databaseName: 'testDatabaseName',
|
||||
authenticationType: Constants.integrated,
|
||||
authenticationType: Constants.AuthenticationType.Integrated,
|
||||
password: password ?? 'test',
|
||||
userName: 'testUsername',
|
||||
groupId: undefined,
|
||||
|
||||
Reference in New Issue
Block a user