Skip to content

Commit 57bf403

Browse files
nvborisenkoRenderMichael
andauthoredApr 3, 2025··
[dotnet] [bidi] Make ContinueWithAuthCommand closer to spec (breaking change) (#15545)
Co-authored-by: Michael Render <[email protected]>
1 parent aef3918 commit 57bf403

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed
 

‎dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
120120
[JsonSerializable(typeof(Modules.BrowsingContext.UserPromptOpenedEventArgs))]
121121
[JsonSerializable(typeof(Modules.BrowsingContext.UserPromptClosedEventArgs))]
122122

123-
[JsonSerializable(typeof(Modules.Network.ContinueWithAuthParameters.Default), TypeInfoPropertyName = "Network_ContinueWithAuthParameters_Default")]
124123
[JsonSerializable(typeof(Modules.Network.AddInterceptCommand))]
125124
[JsonSerializable(typeof(Modules.Network.AddInterceptResult))]
126125
[JsonSerializable(typeof(Modules.Network.ContinueRequestCommand))]

‎dotnet/src/webdriver/BiDi/Modules/Network/ContinueWithAuthCommand.cs

+17-11
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,26 @@ internal class ContinueWithAuthCommand(ContinueWithAuthParameters @params)
2626
: Command<ContinueWithAuthParameters>(@params, "network.continueWithAuth");
2727

2828
[JsonPolymorphic(TypeDiscriminatorPropertyName = "action")]
29-
[JsonDerivedType(typeof(Credentials), "provideCredentials")]
30-
[JsonDerivedType(typeof(Default), "default")]
31-
[JsonDerivedType(typeof(Cancel), "cancel")]
32-
internal abstract record ContinueWithAuthParameters(Request Request) : CommandParameters
33-
{
34-
internal record Credentials(Request Request, [property: JsonPropertyName("credentials")] AuthCredentials AuthCredentials) : ContinueWithAuthParameters(Request);
29+
[JsonDerivedType(typeof(ContinueWithAuthCredentials), "provideCredentials")]
30+
[JsonDerivedType(typeof(ContinueWithAuthDefaultCredentials), "default")]
31+
[JsonDerivedType(typeof(ContinueWithAuthCancelCredentials), "cancel")]
32+
internal abstract record ContinueWithAuthParameters(Request Request) : CommandParameters;
3533

36-
internal record Default(Request Request) : ContinueWithAuthParameters(Request);
34+
internal record ContinueWithAuthCredentials(Request Request, AuthCredentials Credentials) : ContinueWithAuthParameters(Request);
3735

38-
internal record Cancel(Request Request) : ContinueWithAuthParameters(Request);
39-
}
36+
internal abstract record ContinueWithAuthNoCredentials(Request Request) : ContinueWithAuthParameters(Request);
37+
38+
internal record ContinueWithAuthDefaultCredentials(Request Request) : ContinueWithAuthNoCredentials(Request);
39+
40+
internal record ContinueWithAuthCancelCredentials(Request Request) : ContinueWithAuthNoCredentials(Request);
4041

4142
public record ContinueWithAuthOptions : CommandOptions;
4243

43-
public record ContinueWithDefaultAuthOptions : CommandOptions;
44+
public record ContinueWithAuthCredentialsOptions : ContinueWithAuthOptions;
45+
46+
public record ContinueWithAuthNoCredentialsOptions : ContinueWithAuthOptions;
47+
48+
public record ContinueWithAuthDefaultCredentialsOptions : ContinueWithAuthNoCredentialsOptions;
49+
50+
public record ContinueWithAuthCancelCredentialsOptions : ContinueWithAuthNoCredentialsOptions;
4451

45-
public record ContinueWithCancelledAuthOptions : CommandOptions;

‎dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@ internal async Task ProvideResponseAsync(Request request, ProvideResponseOptions
104104
await Broker.ExecuteCommandAsync(new ProvideResponseCommand(@params), options).ConfigureAwait(false);
105105
}
106106

107-
internal async Task ContinueWithAuthAsync(Request request, AuthCredentials credentials, ContinueWithAuthOptions? options = null)
107+
internal async Task ContinueWithAuthAsync(Request request, AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null)
108108
{
109-
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthParameters.Credentials(request, credentials)), options).ConfigureAwait(false);
109+
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthCredentials(request, credentials)), options).ConfigureAwait(false);
110110
}
111111

112-
internal async Task ContinueWithAuthAsync(Request request, ContinueWithDefaultAuthOptions? options = null)
112+
internal async Task ContinueWithAuthAsync(Request request, ContinueWithAuthDefaultCredentialsOptions? options = null)
113113
{
114-
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthParameters.Default(request)), options).ConfigureAwait(false);
114+
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthDefaultCredentials(request)), options).ConfigureAwait(false);
115115
}
116116

117-
internal async Task ContinueWithAuthAsync(Request request, ContinueWithCancelledAuthOptions? options = null)
117+
internal async Task ContinueWithAuthAsync(Request request, ContinueWithAuthCancelCredentialsOptions? options = null)
118118
{
119-
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthParameters.Cancel(request)), options).ConfigureAwait(false);
119+
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthCancelCredentials(request)), options).ConfigureAwait(false);
120120
}
121121

122122
public async Task<Subscription> OnBeforeRequestSentAsync(Func<BeforeRequestSentEventArgs, Task> handler, SubscriptionOptions? options = null)

‎dotnet/src/webdriver/BiDi/Modules/Network/Request.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ public Task ContinueResponseAsync(ContinueResponseOptions? options = null)
5353
return _bidi.Network.ContinueResponseAsync(this, options);
5454
}
5555

56-
public Task ContinueWithAuthAsync(AuthCredentials credentials, ContinueWithAuthOptions? options = null)
56+
public Task ContinueWithAuthAsync(AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null)
5757
{
5858
return _bidi.Network.ContinueWithAuthAsync(this, credentials, options);
5959
}
6060

61-
public Task ContinueWithAuthAsync(ContinueWithDefaultAuthOptions? options = null)
61+
public Task ContinueWithAuthAsync(ContinueWithAuthDefaultCredentialsOptions? options = null)
6262
{
6363
return _bidi.Network.ContinueWithAuthAsync(this, options);
6464
}
6565

66-
public Task ContinueWithAuthAsync(ContinueWithCancelledAuthOptions? options = null)
66+
public Task ContinueWithAuthAsync(ContinueWithAuthCancelCredentialsOptions? options = null)
6767
{
6868
return _bidi.Network.ContinueWithAuthAsync(this, options);
6969
}

‎dotnet/test/common/BiDi/Network/NetworkTest.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ public async Task CanContinueWithAuthCredentials()
162162
{
163163
await using var intercept = await bidi.Network.InterceptAuthAsync(async e =>
164164
{
165-
//TODO Seems it would be better to have method which takes abstract options
166165
await e.Request.Request.ContinueWithAuthAsync(new AuthCredentials("test", "test"));
167166
});
168167

@@ -177,7 +176,7 @@ public async Task CanContinueWithDefaultCredentials()
177176
{
178177
await using var intercept = await bidi.Network.InterceptAuthAsync(async e =>
179178
{
180-
await e.Request.Request.ContinueWithAuthAsync(new ContinueWithDefaultAuthOptions());
179+
await e.Request.Request.ContinueWithAuthAsync(new ContinueWithAuthDefaultCredentialsOptions());
181180
});
182181

183182
var action = async () => await context.NavigateAsync(UrlBuilder.WhereIs("basicAuth"), new() { Wait = ReadinessState.Complete });
@@ -191,7 +190,7 @@ public async Task CanContinueWithCanceledCredentials()
191190
{
192191
await using var intercept = await bidi.Network.InterceptAuthAsync(async e =>
193192
{
194-
await e.Request.Request.ContinueWithAuthAsync(new ContinueWithCancelledAuthOptions());
193+
await e.Request.Request.ContinueWithAuthAsync(new ContinueWithAuthCancelCredentialsOptions());
195194
});
196195

197196
var action = async () => await context.NavigateAsync(UrlBuilder.WhereIs("basicAuth"), new() { Wait = ReadinessState.Complete });

0 commit comments

Comments
 (0)
Please sign in to comment.