Test changes to use identity package.

This commit is contained in:
Jade Welton 2025-01-16 10:31:02 -08:00
parent 1b53c6980d
commit e2bb64b8b2
3 changed files with 7 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);