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

fix(playwrighttesting): no auth error when scalable scenario is disabled #47050

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using NUnit.Framework;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Threading;
using System;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger;

namespace Azure.Developer.MicrosoftPlaywrightTesting.NUnit;
Expand Down Expand Up @@ -45,6 +45,10 @@ public PlaywrightServiceNUnit(TokenCredential? credential = null)
[OneTimeSetUp]
public async Task SetupAsync()
{
if (!UseCloudHostedBrowsers)
return;
TestContext.Progress.WriteLine("\nRunning tests using Microsoft Playwright Testing service.\n");

await InitializeAsync().ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public async Task InitializeAsync(CancellationToken cancellationToken = default)
// Since playwright-dotnet checks PLAYWRIGHT_SERVICE_ACCESS_TOKEN and PLAYWRIGHT_SERVICE_URL to be set, remove PLAYWRIGHT_SERVICE_URL so that tests are run locally.
// If customers use GetConnectOptionsAsync, after setting disableScalableExecution, an error will be thrown.
Environment.SetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceUri, null);
return;
Sid200026 marked this conversation as resolved.
Show resolved Hide resolved
}
// If default auth mechanism is Access token and token is available in the environment variable, no need to setup rotation handler
if (ServiceAuth == ServiceAuthType.AccessToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public void Initialize_WhenDefaultAuthIsEntraIdAccessTokenAndAccessTokenEnvironm
Assert.That(Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceUri), Is.Not.Null);

service.InitializeAsync().Wait();
defaultAzureCredentialMock.Verify(x => x.GetTokenAsync(It.IsAny<TokenRequestContext>(), It.IsAny<CancellationToken>()), Times.Once);
defaultAzureCredentialMock.Verify(x => x.GetTokenAsync(It.IsAny<TokenRequestContext>(), It.IsAny<CancellationToken>()), Times.Never);

service.RotationTimer!.Dispose();
Assert.That(service.RotationTimer, Is.Null);

Assert.That(Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceUri), Is.Null);
}
Expand Down
Loading