Skip to content

Commit e2eea7e

Browse files
HarshaNallurusouthpolestevezfosteromzivdiberry
authored
[Unified Recorder] New test-utils package for test credential (Azure#19423)
* Fix retry handling for Session Not Found errors * Update sdk/cosmosdb/cosmos/test/internal/session.spec.ts Co-authored-by: Zachary Foster <[email protected]> * Update CODEOWNERS for Application Insights (Azure#17055) * Add link to documentation (Azure#18291) * Update AzureIdentityExamples.md (Azure#18958) Rename function to match the credential being used * new package for test credential * revert unrelated changes * unrelated changes * lock file * Update sdk/test-utils/identity-extensions/CHANGELOG.md * Update sdk/test-utils/identity-extensions/CHANGELOG.md * Update sdk/test-utils/identity-extensions/package.json * Update sdk/test-utils/identity-extensions/package.json * Move NoOpCredential to identity extensions package * Update sdk/test-utils/identity-extensions/README.md Co-authored-by: Will Temple <[email protected]> * Update sdk/test-utils/identity-extensions/README.md Co-authored-by: Will Temple <[email protected]> * Update sdk/test-utils/identity-extensions/README.md Co-authored-by: Will Temple <[email protected]> * Update sdk/test-utils/identity-extensions/README.md Co-authored-by: Will Temple <[email protected]> * Update sdk/test-utils/identity-extensions/src/index.ts Co-authored-by: Will Temple <[email protected]> * renames * changelog * more updates * ysage in readme * unused in package.json * TokenCredentialOptions optional Co-authored-by: Steve Faulkner <[email protected]> Co-authored-by: Zachary Foster <[email protected]> Co-authored-by: omziv <[email protected]> Co-authored-by: Dina Berry <[email protected]> Co-authored-by: Philip Gai <[email protected]> Co-authored-by: Will Temple <[email protected]>
1 parent 4550b69 commit e2eea7e

File tree

17 files changed

+242
-17
lines changed

17 files changed

+242
-17
lines changed

common/config/rush/pnpm-lock.yaml

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

rush.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,11 @@
716716
"projectFolder": "sdk/test-utils/recorder-new",
717717
"versionPolicyName": "utility"
718718
},
719+
{
720+
"packageName": "@azure-tools/test-credential",
721+
"projectFolder": "sdk/test-utils/test-credential",
722+
"versionPolicyName": "utility"
723+
},
719724
{
720725
"packageName": "@azure/test-utils-perf",
721726
"projectFolder": "sdk/test-utils/perf",

sdk/test-utils/recorder-new/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 1.0.0 (Unreleased)
44

5+
## 2021-12-17
6+
7+
- Moving `NoOpCredential` to the new `@azure-tools/test-credential` package.
8+
59
## 2021-12-15
610

711
- Change the API for using variables. Variables can now be accessed using the syntax:

sdk/test-utils/recorder-new/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ export { TestProxyHttpClient } from "./core-v2-recorder";
55
export { TestProxyHttpClientCoreV1 } from "./core-v1-recorder";
66
export { relativeRecordingsPath } from "./utils/relativePathCalculator";
77
export { SanitizerOptions, RecorderStartOptions } from "./utils/utils";
8-
export { NoOpCredential } from "./recorderAADCredential";
98
export { env } from "./utils/env";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"plugins": ["@azure/azure-sdk"],
3+
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"]
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Release History
2+
3+
## 1.0.0 (#Unreleased)
4+
5+
### Features Added
6+
7+
Provides the credential to be used in the tests. `NoOpCredential` in playback and `ClientSecretCredential` in record/live modes.
8+
[#19423](https://github.com/Azure/azure-sdk-for-js/pull/19423)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Microsoft
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Azure Tools - Test Credential
2+
3+
This library provides a `TokenCredential` implementation for testing Azure SDK packages.
4+
5+
## Getting started
6+
7+
### Installation
8+
9+
Add this library as a dev dependency in your project.
10+
11+
> rush add -p @azure-tools/test-credential --dev
12+
13+
## Key concepts
14+
15+
### Usage
16+
```ts
17+
import { createTestCredential } from "@azure-tools/test-credential";
18+
19+
const credential = createTestCredential();
20+
```
21+
22+
This library provides the credential to be used in the tests
23+
24+
In playback mode
25+
26+
- returns a `NoOpCredential` (does not make a request to AAD and produces a fake access_token)
27+
28+
In record/live modes
29+
30+
- returns a `ClientSecretCredential` from `@azure/identity` (expects AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET in your environment or in the .env file)
31+
- AAD traffic won't be recorded if this credential is used.
32+
33+
## Next steps
34+
35+
Try out this package in your application and provide feedback!
36+
37+
## Troubleshooting
38+
39+
Log an issue at https://github.com/Azure/azure-sdk-for-js/issues
40+
41+
## Contributing
42+
43+
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
44+
45+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Ftest-utils%2Ftest-credential%2FREADME.png)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"name": "@azure-tools/test-credential",
3+
"version": "1.0.0",
4+
"sdk-type": "utility",
5+
"description": "Test utilities library that provides the test credential",
6+
"main": "dist/index.js",
7+
"module": "dist-esm/src/index.js",
8+
"types": "./types/latest/src/index.d.ts",
9+
"engines": {
10+
"node": ">=12.0.0"
11+
},
12+
"scripts": {
13+
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
14+
"build": "npm run clean && tsc -p . && rollup -c 2>&1",
15+
"build:samples": "echo Skipped.",
16+
"build:test": "echo not needed",
17+
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
18+
"clean": "rimraf dist dist-* types *.tgz *.log",
19+
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
20+
"integration-test:browser": "echo skipped",
21+
"integration-test:node": "echo skipped",
22+
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
23+
"lint:fix": "eslint --no-eslintrc -c ../../.eslintrc.internal.json package.json src test --ext .ts --fix --fix-type [problem,suggestion]",
24+
"lint": "eslint --no-eslintrc -c ../../.eslintrc.internal.json package.json src test --ext .ts",
25+
"pack": "npm pack 2>&1",
26+
"unit-test:browser": "echo skipped",
27+
"unit-test:node": "echo skipped",
28+
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
29+
"test:browser": "npm run clean && npm run build npm run unit-test:browser",
30+
"test:node": "npm run clean && npm run build && npm run unit-test:node",
31+
"test": "npm run clean && npm run build && npm run unit-test"
32+
},
33+
"files": [
34+
"dist/",
35+
"dist-esm/src/",
36+
"types/src/index.d.ts",
37+
"README.md",
38+
"LICENSE"
39+
],
40+
"repository": "github:Azure/azure-sdk-for-js",
41+
"keywords": [
42+
"Azure",
43+
"cloud",
44+
"test",
45+
"framework"
46+
],
47+
"author": "Microsoft Corporation",
48+
"license": "MIT",
49+
"bugs": {
50+
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
51+
},
52+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/test-utils/test-credential/README.md",
53+
"sideEffects": false,
54+
"private": true,
55+
"dependencies": {
56+
"@azure/core-auth": "^1.3.2",
57+
"@azure-tools/test-recorder": "^1.0.0",
58+
"@azure/identity": "^2.0.1"
59+
},
60+
"devDependencies": {
61+
"@azure/dev-tool": "^1.0.0",
62+
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
63+
"@types/node": "^12.0.0",
64+
"eslint": "^7.15.0",
65+
"prettier": "^1.16.4",
66+
"rimraf": "^3.0.0",
67+
"rollup": "^1.16.3",
68+
"typescript": "~4.2.0"
69+
}
70+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
2+
3+
export default makeConfig(require("./package.json"));

0 commit comments

Comments
 (0)