Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unified Recorder] New test-utils package for test credential #19423

Merged
merged 29 commits into from
Dec 17, 2021

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Dec 17, 2021

Provides the credential to be used in the tests. NoOpCredential in playback and ClientSecretCredential in record/live modes.

Fixes #19387

@HarshaNalluru HarshaNalluru changed the title [Unified Recorder] New package for test credential [Unified Recorder] New test-utils package for test credential Dec 17, 2021
"packageName": "@azure-tools/identity-extensions",
"projectFolder": "sdk/test-utils/identity-extensions",
"versionPolicyName": "utility"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Moving fast 🔥


import { ClientSecretCredential } from "@azure/identity";
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
import { NoOpCredential } from "@azure-tools/test-recorder-new";
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn’t NoOpCredential be moved to this package?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, can be done

Copy link
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

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

Very nice to see this quickly.

sdk/test-utils/identity-extensions/src/index.ts Outdated Show resolved Hide resolved
sdk/test-utils/identity-extensions/package.json Outdated Show resolved Hide resolved
sdk/test-utils/identity-extensions/README.md Outdated Show resolved Hide resolved
sdk/test-utils/identity-extensions/README.md Outdated Show resolved Hide resolved
sdk/test-utils/identity-extensions/README.md Outdated Show resolved Hide resolved
sdk/test-utils/identity-extensions/README.md Outdated Show resolved Hide resolved
"@azure/core-auth": "^1.3.2",
"@azure-tools/test-recorder": "^1.0.0",
"@azure-tools/test-recorder-new": "1.0.0",
"@azure/identity": "^2.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Identity currently uses the recorder. Wouldn’t it be an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

identity depends on

  • recorder

test-utils/identity-extensions depends on

  • recorder
  • identity

every other SDK will depend on

  • recorder
  • identity
  • test-utils/identity-extensions

Copy link
Member Author

Choose a reason for hiding this comment

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

identity doesn't depend on test-utils/identity-extensions, so there should not be a problem

Copy link
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

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

LGTM

sdk/test-utils/test-credential/README.md Show resolved Hide resolved
sdk/test-utils/test-credential/package.json Outdated Show resolved Hide resolved
sdk/test-utils/test-credential/package.json Outdated Show resolved Hide resolved
sdk/test-utils/test-credential/package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@sadasant sadasant left a comment

Choose a reason for hiding this comment

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

Let’s go! 🚀

* - returns the ClientSecretCredential (expects AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET in your environment or in the .env file)
* - AAD traffic won't be recorded if this credential is used.
*/
export function createTestCredential() {
Copy link
Member

Choose a reason for hiding this comment

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

please take an optional TokenCredentialOptions parameter.

Copy link
Member Author

@HarshaNalluru HarshaNalluru Dec 17, 2021

Choose a reason for hiding this comment

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

Added that.

Should I do CSC options instead?
image
** CSCOptions extends TokenCredentialOptions

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I haven't seen the need to use the persistence option, but @sadasant can advise here.

Copy link
Member

Choose a reason for hiding this comment

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

I would leave it as TokenCredentialOptions to avoid guaranteeing that this API uses CSC in the back end. I am optimistic that we can eventually make this work with DefaultAzureCredential, even if we have to plumb something through the karma request pipeline.

Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

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

Looks good!

@HarshaNalluru HarshaNalluru enabled auto-merge (squash) December 17, 2021 21:45
@HarshaNalluru HarshaNalluru merged commit e2eea7e into Azure:main Dec 17, 2021
@HarshaNalluru HarshaNalluru deleted the harshan/issue/recorder/19387 branch December 17, 2021 22:03
@Neo-wise
Copy link

Neo-wise commented Apr 9, 2022

Very nice to see this quickly.

azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request Jun 14, 2022
modify servicefabricmesh parameters (Azure#19423)

Co-authored-by: ZiWei Chen (WICRESOFT NORTH AMERICA LTD) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Unified Recorder] NoOpCredential helper
9 participants