From 31c841842e78d9f6441bdf316b3d5cd7f011e64f Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Tue, 29 Aug 2023 12:21:24 -0400 Subject: [PATCH] [dotnet] Add test for Basic Auth using bidi network interception --- .../test/common/NetworkInterceptionTests.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dotnet/test/common/NetworkInterceptionTests.cs b/dotnet/test/common/NetworkInterceptionTests.cs index 6d29a8d41eaeb..0a908f57499a0 100644 --- a/dotnet/test/common/NetworkInterceptionTests.cs +++ b/dotnet/test/common/NetworkInterceptionTests.cs @@ -33,5 +33,25 @@ public async Task TestCanInterceptNetworkCalls() Assert.AreEqual("I intercepted you", text); } } + + [Test] + public async Task TestCanUseAuthorizationHandler() + { + if (driver is IDevTools) + { + INetwork network = driver.Manage().Network; + NetworkAuthenticationHandler handler = new NetworkAuthenticationHandler() + { + UriMatcher = (uri) => uri.PathAndQuery.Contains("basicAuth"), + Credentials = new PasswordCredentials("test", "test") + }; + network.AddAuthenticationHandler(handler); + await network.StartMonitoring(); + driver.Url = authenticationPage; + string text = driver.FindElement(By.CssSelector("h1")).Text; + await network.StopMonitoring(); + Assert.AreEqual("authorized", text); + } + } } }