Skip to content

Commit

Permalink
[dotnet] Add test for Basic Auth using bidi network interception
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Aug 29, 2023
1 parent 87787e4 commit 31c8418
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions dotnet/test/common/NetworkInterceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

0 comments on commit 31c8418

Please sign in to comment.