Skip to content

[dotnet] [test] In-process test webserver#17339

Merged
nvborisenko merged 20 commits intoSeleniumHQ:trunkfrom
nvborisenko:dotnet-test-webserver
Apr 12, 2026
Merged

[dotnet] [test] In-process test webserver#17339
nvborisenko merged 20 commits intoSeleniumHQ:trunkfrom
nvborisenko:dotnet-test-webserver

Conversation

@nvborisenko
Copy link
Copy Markdown
Member

Don't use Java test webserver, use dotnet based.

  • In process (fast), removed ceremony of external process management
  • Used shared common static html pages
  • Align how py/rb/js does internal testing

🔗 Related Issues

Contributes to #15536

💥 What does this PR do?

This pull request introduces a reusable .NET test web server for Selenium tests and integrates it into the test infrastructure. The main changes include adding the new Selenium.Testing.WebServer project, implementing various HTTP handlers for test scenarios, and updating test builds to consume the new web server.

Addition of reusable test web server:

  • Added the new Selenium.Testing.WebServer project (Selenium.Testing.WebServer.csproj) containing the AppServer class, which hosts an ASP.NET Core web server for Selenium tests. This server provides endpoints for authentication, cookies, echoing requests, custom page creation, file uploads, and more. [1] [2]
  • Implemented handler classes for key test endpoints, including BasicAuthHandler, CookieHandler, CreatePageHandler, EchoHandler, and EncodingHandler, each providing HTTP endpoints for Selenium test scenarios. [1] [2] [3] [4] [5]

Integration into test infrastructure:

  • Registered the new web server project in the solution file (Selenium.slnx) and as a dependency in relevant test projects and Bazel build files, ensuring that test suites can use the shared web server. [1] [2] [3] [4]

Test suite configuration improvements:

  • Updated Bazel build rules to set project_sdk = "web" and add the web server as a dependency for remote and support test suites, enabling seamless use of the test server in test runs. [1] [2]

Cleanup of test suite parameters:

  • Simplified conditional logic in _BROWSERS within dotnet_nunit_test_suite.bzl by removing the default skip condition for unsupported browsers, making test execution logic more straightforward. [1] [2] [3]

🔧 Implementation Notes

New testing namespace for testing :)

🔄 Types of changes

  • Cleanup (formatting, renaming)

Copilot AI review requested due to automatic review settings April 12, 2026 09:37
@selenium-ci selenium-ci added C-dotnet .NET Bindings B-build Includes scripting, bazel and CI integrations B-support Issue or PR related to support classes labels Apr 12, 2026
@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Replace Java test webserver with in-process .NET ASP.NET Core implementation

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replaces Java-based test webserver with in-process .NET ASP.NET Core implementation
• Adds Selenium.Testing.WebServer project with HTTP handlers for test scenarios
• Simplifies test infrastructure by removing external process management
• Updates test configuration to use dynamic port allocation and /common path mapping

Grey Divider

File Changes

1. dotnet/test/testing.webserver/AppServer.cs ✨ Enhancement +137/-0

Core ASP.NET web server implementation with endpoint routing

dotnet/test/testing.webserver/AppServer.cs


2. dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs ✨ Enhancement +52/-0

HTTP basic authentication handler for test scenarios

dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs


3. dotnet/test/testing.webserver/Handlers/CookieHandler.cs ✨ Enhancement +93/-0

Cookie management handler for add/delete/deleteAll operations

dotnet/test/testing.webserver/Handlers/CookieHandler.cs


View more (26)
4. dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs ✨ Enhancement +60/-0

Dynamic page creation and serving handler

dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs


5. dotnet/test/testing.webserver/Handlers/EchoHandler.cs ✨ Enhancement +64/-0

Request echo handler for method/headers/body inspection

dotnet/test/testing.webserver/Handlers/EchoHandler.cs


6. dotnet/test/testing.webserver/Handlers/EncodingHandler.cs ✨ Enhancement +39/-0

Character encoding test handler for UTF-16 responses

dotnet/test/testing.webserver/Handlers/EncodingHandler.cs


7. dotnet/test/testing.webserver/Handlers/FedCmHandler.cs ✨ Enhancement +53/-0

Federated Credential Management protocol handler

dotnet/test/testing.webserver/Handlers/FedCmHandler.cs


8. dotnet/test/testing.webserver/Handlers/PageHandler.cs ✨ Enhancement +15/-11

Dynamic test page generation with page number parameter

dotnet/test/testing.webserver/Handlers/PageHandler.cs


9. dotnet/test/testing.webserver/Handlers/RedirectHandler.cs ✨ Enhancement +13/-11

HTTP redirect handler for navigation testing

dotnet/test/testing.webserver/Handlers/RedirectHandler.cs


10. dotnet/test/testing.webserver/Handlers/SleepHandler.cs ✨ Enhancement +43/-0

Delayed response handler for timeout testing

dotnet/test/testing.webserver/Handlers/SleepHandler.cs


11. dotnet/test/testing.webserver/Handlers/UploadHandler.cs ✨ Enhancement +47/-0

File upload handler with artificial delay

dotnet/test/testing.webserver/Handlers/UploadHandler.cs


12. dotnet/test/testing.webserver/Handlers/Utf8Handler.cs ✨ Enhancement +41/-0

UTF-8 file serving handler from web content root

dotnet/test/testing.webserver/Handlers/Utf8Handler.cs


13. dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj ⚙️ Configuration changes +14/-0

Project file for .NET webserver library

dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj


14. dotnet/test/testing.webserver/BUILD.bazel ⚙️ Configuration changes +18/-0

Bazel build configuration for webserver library

dotnet/test/testing.webserver/BUILD.bazel


15. dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs 🐞 Bug fix +33/-77

Migrate from Java webserver to in-process AppServer

dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs


16. dotnet/test/webdriver/Infrastructure/Environment/TestEnvironment.cs 🐞 Bug fix +0/-6

Remove website and webserver configuration classes

dotnet/test/webdriver/Infrastructure/Environment/TestEnvironment.cs


17. dotnet/test/webdriver/Infrastructure/Environment/TestWebServer.cs 🐞 Bug fix +0/-164

Remove Java-based external webserver implementation

dotnet/test/webdriver/Infrastructure/Environment/TestWebServer.cs


18. dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs 🐞 Bug fix +7/-29

Simplify URL builder to use dynamic port and /common path

dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs


19. dotnet/test/webdriver/CookieImplementationTests.cs 🐞 Bug fix +10/-15

Update cookie tests to use /common path mapping

dotnet/test/webdriver/CookieImplementationTests.cs


20. dotnet/test/webdriver/PositionAndSizeTests.cs 🐞 Bug fix +4/-4

Fix decimal parsing with culture-invariant format

dotnet/test/webdriver/PositionAndSizeTests.cs


21. dotnet/Selenium.slnx ⚙️ Configuration changes +1/-0

Add webserver project to solution file

dotnet/Selenium.slnx


22. dotnet/test/webdriver/BUILD.bazel ⚙️ Configuration changes +2/-2

Remove Java appserver dependency, add webserver project

dotnet/test/webdriver/BUILD.bazel


23. dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj ⚙️ Configuration changes +1/-4

Add webserver project reference, remove Java build target

dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj


24. dotnet/test/remote/BUILD.bazel ⚙️ Configuration changes +2/-0

Add webserver project dependency and web SDK

dotnet/test/remote/BUILD.bazel


25. dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj ⚙️ Configuration changes +0/-0

Add webserver project reference

dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj


26. dotnet/test/support/BUILD.bazel ⚙️ Configuration changes +2/-0

Add webserver project dependency and web SDK

dotnet/test/support/BUILD.bazel


27. dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj ⚙️ Configuration changes +1/-0

Add webserver project reference

dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj


28. dotnet/private/dotnet_nunit_test_suite.bzl ⚙️ Configuration changes +3/-12

Remove local driver condition skips in test configuration

dotnet/private/dotnet_nunit_test_suite.bzl


29. dotnet/test/webdriver/appconfig.json ⚙️ Configuration changes +0/-22

Remove website and Java webserver configuration

dotnet/test/webdriver/appconfig.json


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Apr 12, 2026

Code Review by Qodo

🐞 Bugs (3)   📘 Rule violations (4)   📎 Requirement gaps (1)   🎨 UX Issues (0)
🐞\ ≡ Correctness (2) ☼ Reliability (1)
📘\ ☼ Reliability (3) ⛨ Security (1)
📎\ ☼ Reliability (1)

Grey Divider


Action required

1. SleepHandler parses time blindly 📘
Description
SleepHandler uses int.Parse(duration!) on the time query parameter without validating
presence/range, so malformed or negative values can throw unclear exceptions or break the request
flow. This violates the requirement to validate protocol-derived inputs early with clear exceptions.
Code

dotnet/test/testing.webserver/Handlers/SleepHandler.cs[R30-33]

+        string? duration = context.Request.Query["time"];
+        int seconds = int.Parse(duration!);
+
+        await Task.Delay(seconds * 1000);
Evidence
PR Compliance ID 14 requires early validation of external/protocol-derived inputs with clear errors.
The new handler reads time from the query string and immediately int.Parses it with a
null-forgiving operator, which will throw for missing/non-integer/negative values rather than
returning a clear, actionable response.

dotnet/test/testing.webserver/Handlers/SleepHandler.cs[30-33]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`/sleep` accepts the `time` query parameter but parses it with `int.Parse(duration!)` without validating it, leading to unhelpful exceptions on missing/invalid/negative input.

## Issue Context
This is protocol-derived input from HTTP requests, and compliance requires early validation with clear errors.

## Fix Focus Areas
- dotnet/test/testing.webserver/Handlers/SleepHandler.cs[30-33]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. CreatePageHandler trusts request JSON 📘
Description
CreatePageHandler deserializes the request body and immediately dereferences json! and
json!["content"] without validation, which can throw unclear exceptions on invalid JSON or missing
keys. This violates the requirement to validate external inputs early with clear exceptions.
Code

dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs[R40-42]

+        var json = JsonSerializer.Deserialize<Dictionary<string, string>>(body);
+        string content = json!["content"];
+
Evidence
PR Compliance ID 14 requires validating external/protocol-derived inputs before use and failing fast
with clear exceptions. The new handler assumes the body is valid JSON and contains a content key,
using null-forgiving and direct indexing that will throw
NullReferenceException/KeyNotFoundException instead of returning a clear 400 Bad Request.

dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs[40-42]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`/createPage` deserializes arbitrary request JSON and assumes `content` exists, which can throw runtime exceptions for invalid input.

## Issue Context
HTTP request bodies are external inputs and must be validated with clear error handling.

## Fix Focus Areas
- dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs[34-48]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Utf8Handler allows path traversal 📘
Description
Utf8Handler combines the user-controlled path with webContentRoot via Path.Combine without
normalizing/validating, allowing .. segments to escape the intended directory and read arbitrary
files. This violates the requirement to validate protocol-derived inputs early and safely.
Code

dotnet/test/testing.webserver/Handlers/Utf8Handler.cs[R28-34]

+    public static async Task<IResult> Handle(HttpContext context, string path, string webContentRoot)
+    {
+        string filePath = Path.Combine(webContentRoot, path);
+
+        if (!File.Exists(filePath))
+        {
+            return Results.NotFound();
Evidence
PR Compliance ID 14 requires validating external/protocol-derived inputs before use. The handler
takes a route-provided path, combines it directly into a filesystem path, and reads the file if it
exists, without ensuring it stays within webContentRoot.

dotnet/test/testing.webserver/Handlers/Utf8Handler.cs[28-39]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`Utf8Handler` builds `filePath` from a user-controlled route segment without validating it, which can allow directory traversal and unintended file reads.

## Issue Context
Even for a test server, this is protocol-derived input used for filesystem access and should be constrained to the intended content root.

## Fix Focus Areas
- dotnet/test/testing.webserver/Handlers/Utf8Handler.cs[28-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
4. Invalid header setters 🐞
Description
Multiple handlers assign headers via non-existent IHeaderDictionary properties (e.g.,
response.Headers.CacheControl, response.Headers.ContentType), which will not compile and will
block all test projects referencing Selenium.Testing.WebServer. This must be changed to use
HttpResponse.ContentType and Headers["..."] indexer assignments.
Code

dotnet/test/testing.webserver/Handlers/CookieHandler.cs[R33-36]

+        response.Headers.ContentType = "text/html";
+        response.Headers.CacheControl = "no-cache";
+        response.Headers.Pragma = "no-cache";
+        response.Headers.Expires = "0";
Evidence
HttpResponse.Headers is an IHeaderDictionary and does not expose typed properties like
ContentType, CacheControl, Pragma, or Expires; these lines therefore fail compilation. The
same invalid pattern appears in other new handlers too, so the webserver project cannot build as-is.

dotnet/test/testing.webserver/Handlers/CookieHandler.cs[28-37]
dotnet/test/testing.webserver/Handlers/SleepHandler.cs[28-41]
dotnet/test/testing.webserver/Handlers/EchoHandler.cs[50-63]
dotnet/test/testing.webserver/Handlers/FedCmHandler.cs[24-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Several handlers set HTTP headers using non-existent `IHeaderDictionary` properties (e.g., `response.Headers.CacheControl`, `response.Headers.ContentType`). This does not compile in ASP.NET Core.

### Issue Context
`HttpResponse.Headers` is a dictionary; set headers via `Headers["Header-Name"]` (or `Append`) and set content type via `HttpResponse.ContentType`.

### Fix Focus Areas
- dotnet/test/testing.webserver/Handlers/CookieHandler.cs[33-36]
- dotnet/test/testing.webserver/Handlers/SleepHandler.cs[37-39]
- dotnet/test/testing.webserver/Handlers/EchoHandler.cs[58-60]
- dotnet/test/testing.webserver/Handlers/FedCmHandler.cs[28-36]

### Notes
Use:
- `context.Response.ContentType = "text/html; charset=utf-8"` (or set via result)
- `context.Response.Headers["Cache-Control"] = "no-cache"`
- `context.Response.Headers["Pragma"] = "no-cache"`
- `context.Response.Headers["Expires"] = "0"`
- For no-store: `Headers["Cache-Control"] = "no-store"`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Loopback-only server bind 🐞
Description
AppServer binds only to 127.0.0.1, but UrlBuilder.WhereIsViaNonLoopbackAddress() (used by
active proxy tests) navigates to a non-loopback interface IP, which the server will not be listening
on. This will cause connection-refused failures in ProxySettingTests when navigating to the
non-loopback URL.
Code

dotnet/test/testing.webserver/AppServer.cs[45]

+        builder.WebHost.UseUrls("http://127.0.0.1:0");
Evidence
The web server is configured to listen only on 127.0.0.1. The URL builder explicitly selects a
non-loopback IPv4 address and builds a URL with that IP, and ProxySettingTests navigates to it in
a non-ignored test to validate proxy bypass behavior; since Kestrel is not bound to that interface,
the navigation will fail.

dotnet/test/testing.webserver/AppServer.cs[43-46]
dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs[63-76]
dotnet/test/webdriver/ProxySettingTests.cs[76-96]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new test server binds only to 127.0.0.1, but tests intentionally navigate using a non-loopback IP address (to exercise proxy bypass/proxying). This causes connection failures.

### Issue Context
`ProxySettingTests.CanConfigureNoProxy` navigates to `WhereIsViaNonLoopbackAddress(...)` and expects the server to be reachable on a non-loopback interface.

### Fix Focus Areas
- dotnet/test/testing.webserver/AppServer.cs[43-46]

### Suggested fix
Bind Kestrel to an address that accepts connections via the machine's non-loopback IP, e.g.:
- `builder.WebHost.UseUrls("http://0.0.0.0:0")` (or `http://*:0`), or
- configure Kestrel with `ListenAnyIP(0)`.

Also consider returning/propagating the chosen host so `UrlBuilder` remains consistent.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

6. Default browser gating removed 📘
Description
The Bazel NUnit suite no longer applies a default skip filter for Chrome/Edge/Firefox when
pinned/local browser configuration isn’t selected, risking tests running in unsupported
environments. This violates the requirement to gate integration tests based on
feature/driver/environment support.
Code

dotnet/private/dotnet_nunit_test_suite.bzl[R20-26]

                "--params=DriverServiceLocation=$(location @mac_chromedriver//:chromedriver)",
                "--params=BrowserLocation=$(location @mac_chrome//:Chrome.app)/Contents/MacOS/Chrome",
            ],
-            "@selenium//common:use_local_chromedriver": [],
-            "//conditions:default": [
-                "--where=SkipTest==True",
-            ],
+            "//conditions:default": [],
        }),
        "data": chrome_data,
        "tags": [],
Evidence
PR Compliance ID 16 requires gating integration tests to avoid failures in unsupported
CI/environment matrices. The updated _BROWSERS configuration removes the default
--where=SkipTest==True behavior for major browsers, meaning tests may now run without ensuring the
required browser/driver locations are configured.

dotnet/private/dotnet_nunit_test_suite.bzl[20-27]
dotnet/private/dotnet_nunit_test_suite.bzl[37-44]
dotnet/private/dotnet_nunit_test_suite.bzl[54-61]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Default gating for running browser-dependent NUnit tests appears to have been relaxed, which can cause tests to execute where required browser/driver support is not available.

## Issue Context
Compliance requires integration tests to be conditionally enabled based on environment/driver support to avoid cross-environment CI failures.

## Fix Focus Areas
- dotnet/private/dotnet_nunit_test_suite.bzl[20-27]
- dotnet/private/dotnet_nunit_test_suite.bzl[37-44]
- dotnet/private/dotnet_nunit_test_suite.bzl[54-61]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Tests still use EnvironmentManager.Instance 📎
Description
Modified test code continues to depend on the singleton EnvironmentManager.Instance, perpetuating
static/global test context that blocks safe parallelization. This violates the requirement to
eliminate static test infrastructure context to enable parallel execution.
Code

dotnet/test/webdriver/CookieImplementationTests.cs[741]

+        Cookie cookie = new Cookie("Bart", "Simpson", EnvironmentManager.Instance.UrlBuilder.HostName + ".com", "/common", null);
Evidence
PR Compliance ID 3 requires removing reliance on static/global test infrastructure context. The
changed test line still reads environment state via the global EnvironmentManager.Instance,
indicating the test infrastructure remains singleton-based and not parallelization-friendly.

Eliminate static test infrastructure context (e.g., EnvironmentManager) to enable parallelization
dotnet/test/webdriver/CookieImplementationTests.cs[741-741]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Tests continue to access driver/environment configuration through the singleton `EnvironmentManager.Instance`, which maintains global shared state and prevents safe parallelization.

## Issue Context
Compliance requires eliminating static/global test context to enable parallel test runs without cross-test interference.

## Fix Focus Areas
- dotnet/test/webdriver/CookieImplementationTests.cs[741-741]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Broken secure URL builder🐞
Description
UrlBuilder.WhereIsSecure() now returns an https:// URL using the same ephemeral port as the HTTP
server and drops the /common/ prefix, but AppServer only binds HTTP. Any usage of
WhereIsSecure() will fail to connect (and/or request the wrong path) when those tests are enabled.
Code

dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs[R78-81]

    public string WhereIsSecure(string page)
    {
-        string location = "https://" + HostName + ":" + securePort + "/" + Path + "/" + page;
-
-        return location;
+        return "https://" + HostName + ":" + port + "/" + page;
    }
Evidence
The URL builder constructs an HTTPS URL, but the server is only configured with an HTTP URL binding.
This makes the helper incorrect and will break secure-navigation tests when they are
un-ignored/re-enabled.

dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs[78-81]
dotnet/test/testing.webserver/AppServer.cs[43-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`WhereIsSecure()` returns an https URL even though the new server only starts HTTP.

### Issue Context
Many existing tests around insecure cert handling are currently `[Ignore("Unable to open secure url")]`, but the helper should still be correct to avoid future regressions.

### Fix Focus Areas
- dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs[78-81]
- dotnet/test/testing.webserver/AppServer.cs[41-85]

### Suggested fix options
1) Implement HTTPS in `AppServer` (configure Kestrel HTTPS + test cert) and keep `WhereIsSecure()`.
2) If HTTPS is intentionally not supported, change `WhereIsSecure()` to either:
  - return an HTTP URL (and rename the API), or
  - throw a clear exception indicating HTTPS is unsupported in this test server.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
9. BasicAuth Base64 can 500 🐞
Description
BasicAuthHandler calls Convert.FromBase64String without handling format errors; a malformed
Authorization: Basic ... header will throw and return 500 instead of 401. This can make
auth-related network/interception tests flaky if headers are modified or partially sent.
Code

dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs[R36-41]

+        if (authorization is not null && authorization.StartsWith("Basic "))
+        {
+            string encoded = authorization["Basic ".Length..];
+            string decoded = Encoding.UTF8.GetString(Convert.FromBase64String(encoded));
+            string[] parts = decoded.Split(':', 2);
+
Evidence
The handler decodes the Base64 payload without a try/catch; Convert.FromBase64String throws
FormatException for invalid input, which would propagate as a server error rather than a clean
unauthorized response.

dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs[34-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Malformed `Authorization` headers can crash the handler via `Convert.FromBase64String`, returning 500.

### Issue Context
This endpoint is used by auth tests (BiDi/network interception). Defensive behavior should return 401 for any invalid auth header.

### Fix Focus Areas
- dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs[34-46]

### Suggested fix
Wrap Base64 decode + split in a try/catch (FormatException/ArgumentException) and fall through to the existing 401 response.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@selenium-ci
Copy link
Copy Markdown
Member

Thank you, @nvborisenko for this code suggestion.

The support packages contain example code that many users find helpful, but they do not necessarily represent
the best practices for using Selenium, and the Selenium team is not currently merging changes to them.

After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium
to work, we will likely close the PR.

We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks.
If you have any questions, please contact us

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the existing Java-based external test webserver dependency for the .NET test suite with a new in-process ASP.NET Core-based test webserver, and updates .NET test/build wiring to use it.

Changes:

  • Added a new dotnet/test/testing.webserver project implementing an in-process ASP.NET Core test server (AppServer) plus several test handlers.
  • Updated the .NET test environment (EnvironmentManager, UrlBuilder, config) and some tests to use shared common/src/web fixtures via the new server.
  • Updated solution/Bazel build definitions to include the new webserver project and remove Java appserver/keystore dependencies.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj References the new test webserver project; removes Java appserver build target.
dotnet/test/webdriver/PositionAndSizeTests.cs Uses invariant-culture decimal parsing for CSS pixel values.
dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs Simplifies URL construction to target the new in-process server and shared /common paths.
dotnet/test/webdriver/Infrastructure/Environment/TestWebServer.cs Removes the old external-process Java webserver wrapper.
dotnet/test/webdriver/Infrastructure/Environment/TestEnvironment.cs Removes website/server config fields no longer needed with in-process hosting.
dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs Starts the new in-process AppServer and updates URL building/root discovery.
dotnet/test/webdriver/CookieImplementationTests.cs Updates paths/pages to align with shared common/src/web content layout.
dotnet/test/webdriver/BUILD.bazel Removes Java appserver/keystore data; adds web SDK and new webserver dep.
dotnet/test/webdriver/appconfig.json Removes website/webserver configuration sections.
dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj New .NET test webserver project definition (ASP.NET Core framework reference).
dotnet/test/testing.webserver/Handlers/Utf8Handler.cs New handler to serve UTF-8 content from shared web fixtures.
dotnet/test/testing.webserver/Handlers/UploadHandler.cs New handler for upload test scenarios.
dotnet/test/testing.webserver/Handlers/SleepHandler.cs New handler that delays responses for page load timeout tests.
dotnet/test/testing.webserver/Handlers/RedirectHandler.cs New handler for redirect scenarios.
dotnet/test/testing.webserver/Handlers/PageHandler.cs New handler to generate simple numbered pages.
dotnet/test/testing.webserver/Handlers/FedCmHandler.cs New handler endpoints for FedCM-related scenarios.
dotnet/test/testing.webserver/Handlers/EncodingHandler.cs New handler serving UTF-16 content for encoding tests.
dotnet/test/testing.webserver/Handlers/EchoHandler.cs New handler echoing request data back to the client.
dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs New handler to create and serve dynamically generated pages.
dotnet/test/testing.webserver/Handlers/CookieHandler.cs New handler to add/delete cookies via response headers.
dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs New handler implementing basic auth challenge/response behavior.
dotnet/test/testing.webserver/BUILD.bazel New Bazel target for the in-process webserver library and its shared web data.
dotnet/test/testing.webserver/AppServer.cs New in-process ASP.NET Core server that maps handlers and serves shared static fixtures.
dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj Adds project reference to the new test webserver.
dotnet/test/support/BUILD.bazel Adds web SDK and new webserver dep for support tests.
dotnet/test/remote/BUILD.bazel Adds web SDK and new webserver dep for remote tests.
dotnet/Selenium.slnx Adds the new test webserver project to the .NET solution.
dotnet/private/dotnet_nunit_test_suite.bzl Adjusts browser arg selection logic (notably removing default skipping/local-driver handling).

Copilot AI review requested due to automatic review settings April 12, 2026 10:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the .NET test infrastructure’s dependency on the Java “appserver” with a new in-process ASP.NET Core-based test web server, and wires it into the .NET test projects/build graph to better align with other language bindings’ internal testing approach.

Changes:

  • Added a new Selenium.Testing.WebServer .NET project implementing an in-process ASP.NET Core test server with multiple test endpoints and access to shared common/src/web fixtures.
  • Updated .NET test infrastructure to use the new in-process server (removing external Java webserver build/process management and associated config).
  • Updated Bazel and solution/project references to include the new webserver project and required SDK settings.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj Adds reference to new test webserver project; removes Bazel “build Java appserver” target.
dotnet/test/webdriver/PositionAndSizeTests.cs Uses invariant-culture parsing for CSS pixel values.
dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs Simplifies URL construction (host/port) and hardcodes /common base path.
dotnet/test/webdriver/Infrastructure/Environment/TestWebServer.cs Removes external-process Java test webserver wrapper.
dotnet/test/webdriver/Infrastructure/Environment/TestEnvironment.cs Removes website/webserver configuration fields no longer used.
dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs Switches to AppServer usage and adds project-root discovery helper.
dotnet/test/webdriver/CookieImplementationTests.cs Updates cookie test navigation paths to /common and adjusts setup page.
dotnet/test/webdriver/BUILD.bazel Removes Java webserver/keystore data deps; adds new webserver dep and project_sdk = "web".
dotnet/test/webdriver/appconfig.json Removes Java webserver + website configuration blocks.
dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj Introduces new test-only webserver project with ASP.NET Core framework reference.
dotnet/test/testing.webserver/Handlers/Utf8Handler.cs Adds UTF-8 content handler for test pages.
dotnet/test/testing.webserver/Handlers/UploadHandler.cs Adds upload endpoint handler used by upload-related tests.
dotnet/test/testing.webserver/Handlers/SleepHandler.cs Adds sleep/delay endpoint handler used for timing-related tests.
dotnet/test/testing.webserver/Handlers/RedirectHandler.cs Adds redirect endpoint handler.
dotnet/test/testing.webserver/Handlers/PageHandler.cs Adds dynamic “page/{pageNumber}” handler.
dotnet/test/testing.webserver/Handlers/FedCmHandler.cs Adds FedCM-related endpoints for tests.
dotnet/test/testing.webserver/Handlers/EncodingHandler.cs Adds UTF-16 encoding test endpoint.
dotnet/test/testing.webserver/Handlers/EchoHandler.cs Adds request echo endpoint handler.
dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs Adds endpoint to create/serve temporary inline pages for tests.
dotnet/test/testing.webserver/Handlers/CookieHandler.cs Adds cookie set/delete endpoint handler.
dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs Adds basic-auth endpoint handler.
dotnet/test/testing.webserver/BUILD.bazel Adds Bazel csharp_library target for the new webserver project and includes common web fixtures as data.
dotnet/test/testing.webserver/AppServer.cs Implements the in-process ASP.NET Core server and endpoint/static-file mappings.
dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj Adds reference to new test webserver project.
dotnet/test/support/BUILD.bazel Adds new webserver dep and project_sdk = "web" for support tests.
dotnet/test/remote/BUILD.bazel Adds new webserver dep and project_sdk = "web" for remote tests.
dotnet/Selenium.slnx Registers the new test webserver project in the .NET solution.
dotnet/private/dotnet_nunit_test_suite.bzl Simplifies default browser arg selection (removes default skip conditions).

Copilot AI review requested due to automatic review settings April 12, 2026 10:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the Java-based Selenium test webserver used by .NET tests with a new in-process ASP.NET Core-based server (OpenQA.Selenium.Testing.WebServer) and rewires the .NET test infrastructure/build files to use it.

Changes:

  • Added a new Selenium.Testing.WebServer test-only project implementing an in-process ASP.NET Core server with common test endpoints and static file hosting.
  • Updated .NET test infrastructure (EnvironmentManager, UrlBuilder, configs) to start and use the new server instead of building/running the Java appserver.
  • Updated Bazel + solution/project wiring to include the new webserver dependency and use the web SDK where needed.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj Adds reference to the new webserver project; removes Java appserver build target.
dotnet/test/webdriver/PositionAndSizeTests.cs Uses invariant-culture decimal parsing for CSS numeric assertions.
dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs Refactors URL composition to work with http/https base URLs from the new server.
dotnet/test/webdriver/Infrastructure/Environment/TestWebServer.cs Removes the external-process Java appserver wrapper.
dotnet/test/webdriver/Infrastructure/Environment/TestEnvironment.cs Removes website/webserver config fields no longer used.
dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs Starts the new in-process AppServer and initializes UrlBuilder with returned base URLs.
dotnet/test/webdriver/CookieImplementationTests.cs Updates test navigation and cookie paths to the /common layout.
dotnet/test/webdriver/BUILD.bazel Drops Java server artifacts; adds web SDK + new webserver dep.
dotnet/test/webdriver/appconfig.json Removes website and Java webserver configuration sections.
dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj Introduces the new ASP.NET Core-backed test webserver project.
dotnet/test/testing.webserver/Handlers/Utf8Handler.cs Adds a handler to serve UTF-8 test pages from disk.
dotnet/test/testing.webserver/Handlers/UploadHandler.cs Adds an upload endpoint with an intentional delay for wait-related tests.
dotnet/test/testing.webserver/Handlers/SleepHandler.cs Adds a delay endpoint driven by query string.
dotnet/test/testing.webserver/Handlers/RedirectHandler.cs Adds a redirect endpoint used by navigation tests.
dotnet/test/testing.webserver/Handlers/PageHandler.cs Adds a dynamic page generator endpoint.
dotnet/test/testing.webserver/Handlers/FedCmHandler.cs Adds FedCM-related JSON endpoints for authentication tests.
dotnet/test/testing.webserver/Handlers/EncodingHandler.cs Adds a UTF-16 response endpoint for encoding tests.
dotnet/test/testing.webserver/Handlers/EchoHandler.cs Adds an endpoint that echoes method/headers/body into an HTML response.
dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs Adds an endpoint for creating and serving temporary inline pages.
dotnet/test/testing.webserver/Handlers/CookieHandler.cs Adds a cookie manipulation endpoint for cookie tests.
dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs Adds a basic-auth challenge/response endpoint.
dotnet/test/testing.webserver/BUILD.bazel Adds Bazel build target for the new webserver + common web fixtures data.
dotnet/test/testing.webserver/AppServer.cs Implements the in-process ASP.NET Core server, endpoints, and static file hosting.
dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj Adds reference to the new webserver project.
dotnet/test/support/BUILD.bazel Enables web SDK and adds new webserver dep.
dotnet/test/remote/BUILD.bazel Enables web SDK and adds new webserver dep.
dotnet/Selenium.slnx Adds the new webserver project to the .NET solution.
dotnet/private/dotnet_nunit_test_suite.bzl Simplifies default browser selection logic (removes default --where=SkipTest==True for some browsers).

Copilot AI review requested due to automatic review settings April 12, 2026 10:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the Java-based test webserver dependency for .NET Selenium tests with an in-process ASP.NET Core test webserver, aiming to simplify test infrastructure and speed up test runs while reusing the shared common/ HTML fixtures.

Changes:

  • Added a new dotnet/test/testing.webserver project implementing an in-process ASP.NET Core AppServer with multiple test endpoints.
  • Updated .NET test infrastructure (EnvironmentManager, UrlBuilder, cookie tests) to use the new server and /common/... URL shape.
  • Updated solution/Bazel wiring to build/run tests with the new webserver and removed Java appserver build/data dependencies.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj References the new .NET test webserver project; removes Java appserver build target.
dotnet/test/webdriver/PositionAndSizeTests.cs Makes CSS numeric parsing culture-invariant.
dotnet/test/webdriver/Infrastructure/Environment/UrlBuilder.cs Reworks URL composition around provided http/https base URLs and /common prefix.
dotnet/test/webdriver/Infrastructure/Environment/TestWebServer.cs Removes the external-process Java appserver harness.
dotnet/test/webdriver/Infrastructure/Environment/TestEnvironment.cs Removes website/webserver config fields no longer used.
dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs Starts the in-process AppServer and constructs UrlBuilder from returned URLs.
dotnet/test/webdriver/CookieImplementationTests.cs Updates cookie-path expectations and startup navigation for /common URLs.
dotnet/test/webdriver/BUILD.bazel Drops Java webserver/keystore from data; adds dependency on the new webserver and uses project_sdk = "web".
dotnet/test/webdriver/appconfig.json Removes website/webserver configuration blocks.
dotnet/test/testing.webserver/Selenium.Testing.WebServer.csproj Introduces the new test-only webserver project (net8.0 + ASP.NET Core).
dotnet/test/testing.webserver/BUILD.bazel Adds Bazel target for the test webserver and includes shared //common/src/web data.
dotnet/test/testing.webserver/AppServer.cs Implements the ASP.NET Core in-process server and endpoint wiring.
dotnet/test/testing.webserver/Handlers/BasicAuthHandler.cs Adds basic auth endpoint handler.
dotnet/test/testing.webserver/Handlers/CookieHandler.cs Adds cookie manipulation endpoint handler.
dotnet/test/testing.webserver/Handlers/CreatePageHandler.cs Adds endpoint for creating/serving inline pages.
dotnet/test/testing.webserver/Handlers/EchoHandler.cs Adds endpoint that echoes request method/headers/body.
dotnet/test/testing.webserver/Handlers/EncodingHandler.cs Adds UTF-16 content endpoint for encoding tests.
dotnet/test/testing.webserver/Handlers/FedCmHandler.cs Adds FedCM-related endpoints for tests.
dotnet/test/testing.webserver/Handlers/PageHandler.cs Adds dynamic page endpoint.
dotnet/test/testing.webserver/Handlers/RedirectHandler.cs Adds redirect endpoint handler.
dotnet/test/testing.webserver/Handlers/SleepHandler.cs Adds latency endpoint handler.
dotnet/test/testing.webserver/Handlers/UploadHandler.cs Adds upload endpoint handler.
dotnet/test/testing.webserver/Handlers/Utf8Handler.cs Adds handler for serving UTF-8 HTML fixtures.
dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj References the new test webserver project.
dotnet/test/support/BUILD.bazel Adds dependency on new test webserver and uses project_sdk = "web".
dotnet/test/remote/BUILD.bazel Adds dependency on new test webserver and uses project_sdk = "web".
dotnet/Selenium.slnx Registers the new test webserver project in the solution.
dotnet/private/dotnet_nunit_test_suite.bzl Adjusts default browser args selection behavior (removes default skip).

@nvborisenko nvborisenko merged commit 89a97b7 into SeleniumHQ:trunk Apr 12, 2026
23 checks passed
@nvborisenko nvborisenko deleted the dotnet-test-webserver branch April 12, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-support Issue or PR related to support classes C-dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants