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

[test-credential] DAC update #29577

Merged
merged 14 commits into from May 6, 2024

Conversation

HarshaNalluru
Copy link
Member

Packages impacted by this PR

@azure-tools/test-credential

Describe the problem that is addressed by this PR

Need to move away from client secrets in the dev workflow.

Breaking Changes

Updates the createTestCredential method to consume DefaultAzureCredential instead of ClientSecretCredential in order to offer autonomy to the devs and to move away from clietn secrets in environment varaibles.

TO DO

Hotfix 1.x release with the same change.

@github-actions github-actions bot added the test-utils Label for the issues related to the @azure/test-utils package label May 3, 2024
@HarshaNalluru HarshaNalluru changed the title [test-credential] DAZ update [test-credential] DAC update May 6, 2024
@HarshaNalluru HarshaNalluru merged commit 5071f20 into Azure:main May 6, 2024
24 checks passed
@HarshaNalluru HarshaNalluru deleted the harshan/test-credential branch May 6, 2024 22:18
timovv added a commit that referenced this pull request May 9, 2024
### Packages impacted by this PR

- `@azure-tools/dev-tool`
- `@azure-tools/test-credential`

### Describe the problem that is addressed by this PR

We want to move to user auth and `DefaultAzureCredential` to
authenticate our tests, but `DefaultAzureCredential` does not work in
the browser, blocking this transition.

This PR proposes a solution -- create a short-lived, local-only, server
which can create tokens in Node using DefaultAzureCredential. In the
browser, createTestCredential provides a credential implementation which
calls this server whenever it needs a token, and the server relays the
request to DefaultAzureCredential.

Here's what's changed:

- `test-credential` now returns a credential which requests tokens from
a local web endpoint when running browser tests against a live service.
- `dev-tool` contains an implementation of this web endpoint. The
dev-tool scripts used to run browser tests now start this server
automatically when running browser tests. A separate command to start
the server is also provided for pipelines.
- Update live test pipelines to start the server when running browser
tests.

### Provide a list of related PRs _(if any)_

- Draft version with loads of commits and `/azp run` spam: #29581 
- Harsha's earlier PR to enable DefaultAzureCredential:
#29577
HarshaNalluru added a commit to HarshaNalluru/azure-sdk-for-js that referenced this pull request May 9, 2024
`@azure-tools/test-credential`

Need to move away from client secrets in the dev workflow.

Updates the `createTestCredential` method to consume
`DefaultAzureCredential` instead of `ClientSecretCredential` in order to
offer autonomy to the devs and to move away from clietn secrets in
environment varaibles.

- `NoOpCredential` is offered for playback and `DefaultAzureCredential`
in record/live modes.
- [`User Auth` and `Auth via development
tools`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#authenticate-users)
are preferred in record mode to record the tests.

Hotfix 1.x release with the same change.

---------

Co-authored-by: Timo van Veenendaal <me@timo.nz>
HarshaNalluru pushed a commit to HarshaNalluru/azure-sdk-for-js that referenced this pull request May 9, 2024
- `@azure-tools/dev-tool`
- `@azure-tools/test-credential`

We want to move to user auth and `DefaultAzureCredential` to
authenticate our tests, but `DefaultAzureCredential` does not work in
the browser, blocking this transition.

This PR proposes a solution -- create a short-lived, local-only, server
which can create tokens in Node using DefaultAzureCredential. In the
browser, createTestCredential provides a credential implementation which
calls this server whenever it needs a token, and the server relays the
request to DefaultAzureCredential.

Here's what's changed:

- `test-credential` now returns a credential which requests tokens from
a local web endpoint when running browser tests against a live service.
- `dev-tool` contains an implementation of this web endpoint. The
dev-tool scripts used to run browser tests now start this server
automatically when running browser tests. A separate command to start
the server is also provided for pipelines.
- Update live test pipelines to start the server when running browser
tests.

- Draft version with loads of commits and `/azp run` spam: Azure#29581
- Harsha's earlier PR to enable DefaultAzureCredential:
Azure#29577
HarshaNalluru added a commit that referenced this pull request May 9, 2024
…t-credential (#29641)

### Packages impacted by this PR
`@azure-tools/test-credential@1.1.0`

### What's happening?

`test-credential 2.x` is for `test-recorder 4.x`
`test-credential 1.x` is for `test-recorder 3.x`

The only difference between test-credential 2.x and test-credential 1.x
is that it consumes the new env support with vitest
[azure-sdk-for-js/sdk/test-utils/test-credential/CHANGELOG.md at main ·
Azure/azure-sdk-for-js
(github.com)](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/test-utils/test-credential/CHANGELOG.md#200-2024-04-09)

New changes went in `test-credential v2` as part of the spring grove
effort as part of #29577 and #29616.
Cherrypicking those changes into `test-credential v1` is necessary to
address the spring grove efforts. This PR aims to accomplish that for
1.1.0 version of `@azure-tools/test-credential`.

Next step is to publish `@azure-tools/test-credential@1.1.0` package so
that sdks relying on recorder v3 can leverage the package.

---------

Co-authored-by: Timo van Veenendaal <me@timo.nz>
Co-authored-by: Timo van Veenendaal <timov@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test-utils Label for the issues related to the @azure/test-utils package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants