Skip to content

Commit 5deb334

Browse files
[Recorder] Mask access_token in the JSON responses in recordings (Azure#12759)
### TODO - [x] Proposal - Come up with a method to mask "access_token" in the recorder rather than expecting users to provide it through the custom config - [x] Node - [x] Browser - [x] Add "mask" method to the default customizations - [x] Changelog - [x] Regenerate a recording from app-config and keyvault-keys tests with "access_token"s - [x] (Beyond the scope of this PR) Remove the "access_token" custom replacement from the recorder config in all the packages Keyvault, form recognizer, etc Azure#14602
1 parent 611a74b commit 5deb334

File tree

12 files changed

+1840
-331
lines changed

12 files changed

+1840
-331
lines changed

sdk/appconfiguration/app-configuration/recordings/node/authentication/recording_token_authentication_works.js

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/appconfiguration/app-configuration/test/public/auth.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
CredsAndEndpoint
99
} from "./utils/testHelpers";
1010
import * as assert from "assert";
11-
import { Recorder, isPlaybackMode } from "@azure/test-utils-recorder";
11+
import { Recorder } from "@azure/test-utils-recorder";
1212
import { Context } from "mocha";
1313

1414
describe("Authentication", () => {
@@ -31,10 +31,7 @@ describe("Authentication", () => {
3131
);
3232
});
3333

34-
it("token authentication works", async function(this: Context) {
35-
if (isPlaybackMode()) {
36-
this.skip();
37-
}
34+
it("token authentication works", async function() {
3835
const client = new AppConfigurationClient(
3936
credsAndEndpoint.endpoint,
4037
credsAndEndpoint.credential
@@ -43,7 +40,7 @@ describe("Authentication", () => {
4340
// it doesn't matter if any data comes in so long as we were
4441
// able to connect and call the service
4542
await client.addConfigurationSetting({
46-
key: `token-authentication-test-${Date.now()}`,
43+
key: `token-authentication-test-${recorder.newDate("label-1").valueOf()}`,
4744
value: "hello"
4845
});
4946
});

sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ export function startRecorder(that: any): Recorder {
4242
AZURE_CLIENT_SECRET: "azure_client_secret",
4343
AZURE_TENANT_ID: "azuretenantid"
4444
},
45-
customizationsOnRecordings: [
46-
(recording: any): any =>
47-
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`)
48-
],
45+
customizationsOnRecordings: [],
4946
queryParametersToSkip: []
5047
};
5148

0 commit comments

Comments
 (0)