Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maorleger committed Nov 20, 2024
1 parent 5f16d03 commit fa31e8c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
19 changes: 9 additions & 10 deletions sdk/keyvault/keyvault-admin/test/public/backupClient.abort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import { Recorder } from "@azure-tools/test-recorder";
import { KeyVaultBackupClient } from "../../src/index.js";
import { authenticate } from "./utils/authentication.js";
import { testPollerProperties } from "./utils/recorder.js";
import { getSasToken } from "./utils/common.js";
import { describe, it, beforeEach, afterEach, expect } from "vitest";
import { AbortError } from "@azure/abort-controller";
import { getEnvironmentVariable } from "./utils/common.js";

// TODO: https://github.com/Azure/azure-sdk-for-js/issues/30273
describe.skip("Aborting KeyVaultBackupClient's requests", () => {
describe("Aborting KeyVaultBackupClient's requests", () => {
let client: KeyVaultBackupClient;
let recorder: Recorder;
let blobStorageUri: string;
let blobSasToken: string;

let generateFakeUUID: () => string;

Expand All @@ -25,9 +23,10 @@ describe.skip("Aborting KeyVaultBackupClient's requests", () => {
recorder = authentication.recorder;
generateFakeUUID = authentication.generateFakeUUID;

const sasTokenData = getSasToken();
blobStorageUri = sasTokenData.blobStorageUri;
blobSasToken = sasTokenData.blobSasToken;
blobStorageUri = new URL(
getEnvironmentVariable("BLOB_CONTAINER_NAME"),
getEnvironmentVariable("BLOB_STORAGE_URI"),
).href;
});

afterEach(async function () {
Expand All @@ -39,7 +38,7 @@ describe.skip("Aborting KeyVaultBackupClient's requests", () => {
controller.abort();

await expect(
client.beginBackup(blobStorageUri, blobSasToken, {
client.beginBackup(blobStorageUri, {
...testPollerProperties,
abortSignal: controller.signal,
}),
Expand All @@ -52,7 +51,7 @@ describe.skip("Aborting KeyVaultBackupClient's requests", () => {
controller.abort();

await expect(
client.beginRestore(backupURI, blobSasToken, {
client.beginRestore(backupURI, {
...testPollerProperties,
abortSignal: controller.signal,
}),
Expand All @@ -66,7 +65,7 @@ describe.skip("Aborting KeyVaultBackupClient's requests", () => {
controller.abort();

await expect(
client.beginSelectiveKeyRestore("key-name", backupURI, blobSasToken, {
client.beginSelectiveKeyRestore("key-name", backupURI, {
...testPollerProperties,
abortSignal: controller.signal,
}),
Expand Down
8 changes: 5 additions & 3 deletions sdk/keyvault/keyvault-admin/test/public/backupClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { isPlaybackMode } from "@azure-tools/test-recorder";
import type { KeyVaultBackupClient } from "../../src/index.js";
import { authenticate } from "./utils/authentication.js";
import { testPollerProperties } from "./utils/recorder.js";
import { getSasToken } from "./utils/common.js";
import { delay } from "@azure/core-util";
import type { KeyClient } from "@azure/keyvault-keys";
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { getEnvironmentVariable } from "./utils/common.js";

describe("KeyVaultBackupClient", () => {
let client: KeyVaultBackupClient;
Expand All @@ -24,8 +24,10 @@ describe("KeyVaultBackupClient", () => {
client = authentication.backupClient;
keyClient = authentication.keyClient;
recorder = authentication.recorder;
const sasTokenData = getSasToken();
blobStorageUri = sasTokenData.blobStorageUri;
blobStorageUri = new URL(
getEnvironmentVariable("BLOB_CONTAINER_NAME"),
getEnvironmentVariable("BLOB_STORAGE_URI"),
).href;
});

afterEach(async function () {
Expand Down
11 changes: 0 additions & 11 deletions sdk/keyvault/keyvault-admin/test/public/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,3 @@ export function getEnvironmentVariable(envVarName: string): string {
}
return envVar;
}

/**
* Get a predefined SAS token and Storage URI to use when backing up a KeyVault
*/
export function getSasToken(): { blobStorageUri: string; blobSasToken?: string } {
const baseStorageUri = getEnvironmentVariable("BLOB_STORAGE_URI").replace(/\/$/, "");
const blobStorageUri = `${baseStorageUri}/${getEnvironmentVariable("BLOB_CONTAINER_NAME")}`;
const blobSasToken = env["BLOB_STORAGE_SAS_TOKEN"]; // not required

return { blobStorageUri, blobSasToken };
}
2 changes: 1 addition & 1 deletion sdk/keyvault/test-resources-post.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ New-AzKeyVaultRoleAssignment -HsmName $hsmName -RoleDefinitionName "Managed HSM
Log "Role assignments created for '$testApplicationOid'"

Log "Associating managed identity with managed HSM"
Update-AzKeyVaultManagedHsm -HsmName $hsmName -IdentityType "UserAssigned" -UserAssignedIdentityId $DeploymentOutputs["MANAGED_IDENTITY_ID"]
Update-AzKeyVaultManagedHsm -HsmName $hsmName -ResourceGroupName $DeploymentOutputs["KEYVAULT_RESOURCE_GROUP"] -UserAssignedIdentity $DeploymentOutputs["MANAGED_IDENTITY_ID"]
Log "Managed identity associated with managed HSM - backup and restore using managed identity is enabled"

0 comments on commit fa31e8c

Please sign in to comment.