Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sdk/test-utils/recorder-new/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 1.0.0 (Unreleased)

## 2021-12-10

- Loads the .env file using with the help of "dotenv" by default.
[#19139](https://github.com/Azure/azure-sdk-for-js/pull/19139)

## 2021-11-30

- Adds NoOp AAD Credential for playback `NoOpCredential`. Using this as your AAD credential in playback mode would avoid the AAD traffic in playback.
Expand Down
1 change: 1 addition & 0 deletions sdk/test-utils/recorder-new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"types": "./types/src/index.d.ts",
"browser": {
"./dist-esm/src/utils/relativePathCalculator.js": "./dist-esm/src/utils/relativePathCalculator.browser.js",
"./dist-esm/src/utils/env.js": "./dist-esm/src/utils/env.browser.js",
"./dist-esm/test/utils/server.js": "./dist-esm/test/utils/server.browser.js"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions sdk/test-utils/recorder-new/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { TestProxyHttpClientCoreV1 } from "./core-v1-recorder";
export { relativeRecordingsPath } from "./utils/relativePathCalculator";
export { SanitizerOptions, RecorderStartOptions } from "./utils/utils";
export { NoOpCredential } from "./recorderAADCredential";
export { env } from "./utils/env";
6 changes: 6 additions & 0 deletions sdk/test-utils/recorder-new/src/utils/env.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// In the browser, we load the env variables with the help of karma.conf.js

export const env = (window as any).__env__;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw with a descriptive message if karma config did not load the env vars?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn't know if the karma.conf has loaded the variables or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a certain variable is undefined, we'll know from the test failure anyways.

9 changes: 9 additions & 0 deletions sdk/test-utils/recorder-new/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import * as dotenv from "dotenv";

// Initialize the environment
dotenv.config();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this executed? Is the intent that users do import "@azure-tools/recorder-new" to get this loaded?

Copy link
Copy Markdown
Contributor Author

@HarshaNalluru HarshaNalluru Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's the intention.
Or when you import anything from recorder-new


export const env = process.env;
2 changes: 2 additions & 0 deletions sdk/test-utils/testing-recorder-new/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
import { QueueServiceClient } from "@azure/storage-queue";
import { TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new";
import { config } from "dotenv";
import { RecorderStartOptions } from "@azure-tools/test-recorder-new";
config();

const fakeSASUrl =
"https://account_name.queue.core.windows.net/?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
recorderHttpPolicy,
RecorderStartOptions
} from "@azure-tools/test-recorder-new";
import { config } from "dotenv";
import { createSimpleEntity } from "./utils/utils";
import { SanitizerOptions } from "@azure-tools/test-recorder-new";
config();

const fakeConnString =
"TableEndpoint=https://fakeaccountname.table.core.windows.net/;SharedAccessSignature=st=2021-08-03T08:52:15Z&spr=https&sig=fakesigval";
Expand Down