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

[identity] Re-enable tests #29778

Merged
merged 4 commits into from
May 21, 2024
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
2 changes: 1 addition & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/identity/identity/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "js",
"TagPrefix": "js/identity/identity",
"Tag": "js/identity/identity_a7eb8b7286"
"Tag": "js/identity/identity_41bcaec991"
}
2 changes: 1 addition & 1 deletion sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"test:node": "npm run clean && npm run unit-test:node && npm run integration-test:node",
"test": "npm run clean && npm run build:test && npm run unit-test && npm run integration-test",
"unit-test:browser": "dev-tool run test:browser",
"unit-test:node": "echo skipped",
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 300000 --exclude 'test/**/browser/**/*.spec.ts' --exclude 'test/integration/**/*.spec.ts' 'test/**/**/*.spec.ts'",
"unit-test:node:no-timeouts": "dev-tool run test:node-ts-input -- --timeout Infinite --exclude 'test/**/browser/**/*.spec.ts' 'test/**/**/*.spec.ts'",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
},
Expand Down
4 changes: 2 additions & 2 deletions sdk/identity/identity/test/node/msalNodeTestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ export async function msalNodeTestSetup(
{
regex: true,
target: `x-client-OS=[a-zA-Z0-9]+`,
value: `x-client-OS=x-client-OS`,
value: `x-client-OS=Sanitized`,
Copy link
Member Author

Choose a reason for hiding this comment

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

This really ended up being the only diff.., It was getting double-sanitized so replacing it with something that is not the key itself prevents it. I don't understand why or how it works, but let's get tests running again 😄

Copy link
Member

Choose a reason for hiding this comment

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

Maybe double sanitized, because we might be calling the same function twice at 2 different places - one might be getting called from inside of another file?

},
{
regex: true,
target: `x-client-CPU=[a-zA-Z0-9]+`,
value: `x-client-CPU=x-client-CPU`,
value: `x-client-CPU=Sanitized`,
},
{
regex: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { EnvironmentCredential, getBearerTokenProvider } from "../../../src";
import { DefaultAzureCredential, getBearerTokenProvider } from "../../../src";
import { MsalTestCleanup, msalNodeTestSetup } from "../../node/msalNodeTestSetup";
import { Recorder, delay, isPlaybackMode } from "@azure-tools/test-recorder";
import { Context } from "mocha";
Expand All @@ -23,7 +23,7 @@ describe("getBearerTokenProvider", function () {
const scope = "https://vault.azure.net/.default";

it("returns a callback that returns string tokens", async function () {
const credential = new EnvironmentCredential(recorder.configureClientOptions({}));
const credential = new DefaultAzureCredential(recorder.configureClientOptions({}));
Copy link
Member Author

Choose a reason for hiding this comment

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

I need to think through this a bit. But it's probably fine for now...

Copy link
Member

@KarishmaGhiya KarishmaGhiya May 21, 2024

Choose a reason for hiding this comment

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

Yeah how do we know which cred it picks up in the unit tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just wanted to say that I agree with your question 😄 it's not clear or deterministic.

Now that CI / recorded tests are running and green again, I plan to review our tests in live mode. I'll revisit this one and choose a more specific credential as part of that. Thanks for following up with me offline!


const getAccessToken = getBearerTokenProvider(credential, scope);

Expand Down
15 changes: 8 additions & 7 deletions sdk/identity/test-resources-pre.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ param (

)

Import-Module -Name $PSScriptRoot/../../eng/common/scripts/X509Certificate2 -Verbose

Remove-Item $PSScriptRoot/sshKey* -Force
ssh-keygen -t rsa -b 4096 -f $PSScriptRoot/sshKey -N '' -C ''
$sshKey = Get-Content $PSScriptRoot/sshKey.pub

$templateFileParameters['sshPubKey'] = $sshKey
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a required item in the template, so we should be generating it always. Otherwise, you cannot deploy test resources


if (!$CI) {
# TODO: Remove this once auto-cloud config downloads are supported locally
Write-Host "Skipping cert setup in local testing mode"
Expand Down Expand Up @@ -45,13 +53,6 @@ Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_PEM;]$pemPath"
$env:IDENTITY_SP_CERT_PFX = $pfxPath
$env:IDENTITY_SP_CERT_PEM = $pemPath

Import-Module -Name $PSScriptRoot/../../eng/common/scripts/X509Certificate2 -Verbose

Remove-Item $PSScriptRoot/sshKey* -Force
ssh-keygen -t rsa -b 4096 -f $PSScriptRoot/sshKey -N '' -C ''
$sshKey = Get-Content $PSScriptRoot/sshKey.pub

$templateFileParameters['sshPubKey'] = $sshKey

if ($CI) {
# Install this specific version of the Azure CLI to avoid https://github.com/Azure/azure-cli/issues/28358.
Expand Down
Loading