Skip to content

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

Merged
HarshaNalluru merged 29 commits intoAzure:mainfrom
HarshaNalluru:harshan/issue/recorder/19387
Dec 17, 2021
Merged

[Unified Recorder] New test-utils package for test credential#19423
HarshaNalluru merged 29 commits intoAzure:mainfrom
HarshaNalluru:harshan/issue/recorder/19387

Conversation

@HarshaNalluru
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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.

"@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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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

HarshaNalluru and others added 9 commits December 17, 2021 11:50
Co-authored-by: Will Temple <witemple@microsoft.com>
Co-authored-by: Will Temple <witemple@microsoft.com>
Co-authored-by: Will Temple <witemple@microsoft.com>
Co-authored-by: Will Temple <witemple@microsoft.com>
Co-authored-by: Will Temple <witemple@microsoft.com>
Copy link
Copy Markdown
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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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

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.

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
Copy Markdown
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
Copy Markdown

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) <v-ziweichen@microsoft.com>
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