From 5b3fbaa5ff57dd8473170bc73bc0c157418b25d3 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 20 Aug 2021 10:28:33 -0700 Subject: [PATCH] azdata.Account -> AzureAccount (#16842) --- .../account-provider/azureAccountProvider.ts | 22 +++++++------- .../src/azureResource/azure-resource.d.ts | 5 ++-- .../azurecore/src/azureResource/interfaces.ts | 8 ++--- .../azuremonitorTreeDataProvider.ts | 5 ++-- .../providers/database/databaseService.ts | 4 +-- .../database/databaseTreeDataProvider.ts | 5 ++-- .../databaseServerTreeDataProvider.ts | 5 ++-- .../providers/kusto/kustoTreeDataProvider.ts | 5 ++-- .../postgresServerTreeDataProvider.ts | 5 ++-- .../postgresServerTreeDataProvider.ts | 5 ++-- .../providers/resourceTreeDataProviderBase.ts | 5 ++-- .../sqlInstanceTreeDataProvider.ts | 5 ++-- .../sqlInstanceArcTreeDataProvider.ts | 5 ++-- .../src/azureResource/resourceService.ts | 4 +-- .../services/subscriptionFilterService.ts | 7 ++--- .../tree/connectionDialogTreeProvider.ts | 3 +- .../tree/subscriptionTreeNode.ts | 5 ++-- .../src/azureResource/tree/treeProvider.ts | 3 +- .../azurecore/src/azureResource/utils.ts | 22 +++++++------- extensions/azurecore/src/azurecore.d.ts | 30 +++++++++---------- extensions/azurecore/src/extension.ts | 30 +++++++++---------- .../tree/accountTreeNode.test.ts | 14 +++++++-- .../tree/subscriptionTreeNode.test.ts | 4 +-- .../azureResource/tree/treeProvider.test.ts | 5 ++-- 24 files changed, 115 insertions(+), 96 deletions(-) diff --git a/extensions/azurecore/src/account-provider/azureAccountProvider.ts b/extensions/azurecore/src/account-provider/azureAccountProvider.ts index 654ea29eeb..66a17d3991 100644 --- a/extensions/azurecore/src/account-provider/azureAccountProvider.ts +++ b/extensions/azurecore/src/account-provider/azureAccountProvider.ts @@ -69,7 +69,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp } } - private getAuthMethod(account?: azdata.Account): AzureAuth { + private getAuthMethod(account?: AzureAccount): AzureAuth { if (this.authMappings.size === 1) { return this.authMappings.values().next().value; } @@ -82,12 +82,12 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp } } - initialize(storedAccounts: azdata.Account[]): Thenable { + initialize(storedAccounts: AzureAccount[]): Thenable { return this._initialize(storedAccounts); } - private async _initialize(storedAccounts: azdata.Account[]): Promise { - const accounts: azdata.Account[] = []; + private async _initialize(storedAccounts: AzureAccount[]): Promise { + const accounts: AzureAccount[] = []; console.log(`Initializing stored accounts ${JSON.stringify(accounts)}`); for (let account of storedAccounts) { const azureAuth = this.getAuthMethod(account); @@ -103,21 +103,21 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp } - getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable { + getSecurityToken(account: AzureAccount, resource: azdata.AzureResource): Thenable { return this._getSecurityToken(account, resource); } - getAccountSecurityToken(account: azdata.Account, tenantId: string, resource: azdata.AzureResource): Thenable { + getAccountSecurityToken(account: AzureAccount, tenantId: string, resource: azdata.AzureResource): Thenable { return this._getAccountSecurityToken(account, tenantId, resource); } - private async _getAccountSecurityToken(account: azdata.Account, tenantId: string, resource: azdata.AzureResource): Promise { + private async _getAccountSecurityToken(account: AzureAccount, tenantId: string, resource: azdata.AzureResource): Promise { await this.initCompletePromise; const azureAuth = this.getAuthMethod(undefined); return azureAuth?.getAccountSecurityToken(account, tenantId, resource); } - private async _getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Promise { + private async _getSecurityToken(account: AzureAccount, resource: azdata.AzureResource): Promise { vscode.window.showInformationMessage(localize('azure.deprecatedGetSecurityToken', "A call was made to azdata.accounts.getSecurityToken, this method is deprecated and will be removed in future releases. Please use getAccountSecurityToken instead.")); const azureAccount = account as AzureAccount; const response: MultiTenantTokenResponse = {}; @@ -128,11 +128,11 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp return response; } - prompt(): Thenable { + prompt(): Thenable { return this._prompt(); } - private async _prompt(): Promise { + private async _prompt(): Promise { const noAuthSelected = localize('azure.NoAuthMethod.Selected', "No Azure auth method selected. You must select what method of authentication you want to use."); const noAuthAvailable = localize('azure.NoAuthMethod.Available', "No Azure auth method available. You must enable the auth methods in ADS configuration."); @@ -170,7 +170,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp return pick.azureAuth.startLogin(); } - refresh(account: azdata.Account): Thenable { + refresh(account: AzureAccount): Thenable { return this.prompt(); } diff --git a/extensions/azurecore/src/azureResource/azure-resource.d.ts b/extensions/azurecore/src/azureResource/azure-resource.d.ts index 39536a881a..26017ce20c 100644 --- a/extensions/azurecore/src/azureResource/azure-resource.d.ts +++ b/extensions/azurecore/src/azureResource/azure-resource.d.ts @@ -5,8 +5,9 @@ declare module 'azureResource' { import { TreeDataProvider } from 'vscode'; - import { DataProvider, Account, TreeItem } from 'azdata'; + import { DataProvider, TreeItem } from 'azdata'; import { BlobItem } from '@azure/storage-blob'; + import { AzureAccount } from 'azurecore'; export namespace azureResource { @@ -38,7 +39,7 @@ declare module 'azureResource' { } export interface IAzureResourceNode { - readonly account: Account; + readonly account: AzureAccount; readonly subscription: AzureResourceSubscription; readonly tenantId: string; readonly treeItem: TreeItem; diff --git a/extensions/azurecore/src/azureResource/interfaces.ts b/extensions/azurecore/src/azureResource/interfaces.ts index d5ab3e3044..3a9cb68df0 100644 --- a/extensions/azurecore/src/azureResource/interfaces.ts +++ b/extensions/azurecore/src/azureResource/interfaces.ts @@ -5,8 +5,6 @@ import * as msRest from '@azure/ms-rest-js'; -import { Account } from 'azdata'; - import { azureResource } from 'azureResource'; import { AzureAccount, Tenant } from 'azurecore'; @@ -22,8 +20,8 @@ export interface IAzureResourceSubscriptionService { } export interface IAzureResourceSubscriptionFilterService { - getSelectedSubscriptions(account: Account): Promise; - saveSelectedSubscriptions(account: Account, selectedSubscriptions: azureResource.AzureResourceSubscription[]): Promise; + getSelectedSubscriptions(account: AzureAccount): Promise; + saveSelectedSubscriptions(account: AzureAccount, selectedSubscriptions: azureResource.AzureResourceSubscription[]): Promise; } export interface IAzureTerminalService { @@ -45,5 +43,5 @@ export interface IAzureResourceNodeWithProviderId { } export interface IAzureResourceService { - getResources(subscriptions: azureResource.AzureResourceSubscription[], credential: msRest.ServiceClientCredentials, account: Account): Promise; + getResources(subscriptions: azureResource.AzureResourceSubscription[], credential: msRest.ServiceClientCredentials, account: AzureAccount): Promise; } diff --git a/extensions/azurecore/src/azureResource/providers/azuremonitor/azuremonitorTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/azuremonitor/azuremonitorTreeDataProvider.ts index 9d6c06e0d2..8b04ffa766 100644 --- a/extensions/azurecore/src/azureResource/providers/azuremonitor/azuremonitorTreeDataProvider.ts +++ b/extensions/azurecore/src/azureResource/providers/azuremonitor/azuremonitorTreeDataProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ExtensionNodeType, TreeItem, Account } from 'azdata'; +import { ExtensionNodeType, TreeItem } from 'azdata'; import { TreeItemCollapsibleState, ExtensionContext } from 'vscode'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -13,6 +13,7 @@ import { generateGuid } from '../../utils'; import { IAzureResourceService } from '../../interfaces'; import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; import { azureResource } from 'azureResource'; +import { AzureAccount } from 'azurecore'; export class AzureMonitorTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.AzureMonitorContainer'; @@ -26,7 +27,7 @@ export class AzureMonitorTreeDataProvider extends ResourceTreeDataProviderBase { - public async getResources(subscriptions: azureResource.AzureResourceSubscription[], credential: ServiceClientCredentials, account: Account): Promise { + public async getResources(subscriptions: azureResource.AzureResourceSubscription[], credential: ServiceClientCredentials, account: AzureAccount): Promise { const databases: azureResource.AzureResourceDatabase[] = []; const resourceClient = new ResourceGraphClient(credential, { baseUri: account.properties.providerSettings.settings.armResource.endpoint }); diff --git a/extensions/azurecore/src/azureResource/providers/database/databaseTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/database/databaseTreeDataProvider.ts index ed1b176a9d..303ed46c70 100644 --- a/extensions/azurecore/src/azureResource/providers/database/databaseTreeDataProvider.ts +++ b/extensions/azurecore/src/azureResource/providers/database/databaseTreeDataProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TreeItem, ExtensionNodeType, Account } from 'azdata'; +import { TreeItem, ExtensionNodeType } from 'azdata'; import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -13,6 +13,7 @@ import { AzureResourceItemType } from '../../../azureResource/constants'; import { generateGuid } from '../../utils'; import { IAzureResourceService } from '../../interfaces'; import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; +import { AzureAccount } from 'azurecore'; export class AzureResourceDatabaseTreeDataProvider extends ResourceTreeDataProviderBase { @@ -25,7 +26,7 @@ export class AzureResourceDatabaseTreeDataProvider extends ResourceTreeDataProvi ) { super(databaseService); } - protected getTreeItemForResource(database: azureResource.AzureResourceDatabase, account: Account): TreeItem { + protected getTreeItemForResource(database: azureResource.AzureResourceDatabase, account: AzureAccount): TreeItem { return { id: `databaseServer_${database.serverFullName}.database_${database.name}`, label: this.browseConnectionMode ? `${database.serverName}/${database.name} (${AzureResourceDatabaseTreeDataProvider.containerLabel}, ${database.subscription.name})` : `${database.name} (${database.serverName})`, diff --git a/extensions/azurecore/src/azureResource/providers/databaseServer/databaseServerTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/databaseServer/databaseServerTreeDataProvider.ts index 2446f46729..7e20309c85 100644 --- a/extensions/azurecore/src/azureResource/providers/databaseServer/databaseServerTreeDataProvider.ts +++ b/extensions/azurecore/src/azureResource/providers/databaseServer/databaseServerTreeDataProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ExtensionNodeType, TreeItem, Account } from 'azdata'; +import { ExtensionNodeType, TreeItem } from 'azdata'; import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -13,6 +13,7 @@ import { generateGuid } from '../../utils'; import { IAzureResourceService } from '../../interfaces'; import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; import { azureResource } from 'azureResource'; +import { AzureAccount } from 'azurecore'; export class AzureResourceDatabaseServerTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.databaseServer.treeDataProvider.databaseServerContainer'; @@ -26,7 +27,7 @@ export class AzureResourceDatabaseServerTreeDataProvider extends ResourceTreeDat } - protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: Account): TreeItem { + protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: AzureAccount): TreeItem { return { id: `databaseServer_${databaseServer.id ? databaseServer.id : databaseServer.name}`, label: this.browseConnectionMode ? `${databaseServer.name} (${AzureResourceDatabaseServerTreeDataProvider.containerLabel}, ${databaseServer.subscription.name})` : databaseServer.name, diff --git a/extensions/azurecore/src/azureResource/providers/kusto/kustoTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/kusto/kustoTreeDataProvider.ts index 6b9c4df007..bdf10a3fa7 100644 --- a/extensions/azurecore/src/azureResource/providers/kusto/kustoTreeDataProvider.ts +++ b/extensions/azurecore/src/azureResource/providers/kusto/kustoTreeDataProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ExtensionNodeType, TreeItem, Account } from 'azdata'; +import { ExtensionNodeType, TreeItem } from 'azdata'; import { TreeItemCollapsibleState, ExtensionContext } from 'vscode'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -13,6 +13,7 @@ import { generateGuid } from '../../utils'; import { IAzureResourceService } from '../../interfaces'; import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; import { azureResource } from 'azureResource'; +import { AzureAccount } from 'azurecore'; export class KustoTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.KustoContainer'; @@ -26,7 +27,7 @@ export class KustoTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.postgresArcServer.treeDataProvider.postgresServerContainer'; @@ -26,7 +27,7 @@ export class PostgresServerArcTreeDataProvider extends ResourceTreeDataProviderB } - protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: Account): TreeItem { + protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: AzureAccount): TreeItem { return { id: `databaseServer_${databaseServer.id ? databaseServer.id : databaseServer.name}`, label: this.browseConnectionMode ? `${databaseServer.name} (${PostgresServerArcTreeDataProvider.containerLabel}, ${databaseServer.subscription.name})` : databaseServer.name, diff --git a/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerTreeDataProvider.ts index add69b40d7..59b394ab6a 100644 --- a/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerTreeDataProvider.ts +++ b/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerTreeDataProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ExtensionNodeType, TreeItem, Account } from 'azdata'; +import { ExtensionNodeType, TreeItem } from 'azdata'; import { TreeItemCollapsibleState, ExtensionContext } from 'vscode'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -13,6 +13,7 @@ import { generateGuid } from '../../utils'; import { IAzureResourceService } from '../../interfaces'; import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; import { azureResource } from 'azureResource'; +import { AzureAccount } from 'azurecore'; export class PostgresServerTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.databaseServer.treeDataProvider.postgresServerContainer'; @@ -26,7 +27,7 @@ export class PostgresServerTreeDataProvider extends ResourceTreeDataProviderBase } - protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: Account): TreeItem { + protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: AzureAccount): TreeItem { return { id: `databaseServer_${databaseServer.id ? databaseServer.id : databaseServer.name}`, label: this.browseConnectionMode ? `${databaseServer.name} (${PostgresServerTreeDataProvider.containerLabel}, ${databaseServer.subscription.name})` : databaseServer.name, diff --git a/extensions/azurecore/src/azureResource/providers/resourceTreeDataProviderBase.ts b/extensions/azurecore/src/azureResource/providers/resourceTreeDataProviderBase.ts index 9f469615b8..ef3ded3c53 100644 --- a/extensions/azurecore/src/azureResource/providers/resourceTreeDataProviderBase.ts +++ b/extensions/azurecore/src/azureResource/providers/resourceTreeDataProviderBase.ts @@ -10,6 +10,7 @@ import { azureResource } from 'azureResource'; import { IAzureResourceService } from '../interfaces'; import { AzureResourceErrorMessageUtil } from '../utils'; import { ResourceGraphClient } from '@azure/arm-resourcegraph'; +import { AzureAccount } from 'azurecore'; export abstract class ResourceTreeDataProviderBase implements azureResource.IAzureResourceTreeDataProvider { public browseConnectionMode: boolean = false; @@ -49,7 +50,7 @@ export abstract class ResourceTreeDataProviderBase { + public async getResources(subscriptions: azureResource.AzureResourceSubscription[], credential: msRest.ServiceClientCredentials, account: AzureAccount): Promise { const convertedResources: U[] = []; const resourceClient = new ResourceGraphClient(credential, { baseUri: account.properties.providerSettings.settings.armResource.endpoint }); const graphResources = await queryGraphResources(resourceClient, subscriptions, this.query); diff --git a/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceTreeDataProvider.ts b/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceTreeDataProvider.ts index 5661c7549b..841591350d 100644 --- a/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceTreeDataProvider.ts +++ b/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceTreeDataProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ExtensionNodeType, TreeItem, Account } from 'azdata'; +import { ExtensionNodeType, TreeItem } from 'azdata'; import { TreeItemCollapsibleState, ExtensionContext } from 'vscode'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -13,6 +13,7 @@ import { generateGuid } from '../../utils'; import { IAzureResourceService } from '../../interfaces'; import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase'; import { azureResource } from 'azureResource'; +import { AzureAccount } from 'azurecore'; export class SqlInstanceTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.sqlInstanceContainer'; @@ -26,7 +27,7 @@ export class SqlInstanceTreeDataProvider extends ResourceTreeDataProviderBase { private static readonly containerId = 'azure.resource.providers.sqlInstanceArcContainer'; @@ -26,7 +27,7 @@ export class SqlInstanceArcTreeDataProvider extends ResourceTreeDataProviderBase } - protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: Account): TreeItem { + protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: AzureAccount): TreeItem { return { id: `sqlInstance_${databaseServer.id ? databaseServer.id : databaseServer.name}`, label: this.browseConnectionMode ? `${databaseServer.name} (${SqlInstanceArcTreeDataProvider.containerLabel}, ${databaseServer.subscription.name})` : databaseServer.name, diff --git a/extensions/azurecore/src/azureResource/resourceService.ts b/extensions/azurecore/src/azureResource/resourceService.ts index fdae5370d6..fdc0d07b49 100644 --- a/extensions/azurecore/src/azureResource/resourceService.ts +++ b/extensions/azurecore/src/azureResource/resourceService.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { extensions, TreeItem } from 'vscode'; -import { Account } from 'azdata'; import { azureResource } from 'azureResource'; import { IAzureResourceNodeWithProviderId } from './interfaces'; +import { AzureAccount } from 'azurecore'; export class AzureResourceService { private _areResourceProvidersLoaded: boolean = false; @@ -33,7 +33,7 @@ export class AzureResourceService { this._areResourceProvidersLoaded = false; } - public async getRootChildren(resourceProviderId: string, account: Account, subscription: azureResource.AzureResourceSubscription, tenatId: string): Promise { + public async getRootChildren(resourceProviderId: string, account: AzureAccount, subscription: azureResource.AzureResourceSubscription, tenatId: string): Promise { await this.ensureResourceProvidersRegistered(); if (!(resourceProviderId in this._resourceProviders)) { diff --git a/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts b/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts index c5ad18120e..680f3ab646 100644 --- a/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts +++ b/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Account } from 'azdata'; - +import { AzureAccount } from 'azurecore'; import { azureResource } from 'azureResource'; import { IAzureResourceSubscriptionFilterService, IAzureResourceCacheService } from '../interfaces'; @@ -21,7 +20,7 @@ export class AzureResourceSubscriptionFilterService implements IAzureResourceSub this._cacheKey = this._cacheService.generateKey('selectedSubscriptions'); } - public async getSelectedSubscriptions(account: Account): Promise { + public async getSelectedSubscriptions(account: AzureAccount): Promise { let selectedSubscriptions: azureResource.AzureResourceSubscription[] = []; const cache = this._cacheService.get(this._cacheKey); @@ -32,7 +31,7 @@ export class AzureResourceSubscriptionFilterService implements IAzureResourceSub return selectedSubscriptions; } - public async saveSelectedSubscriptions(account: Account, selectedSubscriptions: azureResource.AzureResourceSubscription[]): Promise { + public async saveSelectedSubscriptions(account: AzureAccount, selectedSubscriptions: azureResource.AzureResourceSubscription[]): Promise { let selectedSubscriptionsCache: { [accountId: string]: azureResource.AzureResourceSubscription[] } = {}; const cache = this._cacheService.get(this._cacheKey); diff --git a/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts b/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts index 09014c93cd..5bf8636614 100644 --- a/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts +++ b/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts @@ -17,11 +17,12 @@ import { AzureResourceErrorMessageUtil, equals } from '../utils'; import { IAzureResourceTreeChangeHandler } from './treeChangeHandler'; import { FlatAccountTreeNode } from './flatAccountTreeNode'; import { Logger } from '../../utils/Logger'; +import { AzureAccount } from 'azurecore'; export class ConnectionDialogTreeProvider implements vscode.TreeDataProvider, IAzureResourceTreeChangeHandler { public isSystemInitialized: boolean = false; - private accounts: azdata.Account[]; + private accounts: AzureAccount[]; private _onDidChangeTreeData = new vscode.EventEmitter(); private loadingAccountsPromise: Promise; diff --git a/extensions/azurecore/src/azureResource/tree/subscriptionTreeNode.ts b/extensions/azurecore/src/azureResource/tree/subscriptionTreeNode.ts index 45b5ebf3da..170f081355 100644 --- a/extensions/azurecore/src/azureResource/tree/subscriptionTreeNode.ts +++ b/extensions/azurecore/src/azureResource/tree/subscriptionTreeNode.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { Account, NodeInfo } from 'azdata'; +import { NodeInfo } from 'azdata'; import { AppContext } from '../../appContext'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -19,10 +19,11 @@ import { AzureResourceMessageTreeNode } from '../messageTreeNode'; import { AzureResourceErrorMessageUtil } from '../utils'; import { AzureResourceService } from '../resourceService'; import { AzureResourceResourceTreeNode } from '../resourceTreeNode'; +import { AzureAccount } from 'azurecore'; export class AzureResourceSubscriptionTreeNode extends AzureResourceContainerTreeNodeBase { public constructor( - public readonly account: Account, + public readonly account: AzureAccount, public readonly subscription: azureResource.AzureResourceSubscription, public readonly tenatId: string, appContext: AppContext, diff --git a/extensions/azurecore/src/azureResource/tree/treeProvider.ts b/extensions/azurecore/src/azureResource/tree/treeProvider.ts index 6a97de8b7e..a749acc9ff 100644 --- a/extensions/azurecore/src/azureResource/tree/treeProvider.ts +++ b/extensions/azurecore/src/azureResource/tree/treeProvider.ts @@ -16,12 +16,13 @@ import { AzureResourceMessageTreeNode } from '../messageTreeNode'; import { AzureResourceContainerTreeNodeBase } from './baseTreeNodes'; import { AzureResourceErrorMessageUtil, equals } from '../utils'; import { IAzureResourceTreeChangeHandler } from './treeChangeHandler'; +import { AzureAccount } from 'azurecore'; export class AzureResourceTreeProvider implements vscode.TreeDataProvider, IAzureResourceTreeChangeHandler { public isSystemInitialized: boolean = false; - private accounts: azdata.Account[]; + private accounts: AzureAccount[]; private _onDidChangeTreeData = new vscode.EventEmitter(); private loadingAccountsPromise: Promise; diff --git a/extensions/azurecore/src/azureResource/utils.ts b/extensions/azurecore/src/azureResource/utils.ts index 17ec51db8b..ad3c5c9c03 100644 --- a/extensions/azurecore/src/azureResource/utils.ts +++ b/extensions/azurecore/src/azureResource/utils.ts @@ -107,7 +107,7 @@ export function equals(one: any, other: any): boolean { return true; } -export async function getResourceGroups(appContext: AppContext, account?: azdata.Account, subscription?: azureResource.AzureResourceSubscription, ignoreErrors: boolean = false): Promise { +export async function getResourceGroups(appContext: AppContext, account?: AzureAccount, subscription?: azureResource.AzureResourceSubscription, ignoreErrors: boolean = false): Promise { const result: GetResourceGroupsResult = { resourceGroups: [], errors: [] }; if (!account?.properties?.tenants || !Array.isArray(account.properties.tenants) || !subscription) { const error = new Error(invalidAzureAccount); @@ -143,7 +143,7 @@ export async function getResourceGroups(appContext: AppContext, account?: azdata return result; } -export async function getLocations(appContext: AppContext, account?: azdata.Account, subscription?: azureResource.AzureResourceSubscription, ignoreErrors: boolean = false): Promise { +export async function getLocations(appContext: AppContext, account?: AzureAccount, subscription?: azureResource.AzureResourceSubscription, ignoreErrors: boolean = false): Promise { const result: GetLocationsResult = { locations: [], errors: [] }; if (!account?.properties?.tenants || !Array.isArray(account.properties.tenants) || !subscription) { const error = new Error(invalidAzureAccount); @@ -178,7 +178,7 @@ export async function getLocations(appContext: AppContext, account?: azdata.Acco } export async function runResourceQuery( - account: azdata.Account, + account: AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean = false, query: string): Promise> { @@ -292,7 +292,7 @@ export async function getSubscriptions(appContext: AppContext, account?: AzureAc return result; } -export async function getSelectedSubscriptions(appContext: AppContext, account?: azdata.Account, ignoreErrors: boolean = false): Promise { +export async function getSelectedSubscriptions(appContext: AppContext, account?: AzureAccount, ignoreErrors: boolean = false): Promise { const result: GetSubscriptionsResult = { subscriptions: [], errors: [] }; if (!account?.properties?.tenants || !Array.isArray(account.properties.tenants)) { const error = new Error(invalidAzureAccount); @@ -331,7 +331,7 @@ export async function getSelectedSubscriptions(appContext: AppContext, account?: * @param host Use this to override the host. The default host is https://management.azure.com * @param requestHeaders Provide additional request headers */ -export async function makeHttpRequest(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, path: string, requestType: HttpRequestMethod, requestBody?: any, ignoreErrors: boolean = false, host: string = 'https://management.azure.com', requestHeaders: { [key: string]: string } = {}): Promise { +export async function makeHttpRequest(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, path: string, requestType: HttpRequestMethod, requestBody?: any, ignoreErrors: boolean = false, host: string = 'https://management.azure.com', requestHeaders: { [key: string]: string } = {}): Promise { const result: AzureRestResponse = { response: {}, errors: [] }; if (!account?.properties?.tenants || !Array.isArray(account.properties.tenants)) { @@ -430,7 +430,7 @@ export async function makeHttpRequest(account: azdata.Account, subscription: azu return result; } -export async function getManagedDatabases(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, managedInstance: azureResource.AzureSqlManagedInstance, ignoreErrors: boolean): Promise { +export async function getManagedDatabases(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, managedInstance: azureResource.AzureSqlManagedInstance, ignoreErrors: boolean): Promise { const path = `/subscriptions/${subscription.id}/resourceGroups/${managedInstance.resourceGroup}/providers/Microsoft.Sql/managedInstances/${managedInstance.name}/databases?api-version=2020-02-02-preview`; const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors); return { @@ -439,7 +439,7 @@ export async function getManagedDatabases(account: azdata.Account, subscription: }; } -export async function getBlobContainers(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { +export async function getBlobContainers(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { const path = `/subscriptions/${subscription.id}/resourceGroups/${storageAccount.resourceGroup}/providers/Microsoft.Storage/storageAccounts/${storageAccount.name}/blobServices/default/containers?api-version=2019-06-01`; const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors); return { @@ -448,7 +448,7 @@ export async function getBlobContainers(account: azdata.Account, subscription: a }; } -export async function getFileShares(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { +export async function getFileShares(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { const path = `/subscriptions/${subscription.id}/resourceGroups/${storageAccount.resourceGroup}/providers/Microsoft.Storage/storageAccounts/${storageAccount.name}/fileServices/default/shares?api-version=2019-06-01`; const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors); return { @@ -457,7 +457,7 @@ export async function getFileShares(account: azdata.Account, subscription: azure }; } -export async function createResourceGroup(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, resourceGroupName: string, location: string, ignoreErrors: boolean): Promise { +export async function createResourceGroup(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, resourceGroupName: string, location: string, ignoreErrors: boolean): Promise { const path = `/subscriptions/${subscription.id}/resourcegroups/${resourceGroupName}?api-version=2021-04-01`; const requestBody = { location: location @@ -469,7 +469,7 @@ export async function createResourceGroup(account: azdata.Account, subscription: }; } -export async function getStorageAccountAccessKey(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { +export async function getStorageAccountAccessKey(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { const path = `/subscriptions/${subscription.id}/resourceGroups/${storageAccount.resourceGroup}/providers/Microsoft.Storage/storageAccounts/${storageAccount.name}/listKeys?api-version=2019-06-01`; const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.POST, undefined, ignoreErrors); return { @@ -479,7 +479,7 @@ export async function getStorageAccountAccessKey(account: azdata.Account, subscr }; } -export async function getBlobs(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, containerName: string, ignoreErrors: boolean): Promise { +export async function getBlobs(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, containerName: string, ignoreErrors: boolean): Promise { const result: GetBlobsResult = { blobs: [], errors: [] }; const storageKeys = await getStorageAccountAccessKey(account, subscription, storageAccount, ignoreErrors); if (!ignoreErrors) { diff --git a/extensions/azurecore/src/azurecore.d.ts b/extensions/azurecore/src/azurecore.d.ts index 24a6aac280..30620a4049 100644 --- a/extensions/azurecore/src/azurecore.d.ts +++ b/extensions/azurecore/src/azurecore.d.ts @@ -263,19 +263,19 @@ declare module 'azurecore' { } export interface IExtension { - getSubscriptions(account?: azdata.Account, ignoreErrors?: boolean, selectedOnly?: boolean): Promise; - getResourceGroups(account?: azdata.Account, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Promise; - getLocations(account?: azdata.Account, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Promise; - getSqlManagedInstances(account: azdata.Account, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; - getManagedDatabases(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, managedInstance: azureResource.AzureSqlManagedInstance, ignoreErrors?: boolean): Promise; - getSqlServers(account: azdata.Account, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; - getSqlVMServers(account: azdata.Account, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; - getStorageAccounts(account: azdata.Account, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; - getBlobContainers(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors?: boolean): Promise; - getFileShares(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors?: boolean): Promise; - createResourceGroup(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, resourceGroupName: string, location: string, ignoreErrors?: boolean): Promise; - getStorageAccountAccessKey(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors?: boolean): Promise; - getBlobs(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, containerName: string, ignoreErrors?: boolean): Promise; + getSubscriptions(account?: AzureAccount, ignoreErrors?: boolean, selectedOnly?: boolean): Promise; + getResourceGroups(account?: AzureAccount, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Promise; + getLocations(account?: AzureAccount, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Promise; + getSqlManagedInstances(account: AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; + getManagedDatabases(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, managedInstance: azureResource.AzureSqlManagedInstance, ignoreErrors?: boolean): Promise; + getSqlServers(account: AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; + getSqlVMServers(account: AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; + getStorageAccounts(account: AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors?: boolean): Promise; + getBlobContainers(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors?: boolean): Promise; + getFileShares(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors?: boolean): Promise; + createResourceGroup(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, resourceGroupName: string, location: string, ignoreErrors?: boolean): Promise; + getStorageAccountAccessKey(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors?: boolean): Promise; + getBlobs(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, containerName: string, ignoreErrors?: boolean): Promise; /** * Makes Azure REST requests to create, retrieve, update or delete access to azure service's resources. * For reference to different service URLs, See https://docs.microsoft.com/rest/api/?view=Azure @@ -288,7 +288,7 @@ declare module 'azurecore' { * @param host Use this to override the host. The default host is https://management.azure.com * @param requestHeaders Provide additional request headers */ - makeAzureRestRequest(account: azdata.Account, subscription: azureResource.AzureResourceSubscription, path: string, requestType: HttpRequestMethod, requestBody?: any, ignoreErrors?: boolean, host?: string, requestHeaders?: { [key: string]: string }): Promise; + makeAzureRestRequest(account: AzureAccount, subscription: azureResource.AzureResourceSubscription, path: string, requestType: HttpRequestMethod, requestBody?: any, ignoreErrors?: boolean, host?: string, requestHeaders?: { [key: string]: string }): Promise; /** * Converts a region value (@see AzureRegion) into the localized Display Name * @param region The region value @@ -296,7 +296,7 @@ declare module 'azurecore' { getRegionDisplayName(region?: string): string; provideResources(): azureResource.IAzureResourceProvider[]; - runGraphQuery(account: azdata.Account, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean, query: string): Promise>; + runGraphQuery(account: AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean, query: string): Promise>; } export type GetSubscriptionsResult = { subscriptions: azureResource.AzureResourceSubscription[], errors: Error[] }; diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts index 050ab31a9c..1ae3db21dd 100644 --- a/extensions/azurecore/src/extension.ts +++ b/extensions/azurecore/src/extension.ts @@ -117,7 +117,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { return azureResourceUtils.getResourceGroups(appContext, account, subscription, ignoreErrors); }, - getLocations(account?: azdata.Account, + getResourceGroups(account?: azurecore.AzureAccount, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Promise { return azureResourceUtils.getResourceGroups(appContext, account, subscription, ignoreErrors); }, + getLocations(account?: azurecore.AzureAccount, subscription?: azureResource.AzureResourceSubscription, ignoreErrors?: boolean): Promise { return azureResourceUtils.getLocations(appContext, account, subscription, ignoreErrors); @@ -172,65 +172,65 @@ export async function activate(context: vscode.ExtensionContext): Promise { return azureResourceUtils.runResourceQuery(account, subscriptions, ignoreErrors, `where type == "${azureResource.AzureResourceType.sqlManagedInstance}"`); }, - getManagedDatabases(account: azdata.Account, + getManagedDatabases(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, managedInstance: azureResource.AzureSqlManagedInstance, ignoreErrors: boolean): Promise { return azureResourceUtils.getManagedDatabases(account, subscription, managedInstance, ignoreErrors); }, - getSqlServers(account: azdata.Account, + getSqlServers(account: azurecore.AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean): Promise { return azureResourceUtils.runResourceQuery(account, subscriptions, ignoreErrors, `where type == "${azureResource.AzureResourceType.sqlServer}"`); }, - getSqlVMServers(account: azdata.Account, + getSqlVMServers(account: azurecore.AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean): Promise { return azureResourceUtils.runResourceQuery(account, subscriptions, ignoreErrors, `where type == "${azureResource.AzureResourceType.virtualMachines}" and properties.storageProfile.imageReference.publisher == "microsoftsqlserver"`); }, - getStorageAccounts(account: azdata.Account, + getStorageAccounts(account: azurecore.AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean): Promise { return azureResourceUtils.runResourceQuery(account, subscriptions, ignoreErrors, `where type == "${azureResource.AzureResourceType.storageAccount}"`); }, - getBlobContainers(account: azdata.Account, + getBlobContainers(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { return azureResourceUtils.getBlobContainers(account, subscription, storageAccount, ignoreErrors); }, - getFileShares(account: azdata.Account, + getFileShares(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { return azureResourceUtils.getFileShares(account, subscription, storageAccount, ignoreErrors); }, - getStorageAccountAccessKey(account: azdata.Account, + getStorageAccountAccessKey(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, ignoreErrors: boolean): Promise { return azureResourceUtils.getStorageAccountAccessKey(account, subscription, storageAccount, ignoreErrors); }, - getBlobs(account: azdata.Account, + getBlobs(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, storageAccount: azureResource.AzureGraphResource, containerName: string, ignoreErrors: boolean): Promise { return azureResourceUtils.getBlobs(account, subscription, storageAccount, containerName, ignoreErrors); }, - createResourceGroup(account: azdata.Account, + createResourceGroup(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, resourceGroupName: string, location: string, ignoreErrors: boolean): Promise { return azureResourceUtils.createResourceGroup(account, subscription, resourceGroupName, location, ignoreErrors); }, - makeAzureRestRequest(account: azdata.Account, + makeAzureRestRequest(account: azurecore.AzureAccount, subscription: azureResource.AzureResourceSubscription, path: string, requestType: azurecore.HttpRequestMethod, @@ -241,7 +241,7 @@ export async function activate(context: vscode.ExtensionContext): Promise(account: azdata.Account, + runGraphQuery(account: azurecore.AzureAccount, subscriptions: azureResource.AzureResourceSubscription[], ignoreErrors: boolean, query: string): Promise> { diff --git a/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts b/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts index 20a14f81d4..423dbc699a 100644 --- a/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts @@ -23,6 +23,7 @@ import { AzureResourceSubscriptionTreeNode } from '../../../azureResource/tree/s import { AzureResourceItemType, AzureResourceServiceNames } from '../../../azureResource/constants'; import { AzureResourceMessageTreeNode } from '../../../azureResource/messageTreeNode'; import { generateGuid } from '../../../azureResource/utils'; +import { AzureAccount } from 'azurecore'; // Mock services let mockExtensionContext: TypeMoq.IMock; @@ -35,7 +36,7 @@ let mockTreeChangeHandler: TypeMoq.IMock; // Mock test data const mockTenantId = 'mock_tenant_id'; -const mockAccount: azdata.Account = { +const mockAccount: AzureAccount = { key: { accountId: '97915f6d-84fa-4926-b60c-38db64327ad7', providerId: 'mock_provider' @@ -50,9 +51,16 @@ const mockAccount: azdata.Account = { properties: { tenants: [ { - id: mockTenantId + id: mockTenantId, + displayName: 'Mock Tenant' } - ] + ], + providerSettings: { + settings: { }, + id: 'azure', + displayName: 'Azure' + }, + isMsAccount: true }, isStale: false }; diff --git a/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts b/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts index 399ffe0939..935db93233 100644 --- a/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts @@ -5,7 +5,6 @@ import * as should from 'should'; import * as TypeMoq from 'typemoq'; -import * as azdata from 'azdata'; import * as vscode from 'vscode'; import 'mocha'; import { AppContext } from '../../../appContext'; @@ -18,6 +17,7 @@ import { AzureResourceService } from '../../../azureResource/resourceService'; import { AzureResourceResourceTreeNode } from '../../../azureResource/resourceTreeNode'; import { IAzureResourceCacheService } from '../../../azureResource/interfaces'; import { generateGuid } from '../../../azureResource/utils'; +import { AzureAccount } from 'azurecore'; // Mock services let appContext: AppContext; @@ -28,7 +28,7 @@ let mockCacheService: TypeMoq.IMock; let mockTreeChangeHandler: TypeMoq.IMock; // Mock test data -const mockAccount: azdata.Account = { +const mockAccount: AzureAccount = { key: { accountId: 'mock_account', providerId: 'mock_provider' diff --git a/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts b/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts index ad3a2e61e0..4a4357369e 100644 --- a/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts @@ -17,6 +17,7 @@ import { AzureResourceAccountTreeNode } from '../../../azureResource/tree/accoun import { AzureResourceAccountNotSignedInTreeNode } from '../../../azureResource/tree/accountNotSignedInTreeNode'; import { AzureResourceServiceNames } from '../../../azureResource/constants'; import { generateGuid } from '../../../azureResource/utils'; +import { AzureAccount } from 'azurecore'; // Mock services let mockAppContext: AppContext; @@ -25,7 +26,7 @@ let mockExtensionContext: TypeMoq.IMock; let mockCacheService: TypeMoq.IMock; // Mock test data -const mockAccount1: azdata.Account = { +const mockAccount1: AzureAccount = { key: { accountId: 'mock_account_1', providerId: 'mock_provider' @@ -39,7 +40,7 @@ const mockAccount1: azdata.Account = { properties: undefined, isStale: false }; -const mockAccount2: azdata.Account = { +const mockAccount2: AzureAccount = { key: { accountId: 'mock_account_2', providerId: 'mock_provider'