From 7911d9296342fbca3d19c8779894156c77cd6e9e Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:31:26 +0300 Subject: [PATCH] [dotnet] [bidi] Decouple AuthCredentials in Network module --- .../src/webdriver/BiDi/Modules/Network/AuthCredentials.cs | 7 +++---- dotnet/test/common/BiDi/Network/NetworkTest.cs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/AuthCredentials.cs b/dotnet/src/webdriver/BiDi/Modules/Network/AuthCredentials.cs index 9178e32af2efd..f3bd0343a557b 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/AuthCredentials.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/AuthCredentials.cs @@ -21,11 +21,10 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(Basic), "password")] -public abstract record AuthCredentials +public record AuthCredentials(string Username, string Password) { - public record Basic(string Username, string Password) : AuthCredentials; + [JsonInclude] + internal string Type { get; } = "password"; } diff --git a/dotnet/test/common/BiDi/Network/NetworkTest.cs b/dotnet/test/common/BiDi/Network/NetworkTest.cs index 9a6c457e69e0e..2773d539dbb37 100644 --- a/dotnet/test/common/BiDi/Network/NetworkTest.cs +++ b/dotnet/test/common/BiDi/Network/NetworkTest.cs @@ -163,7 +163,7 @@ public async Task CanContinueWithAuthCredentials() await using var intercept = await bidi.Network.InterceptAuthAsync(async e => { //TODO Seems it would be better to have method which takes abstract options - await e.Request.Request.ContinueWithAuthAsync(new AuthCredentials.Basic("test", "test")); + await e.Request.Request.ContinueWithAuthAsync(new AuthCredentials("test", "test")); }); await context.NavigateAsync(UrlBuilder.WhereIs("basicAuth"), new() { Wait = ReadinessState.Complete });