Repository navigation
Use HTTP transport for browser dotnettestcli #10143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Amaury Levé (Evangelink)
merged 23 commits into
main
from
dev/amauryleve/http-dotnettestcli-transport
Jul 23, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a467c79
Add HTTP dotnettestcli transport
Evangelink 1af0d20
Address HTTP transport review feedback
Evangelink 56e353d
Merge origin/main and resolve PR conflicts
Copilot f269f7d
Harden HTTP transport diagnostics
Evangelink 315e0f1
Close HTTP transport cancellation gaps
Evangelink b364346
Make HTTP transport tests deterministic
Evangelink 410a2c7
Redact all sensitive option values
Evangelink 2d20ea6
Redact excess inline option values
Evangelink 040233d
Redact malformed HTTP transport arguments
Evangelink d5d720a
Make response cancellation terminal
Evangelink 5c1d5de
Validate HTTP transport option dependencies
Evangelink c928130
Avoid redirect configuration on WASI
Evangelink 9b71119
Close remaining diagnostic leaks
Evangelink df4ebb2
Make failed HTTP requests terminal
Evangelink caad62e
Validate explicit pipe transport dependency
Evangelink d8862c1
Redact expanded response-file arguments
Evangelink 3ff029b
Redact sensitive response-file errors
Evangelink 94e0b13
Redact whitespace-prefixed sensitive options
Evangelink 4b2ed23
Declare response-file helper overload
Evangelink e2fbf0d
Sanitize response-file access errors
Evangelink eae0231
Redact relaunched process diagnostics
Evangelink 7cd0694
Redact malformed response-file paths
Evangelink f4ce182
Merge branch 'main' into dev/amauryleve/http-dotnettestcli-transport
Evangelink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
194 changes: 154 additions & 40 deletions
194
docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineArgumentsRedactor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.Testing.Platform.CommandLine; | ||
|
|
||
| internal static class CommandLineArgumentsRedactor | ||
| { | ||
| private const string RedactedPlaceholder = "***REDACTED***"; | ||
|
|
||
| public static string Redact(string[] args) | ||
| => string.Join(" ", RedactArguments(args)); | ||
|
|
||
| public static string RedactArgument(string[] args, int index) | ||
| => RedactArguments(args)[index]; | ||
|
|
||
| private static string[] RedactArguments(string[] args) | ||
| { | ||
| if (args.Length == 0) | ||
| { | ||
| return []; | ||
| } | ||
|
|
||
| string[] redacted = new string[args.Length]; | ||
| bool redactNextValue = false; | ||
| bool sanitizeNextEndpoint = false; | ||
| bool sensitiveValueConsumed = false; | ||
|
|
||
| for (int i = 0; i < args.Length; i++) | ||
| { | ||
| string arg = args[i]; | ||
| if (TryParseOption(arg, out string? prefix, out string? name, out string? delimiter, out string? inlineValue)) | ||
| { | ||
| bool isToken = IsTokenOption(name); | ||
| bool isEndpoint = IsEndpointOption(name); | ||
| if (isToken) | ||
| { | ||
| redacted[i] = inlineValue is null | ||
| ? arg | ||
| : $"{prefix}{name}{delimiter}{RedactedPlaceholder}"; | ||
| redactNextValue = true; | ||
| sanitizeNextEndpoint = false; | ||
| sensitiveValueConsumed = inlineValue is not null; | ||
| } | ||
| else if (isEndpoint) | ||
| { | ||
| redacted[i] = inlineValue is null | ||
| ? arg | ||
| : $"{prefix}{name}{delimiter}{SanitizeEndpoint(inlineValue)}"; | ||
| sanitizeNextEndpoint = true; | ||
| redactNextValue = false; | ||
| sensitiveValueConsumed = inlineValue is not null; | ||
| } | ||
| else if (redactNextValue && !sensitiveValueConsumed) | ||
| { | ||
| redacted[i] = RedactedPlaceholder; | ||
| redactNextValue = false; | ||
| sanitizeNextEndpoint = false; | ||
| sensitiveValueConsumed = false; | ||
| } | ||
| else if (sanitizeNextEndpoint && !sensitiveValueConsumed) | ||
| { | ||
| redacted[i] = SanitizeEndpoint(arg); | ||
| redactNextValue = false; | ||
| sanitizeNextEndpoint = false; | ||
| sensitiveValueConsumed = false; | ||
| } | ||
| else | ||
| { | ||
| redacted[i] = arg; | ||
| redactNextValue = false; | ||
| sanitizeNextEndpoint = false; | ||
| sensitiveValueConsumed = false; | ||
| } | ||
|
|
||
| continue; | ||
| } | ||
|
|
||
| if (redactNextValue) | ||
| { | ||
| redacted[i] = RedactedPlaceholder; | ||
| sensitiveValueConsumed = true; | ||
| } | ||
| else if (sanitizeNextEndpoint) | ||
| { | ||
| redacted[i] = SanitizeEndpoint(arg); | ||
| sensitiveValueConsumed = true; | ||
| } | ||
| else | ||
| { | ||
| redacted[i] = arg; | ||
| } | ||
| } | ||
|
|
||
| return redacted; | ||
| } | ||
|
|
||
| private static bool TryParseOption( | ||
| string arg, | ||
| [NotNullWhen(true)] out string? prefix, | ||
| [NotNullWhen(true)] out string? name, | ||
| out string? delimiter, | ||
| out string? inlineValue) | ||
| { | ||
| prefix = null; | ||
| name = null; | ||
| delimiter = null; | ||
| inlineValue = null; | ||
|
|
||
| int optionStart = 0; | ||
| while (optionStart < arg.Length && char.IsWhiteSpace(arg[optionStart])) | ||
| { | ||
| optionStart++; | ||
| } | ||
|
|
||
| int prefixLength = 0; | ||
| while (optionStart + prefixLength < arg.Length && arg[optionStart + prefixLength] == '-') | ||
| { | ||
| prefixLength++; | ||
| } | ||
|
|
||
| bool hasLeadingWhitespace = optionStart > 0; | ||
| bool isValidPrefix = !hasLeadingWhitespace && prefixLength is 1 or 2; | ||
| bool isMalformedPrefix = hasLeadingWhitespace || prefixLength >= 3; | ||
| if ((!isValidPrefix && !isMalformedPrefix) || optionStart + prefixLength == arg.Length) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| prefix = arg[..(optionStart + prefixLength)]; | ||
| string withoutPrefix = arg[(optionStart + prefixLength)..]; | ||
| int delimiterIndex = withoutPrefix.IndexOfAny(['=', ':']); | ||
| if (delimiterIndex == -1) | ||
| { | ||
| name = withoutPrefix; | ||
| } | ||
| else | ||
| { | ||
| name = withoutPrefix[..delimiterIndex]; | ||
| delimiter = withoutPrefix[delimiterIndex].ToString(); | ||
| inlineValue = withoutPrefix[(delimiterIndex + 1)..]; | ||
| } | ||
|
|
||
| if (!isMalformedPrefix || IsTokenOption(name) || IsEndpointOption(name)) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| prefix = null; | ||
| name = null; | ||
| delimiter = null; | ||
| inlineValue = null; | ||
| return false; | ||
| } | ||
|
|
||
| private static bool IsTokenOption(string name) | ||
| => PlatformCommandLineProvider.DotNetTestHttpTokenOptionKey.Equals(name, StringComparison.OrdinalIgnoreCase); | ||
|
|
||
| private static bool IsEndpointOption(string name) | ||
| => PlatformCommandLineProvider.DotNetTestHttpEndpointOptionKey.Equals(name, StringComparison.OrdinalIgnoreCase); | ||
|
|
||
| private static string SanitizeEndpoint(string endpoint) | ||
| => Uri.TryCreate(endpoint, UriKind.Absolute, out Uri? uri) | ||
| && uri.Scheme is "http" or "https" | ||
| && RoslynString.IsNullOrEmpty(uri.UserInfo) | ||
| ? uri.GetLeftPart(UriPartial.Authority) | ||
| : RedactedPlaceholder; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.