mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-01-19 07:20:21 +00:00
Test changes to use identity package.
This commit is contained in:
parent
1b53c6980d
commit
e2bb64b8b2
10
test/fx.ts
10
test/fx.ts
@ -1,4 +1,4 @@
|
||||
import { AzureCliCredentials } from "@azure/ms-rest-nodeauth";
|
||||
import { AzureCliCredential } from "@azure/identity";
|
||||
import { expect, Frame, Locator, Page } from "@playwright/test";
|
||||
import crypto from "crypto";
|
||||
|
||||
@ -20,13 +20,13 @@ export function generateUniqueName(baseName, options?: TestNameOptions): string
|
||||
return `${prefix}${baseName}${crypto.randomBytes(length).toString("hex")}${suffix}`;
|
||||
}
|
||||
|
||||
export async function getAzureCLICredentials(): Promise<AzureCliCredentials> {
|
||||
return await AzureCliCredentials.create();
|
||||
export function getAzureCLICredentials(): AzureCliCredential {
|
||||
return new AzureCliCredential();
|
||||
}
|
||||
|
||||
export async function getAzureCLICredentialsToken(): Promise<string> {
|
||||
const credentials = await getAzureCLICredentials();
|
||||
const token = (await credentials.getToken()).accessToken;
|
||||
const credentials = getAzureCLICredentials();
|
||||
const token = (await credentials.getToken("https://management.core.windows.net//.default")).token;
|
||||
return token;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
} from "../fx";
|
||||
|
||||
test("SQL account using Resource token", async ({ page }) => {
|
||||
const credentials = await getAzureCLICredentials();
|
||||
const credentials = getAzureCLICredentials();
|
||||
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
const accountName = getAccountName(TestAccount.SQL);
|
||||
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||
|
@ -56,7 +56,7 @@ export class TestContainerContext {
|
||||
export async function createTestSQLContainer(includeTestData?: boolean) {
|
||||
const databaseId = generateUniqueName("db");
|
||||
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
|
||||
const credentials = await getAzureCLICredentials();
|
||||
const credentials = getAzureCLICredentials();
|
||||
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
const accountName = getAccountName(TestAccount.SQL);
|
||||
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user