mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-02 16:08:23 +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 { expect, Frame, Locator, Page } from "@playwright/test";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
|
|
||||||
@ -20,13 +20,13 @@ export function generateUniqueName(baseName, options?: TestNameOptions): string
|
|||||||
return `${prefix}${baseName}${crypto.randomBytes(length).toString("hex")}${suffix}`;
|
return `${prefix}${baseName}${crypto.randomBytes(length).toString("hex")}${suffix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAzureCLICredentials(): Promise<AzureCliCredentials> {
|
export function getAzureCLICredentials(): AzureCliCredential {
|
||||||
return await AzureCliCredentials.create();
|
return new AzureCliCredential();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAzureCLICredentialsToken(): Promise<string> {
|
export async function getAzureCLICredentialsToken(): Promise<string> {
|
||||||
const credentials = await getAzureCLICredentials();
|
const credentials = getAzureCLICredentials();
|
||||||
const token = (await credentials.getToken()).accessToken;
|
const token = (await credentials.getToken("https://management.core.windows.net//.default")).token;
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
} from "../fx";
|
} from "../fx";
|
||||||
|
|
||||||
test("SQL account using Resource token", async ({ page }) => {
|
test("SQL account using Resource token", async ({ page }) => {
|
||||||
const credentials = await getAzureCLICredentials();
|
const credentials = getAzureCLICredentials();
|
||||||
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||||
const accountName = getAccountName(TestAccount.SQL);
|
const accountName = getAccountName(TestAccount.SQL);
|
||||||
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||||
|
@ -56,7 +56,7 @@ export class TestContainerContext {
|
|||||||
export async function createTestSQLContainer(includeTestData?: boolean) {
|
export async function createTestSQLContainer(includeTestData?: boolean) {
|
||||||
const databaseId = generateUniqueName("db");
|
const databaseId = generateUniqueName("db");
|
||||||
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
|
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 armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||||
const accountName = getAccountName(TestAccount.SQL);
|
const accountName = getAccountName(TestAccount.SQL);
|
||||||
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user