mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-12-02 02:17:01 +00:00
6925fa8e4e
* Use Az login with OpenID connection to get test credentials. * Set subscription id environment variable. * Update testExplorer and cleanup job. * Retrieve access token in test case and pass to testExplorer. * Add debug tracing for tests. * Set up other mongo test to use Az CLI creds. * Revert subscription id retrieval. * Add CLI credentials retrieval to rest of tests. * Fix missing imports. * Clean up redundant code. * Remove commented import statement.
21 lines
742 B
TypeScript
21 lines
742 B
TypeScript
import { AzureCliCredentials } from "@azure/ms-rest-nodeauth";
|
|
import crypto from "crypto";
|
|
|
|
export function generateUniqueName(baseName = "", length = 4): string {
|
|
return `${baseName}${crypto.randomBytes(length).toString("hex")}`;
|
|
}
|
|
|
|
export function generateDatabaseNameWithTimestamp(baseName = "db", length = 1): string {
|
|
return `${baseName}${crypto.randomBytes(length).toString("hex")}-${Date.now()}`;
|
|
}
|
|
|
|
export async function getAzureCLICredentials(): Promise<AzureCliCredentials> {
|
|
return await AzureCliCredentials.create();
|
|
}
|
|
|
|
export async function getAzureCLICredentialsToken(): Promise<string> {
|
|
const credentials = await getAzureCLICredentials();
|
|
const token = (await credentials.getToken()).accessToken;
|
|
return token;
|
|
}
|