Skip to content

Commit

Permalink
http testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Aug 30, 2024
1 parent db4bf2e commit 7bd40a3
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ await ValidateClientCancellationAsync(async () =>
[InlineData(CancellationMode.CancelPendingRequests, true)]
[InlineData(CancellationMode.DisposeHttpClient, true)]
[SkipOnPlatform(TestPlatforms.Browser, "Browser doesn't have blocking synchronous Stream.ReadByte and so it waits for whole body")]
[SkipOnPlatform(TestPlatforms.Wasi, "Wasi doesn't have blocking synchronous Stream.ReadByte and so it waits for whole body")]
public async Task GetAsync_CancelPendingRequests_DoesntCancelReadAsyncOnResponseStream(CancellationMode mode, bool copyToAsync)
{
if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value)
Expand Down Expand Up @@ -347,6 +348,7 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) =>

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "MaxConnectionsPerServer is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "MaxConnectionsPerServer is not supported on Wasi")]
public async Task MaxConnectionsPerServer_WaitingConnectionsAreCancelable()
{
if (LoopbackServerFactory.Version >= HttpVersion20.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void CookieContainer_SetNull_ThrowsArgumentNullException()
}

[SkipOnPlatform(TestPlatforms.Browser, "Credentials is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "Credentials not supported on Wasi")]
public void Ctor_ExpectedDefaultPropertyValues_CommonPlatform()
{
using (HttpClientHandler handler = CreateHttpClientHandler())
Expand All @@ -68,6 +69,7 @@ public void Ctor_ExpectedDefaultPropertyValues_CommonPlatform()

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "MaxResponseHeadersLength is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "MaxResponseHeadersLength not supported on Wasi")]
public void Ctor_ExpectedDefaultPropertyValues()
{
using (HttpClientHandler handler = CreateHttpClientHandler())
Expand All @@ -86,6 +88,7 @@ public void Ctor_ExpectedDefaultPropertyValues()

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Credentials is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "Credentials not supported on Wasi")]
public void Credentials_SetGet_Roundtrips()
{
using (HttpClientHandler handler = CreateHttpClientHandler())
Expand All @@ -107,6 +110,7 @@ public void Credentials_SetGet_Roundtrips()
[InlineData(-1)]
[InlineData(0)]
[SkipOnPlatform(TestPlatforms.Browser, "MaxAutomaticRedirections not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "MaxAutomaticRedirections not supported on Wasi")]
public void MaxAutomaticRedirections_InvalidValue_Throws(int redirects)
{
using (HttpClientHandler handler = CreateHttpClientHandler())
Expand Down Expand Up @@ -157,6 +161,7 @@ public void Properties_AddItemToDictionary_ItemPresent()

[ConditionalFact]
[SkipOnPlatform(TestPlatforms.Browser, "ServerCertificateCustomValidationCallback not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "ServerCertificateCustomValidationCallback not supported on Wasi")]
public async Task GetAsync_IPv6LinkLocalAddressUri_Success()
{
if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value)
Expand Down Expand Up @@ -231,6 +236,7 @@ public static IEnumerable<object[]> GetAsync_IPBasedUri_Success_MemberData()
[InlineData("[::1234]:8080", "[::1234]:8080")]
[InlineData("[fe80::9c3a:b64d:6249:1de8%2]", "[fe80::9c3a:b64d:6249:1de8]")]
[SkipOnPlatform(TestPlatforms.Browser, "Proxy not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "Proxy not supported on Wasi")]
public async Task GetAsync_IPv6AddressInHostHeader_CorrectlyFormatted(string host, string hostHeader)
{
string ipv6Address = "http://" + host;
Expand Down Expand Up @@ -309,6 +315,7 @@ await LoopbackServer.CreateClientAndServerAsync(async url =>
[InlineData("WWW-Authenticate", "CustomAuth")]
[InlineData("", "")] // RFC7235 requires servers to send this header with 401 but some servers don't.
[SkipOnPlatform(TestPlatforms.Browser, "Credentials is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "Credentials is not supported on Wasi")]
public async Task GetAsync_ServerNeedsNonStandardAuthAndSetCredential_StatusCodeUnauthorized(string authHeadrName, string authHeaderValue)
{
if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public async Task PostLargeContentUsingContentLengthSemantics_Success(Configurat

[OuterLoop("Uses external servers")]
[SkipOnPlatform(TestPlatforms.Browser, "PreAuthenticate not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "PreAuthenticate not supported on Wasi")]
[Theory, MemberData(nameof(RemoteServersMemberData))]
public async Task PostRewindableContentUsingAuth_NoPreAuthenticate_Success(Configuration.Http.RemoteServer remoteServer)
{
Expand All @@ -179,6 +180,7 @@ public async Task PostRewindableContentUsingAuth_NoPreAuthenticate_Success(Confi
[OuterLoop("Uses external servers")]
[Theory, MemberData(nameof(RemoteServersMemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "PreAuthenticate not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "PreAuthenticate not supported on Wasi")]
public async Task PostNonRewindableContentUsingAuth_NoPreAuthenticate_ThrowsHttpRequestException(Configuration.Http.RemoteServer remoteServer)
{
// Sync API supported only up to HTTP/1.1
Expand All @@ -196,6 +198,7 @@ await Assert.ThrowsAsync<HttpRequestException>(() =>
[OuterLoop("Uses external servers")]
[Theory, MemberData(nameof(RemoteServersMemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "PreAuthenticate not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "PreAuthenticate not supported on Wasi")]
public async Task PostNonRewindableContentUsingAuth_PreAuthenticate_Success(Configuration.Http.RemoteServer remoteServer)
{
// Sync API supported only up to HTTP/1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "User-Agent is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_UserAgent_CorrectlyWritten()
{
string userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.18 Safari/537.36";
Expand Down Expand Up @@ -139,6 +140,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
[InlineData("\u05D1\u05F1")]
[InlineData("jp\u30A5")]
[SkipOnPlatform(TestPlatforms.Browser, "Browser is relaxed about validating HTTP headers")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_InvalidCharactersInHeader_Throw(string value)
{
await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
Expand Down Expand Up @@ -388,6 +390,7 @@ public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort)
[OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))]
[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException()
{
if (LoopbackServerFactory.Version >= HttpVersion.Version20)
Expand All @@ -408,6 +411,7 @@ public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException()

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Browser is relaxed about validating HTTP headers")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_WithZeroLengthHeaderName_Throws()
{
await LoopbackServerFactory.CreateClientAndServerAsync(
Expand Down Expand Up @@ -452,6 +456,7 @@ private static readonly (string Name, Encoding ValueEncoding, string Separator,

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CustomRequestEncodingSelector_CanSendNonAsciiHeaderValues()
{
await LoopbackServerFactory.CreateClientAndServerAsync(
Expand Down Expand Up @@ -507,6 +512,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CustomResponseEncodingSelector_CanReceiveNonAsciiHeaderValues()
{
await LoopbackServerFactory.CreateClientAndServerAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ await server.AcceptConnectionAsync(async connection =>

[Collection(nameof(HttpClientMiniStress))]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Security is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public abstract class HttpClientMiniStress : HttpClientHandlerTestBase
{
public HttpClientMiniStress(ITestOutputHelper output) : base(output) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public async Task GetContentAsync_ErrorStatusCode_ExpectedExceptionThrown(bool w

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task GetContentAsync_WhenCannotConnect_ExceptionContainsHostInfo()
{
const string Host = "localhost:1234";
Expand Down Expand Up @@ -692,6 +693,7 @@ public void Dispose_UseAfterDispose_Throws()
[InlineData(false)]
[InlineData(true)]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Sockets is not supported on this platform")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public void CancelAllPending_AllPendingOperationsCanceled(bool withInfiniteTimeout)
{
using (var client = new HttpClient(new CustomResponseHandler((r, c) => WhenCanceled<HttpResponseMessage>(c))))
Expand All @@ -710,6 +712,7 @@ public void CancelAllPending_AllPendingOperationsCanceled(bool withInfiniteTimeo
[InlineData(HttpCompletionOption.ResponseContentRead)]
[InlineData(HttpCompletionOption.ResponseHeadersRead)]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Sockets is not supported on this platform")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public void Timeout_TooShort_AllPendingOperationsCanceled(HttpCompletionOption completionOption)
{
using (var client = new HttpClient(new CustomResponseHandler((r, c) => WhenCanceled<HttpResponseMessage>(c))))
Expand Down Expand Up @@ -747,6 +750,7 @@ public async Task Timeout_CallerCanceledTokenAfterTimeout_TimeoutIsNotDetected(H
[InlineData(HttpCompletionOption.ResponseContentRead)]
[InlineData(HttpCompletionOption.ResponseHeadersRead)]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Sockets is not supported on this platform")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public void Timeout_CallerCanceledTokenBeforeTimeout_TimeoutIsNotDetected(HttpCompletionOption completionOption)
{
using (var client = new HttpClient(new CustomResponseHandler((r, c) => WhenCanceled<HttpResponseMessage>(c))))
Expand Down Expand Up @@ -943,6 +947,7 @@ public void Send_SingleThread_Succeeds(HttpCompletionOption completionOption)
[InlineData(HttpCompletionOption.ResponseHeadersRead)]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_SingleThread_Loopback_Succeeds(HttpCompletionOption completionOption)
{
string content = "Test content";
Expand Down Expand Up @@ -998,6 +1003,7 @@ await server.AcceptConnectionAsync(async connection =>
[OuterLoop]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_CancelledRequestContent_Throws()
{
CancellationTokenSource cts = new CancellationTokenSource();
Expand Down Expand Up @@ -1087,6 +1093,7 @@ await server.AcceptConnectionAsync(async connection =>
[OuterLoop]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_CancelledResponseContent_Throws()
{
string content = "Test content";
Expand Down Expand Up @@ -1139,6 +1146,7 @@ await IgnoreExceptions(async () =>
[OuterLoop]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_TimeoutResponseContent_Throws()
{
const string Content = "Test content";
Expand Down Expand Up @@ -1197,6 +1205,7 @@ public static IEnumerable<object[]> VersionSelectionMemberData()
[Theory]
[MemberData(nameof(VersionSelectionMemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CorrectVersionSelected_LoopbackServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult)
{
await HttpAgnosticLoopbackServer.CreateClientAndServerAsync(
Expand Down Expand Up @@ -1247,6 +1256,7 @@ await HttpAgnosticLoopbackServer.CreateClientAndServerAsync(
[OuterLoop("Uses external servers")]
[MemberData(nameof(VersionSelectionMemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CorrectVersionSelected_ExternalServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult)
{
RemoteServer remoteServer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public async Task ReadAsStreamAsync_FirstGetFromUnbufferedContentThenGetFromBuff
}

[SkipOnPlatform(TestPlatforms.Browser, "Browser doesn't support Synchronous reads")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ public Task RequestDuration_ErrorStatus_ErrorTypeRecorded(int statusCode)

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Browser is relaxed about validating HTTP headers")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task RequestDuration_ConnectionClosedWhileReceivingHeaders_Recorded()
{
using CancellationTokenSource cancelServerCts = new CancellationTokenSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ internal static async Task HandleAuthenticationRequestWithFakeServer(LoopbackSer
[InlineData(true)]
[InlineData(false)]
[SkipOnPlatform(TestPlatforms.Browser, "Credentials and HttpListener is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task DefaultHandler_FakeServer_Success(bool useNtlm)
{
await LoopbackServer.CreateClientAndServerAsync(
Expand All @@ -142,6 +143,7 @@ await server.AcceptConnectionAsync(async connection =>

[Fact]
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.Windows, "DefaultCredentials are unsupported for NTLM on Unix / Managed implementation")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task DefaultHandler_FakeServer_DefaultCredentials()
{
await LoopbackServer.CreateClientAndServerAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static IEnumerable<object[]> ZeroByteRead_IssuesZeroByteReadOnUnderlyingS
[Theory]
[MemberData(nameof(ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream_MemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "ConnectCallback is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream(StreamConformanceTests.ReadWriteMode readMode, bool useSsl)
{
(Stream httpConnection, Stream server) = ConnectedStreams.CreateBidirectional(4096, int.MaxValue);
Expand Down
Loading

0 comments on commit 7bd40a3

Please sign in to comment.