Skip to content

Commit

Permalink
[Recorder] Followup of #7083 - Coupling RecorderEnvironmentSetup wi…
Browse files Browse the repository at this point in the history
…th the record call (#7085)

* add brand new RecorderEnvironmentSetup

* import RecorderEnvironmentSetup from the utils and pass on to setEnvironmentOnLoad

* update exports in the recorder

* import RecorderEnvironmentSetup in storage-queue

* update tests with recorderEnvSetup accordingly

* cleanup - remove dependency on env variables in replaceableVariables

* Update testutils.common.ts files for all storage packages

* file-share tests fixed

* blob tests fix

* blob fix leftovers

* recordings for the beforeEach update

* storage-file-datalake update recorderEnvSetup

* fix formatting

* DataLakeService FIX

* FILE DATALAKE - left overs

* updated Guidelines accordingly

* update keyvault tests

* Update Changelog
  • Loading branch information
HarshaNalluru authored Jan 28, 2020
1 parent ac112f1 commit 0ce15cc
Show file tree
Hide file tree
Showing 110 changed files with 3,404 additions and 1,880 deletions.
33 changes: 17 additions & 16 deletions sdk/keyvault/keyvault-certificates/test/utils/testAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ import { ClientSecretCredential } from "@azure/identity";
import { getKeyvaultName } from "./utils.common";
import { CertificateClient } from "../../src";
import { uniqueString } from "./recorderUtils";
import { env, record, setReplaceableVariables, setReplacements } from "@azure/test-utils-recorder";
import { env, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder";
import TestClient from "./testClient";

export async function authenticate(that: any): Promise<any> {
setReplaceableVariables({
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "azure_tenant_id",
KEYVAULT_NAME: "keyvault_name"
});

const suffix = uniqueString();
setReplacements([
(recording: any): any =>
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`),
(recording: any): any =>
suffix === "" ? recording : recording.replace(new RegExp(suffix, "g"), "")
]);

const recorder = record(that);
const recorderEnvSetup: RecorderEnvironmentSetup = {
replaceableVariables: {
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "azure_tenant_id",
KEYVAULT_NAME: "keyvault_name"
},
replaceInRecordings: [
(recording: any): any =>
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`),
(recording: any): any =>
suffix === "" ? recording : recording.replace(new RegExp(suffix, "g"), "")
],
queryParametersToSkip: []
};
const recorder = record(that, recorderEnvSetup);
const credential = await new ClientSecretCredential(
env.AZURE_TENANT_ID,
env.AZURE_CLIENT_ID,
Expand Down
33 changes: 17 additions & 16 deletions sdk/keyvault/keyvault-keys/test/utils/testAuthentication.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { ClientSecretCredential } from "@azure/identity";
import { getKeyvaultName } from "./utils.common";
import { KeyClient } from "../../src";
import { env, record, setReplaceableVariables, setReplacements } from "@azure/test-utils-recorder";
import { env, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder";
import { uniqueString } from "./recorderUtils";
import TestClient from "./testClient";

export async function authenticate(that: any): Promise<any> {
setReplaceableVariables({
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "azure_tenant_id",
KEYVAULT_NAME: "keyvault_name"
});

const keySuffix = uniqueString();
setReplacements([
(recording: any): any =>
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`),
(recording: any): any =>
keySuffix === "" ? recording : recording.replace(new RegExp(keySuffix, "g"), "")
]);

const recorder = record(that);
const recorderEnvSetup: RecorderEnvironmentSetup = {
replaceableVariables: {
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "azure_tenant_id",
KEYVAULT_NAME: "keyvault_name"
},
replaceInRecordings: [
(recording: any): any =>
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`),
(recording: any): any =>
keySuffix === "" ? recording : recording.replace(new RegExp(keySuffix, "g"), "")
],
queryParametersToSkip: []
};
const recorder = record(that, recorderEnvSetup);
const credential = await new ClientSecretCredential(
env.AZURE_TENANT_ID,
env.AZURE_CLIENT_ID,
Expand Down
33 changes: 17 additions & 16 deletions sdk/keyvault/keyvault-secrets/test/utils/testAuthentication.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { ClientSecretCredential } from "@azure/identity";
import { getKeyvaultName } from "./utils.common";
import { SecretClient } from "../../src";
import { env, record, setReplaceableVariables, setReplacements } from "@azure/test-utils-recorder";
import { env, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder";
import { uniqueString } from "./recorderUtils";
import TestClient from "./testClient";

export async function authenticate(that: any): Promise<any> {
setReplaceableVariables({
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "azure_tenant_id",
KEYVAULT_NAME: "keyvault_name"
});

const secretSuffix = uniqueString();
setReplacements([
(recording: any): any =>
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`),
(recording: any): any =>
secretSuffix === "" ? recording : recording.replace(new RegExp(secretSuffix, "g"), "")
]);

const recorder = record(that);
const recorderEnvSetup: RecorderEnvironmentSetup = {
replaceableVariables: {
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "azure_tenant_id",
KEYVAULT_NAME: "keyvault_name"
},
replaceInRecordings: [
(recording: any): any =>
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`),
(recording: any): any =>
secretSuffix === "" ? recording : recording.replace(new RegExp(secretSuffix, "g"), "")
],
queryParametersToSkip: []
};
const recorder = record(that, recorderEnvSetup);
const credential = await new ClientSecretCredential(
env.AZURE_TENANT_ID,
env.AZURE_CLIENT_ID,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0ce15cc

Please sign in to comment.