Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
fix some conditional test logic to ensure we're not disabling Sockets…
Browse files Browse the repository at this point in the history
…HttpHandler tests
  • Loading branch information
Geoff Kizer committed Mar 5, 2018
1 parent 91b311e commit c2db574
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
23 changes: 16 additions & 7 deletions src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
Expand Up @@ -34,8 +34,6 @@ public class HttpClientHandlerTest : HttpClientTestBase

private readonly NetworkCredential _credential = new NetworkCredential(Username, Password);

public static bool IsNotWindows7 => !PlatformDetection.IsWindows7;

public static readonly object[][] EchoServers = Configuration.Http.EchoServers;
public static readonly object[][] VerifyUploadServers = Configuration.Http.VerifyUploadServers;
public static readonly object[][] CompressedServers = Configuration.Http.CompressedServers;
Expand Down Expand Up @@ -98,7 +96,6 @@ public class HttpClientHandlerTest : HttpClientTestBase
GetMethods("HEAD", "TRACE");

private static bool IsWindows10Version1607OrGreater => PlatformDetection.IsWindows10Version1607OrGreater;
private static bool NotWindowsUAPOrBeforeVersion1709 => !PlatformDetection.IsUap || PlatformDetection.IsWindows10Version1709OrGreater;

private static IEnumerable<object[]> GetMethods(params string[] methods)
{
Expand Down Expand Up @@ -842,9 +839,9 @@ public async Task GetAsync_AllowAutoRedirectTrue_RedirectToUriWithParams_Request
[InlineData(3, 4)]
public async Task GetAsync_MaxAutomaticRedirectionsNServerHops_ThrowsIfTooMany(int maxHops, int hops)
{
if (PlatformDetection.IsWindows && !PlatformDetection.IsWindows10Version1703OrGreater)
if (IsWinHttpHandler && !PlatformDetection.IsWindows10Version1703OrGreater)
{
// Skip this test if running on Windows but on a release prior to Windows 10 Creators Update.
// Skip this test if using WinHttpHandler but on a release prior to Windows 10 Creators Update.
_output.WriteLine("Skipping test due to Windows 10 version prior to Version 1703.");
return;
}
Expand Down Expand Up @@ -1099,9 +1096,16 @@ public async Task GetAsync_CredentialIsCredentialCacheUriRedirect_StatusCodeOK(i
}

[OuterLoop] // TODO: Issue #11345
[ConditionalTheory(nameof(NotWindowsUAPOrBeforeVersion1709)), MemberData(nameof(HeaderWithEmptyValueAndUris))]
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)]
[Theory]
[MemberData(nameof(HeaderWithEmptyValueAndUris))]
public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndEmptyValueSent(string name, string value, Uri uri)
{
if (IsWinHttpHandler && !PlatformDetection.IsWindows10Version1709OrGreater)
{
return;
}

using (HttpClient client = CreateHttpClient())
{
_output.WriteLine($"name={name}, value={value}");
Expand Down Expand Up @@ -2894,10 +2898,15 @@ public async Task Proxy_SslProxyUnsupported_Throws()
}

[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "UAP does not support custom proxies.")]
[ActiveIssue(23136, TestPlatforms.Windows)]
[Fact]
public async Task Proxy_UseSecureProxyTunnel_Success()
{
if (IsWinHttpHandler)
{
// Issue #27746: WinHttpHandler hangs on this test
return;
}

LoopbackServer.Options options = new LoopbackServer.Options { UseSsl = true };

var listener = new TcpListener(IPAddress.Loopback, 0);
Expand Down
Expand Up @@ -160,9 +160,14 @@ public async Task PostNonRewindableContentUsingAuth_NoPreAuthenticate_ThrowsHttp

[OuterLoop] // TODO: Issue #11345
[Theory, MemberData(nameof(BasicAuthEchoServers))]
[ActiveIssue(9228, TestPlatforms.Windows)]
public async Task PostNonRewindableContentUsingAuth_PreAuthenticate_Success(Uri serverUri)
{
if (IsWinHttpHandler)
{
// Issue #9228
return;
}

HttpContent content = CustomContent.Create(ExpectedContent, false);
var credential = new NetworkCredential(UserName, Password);
await PostUsingAuthHelper(serverUri, ExpectedContent, content, credential, preAuthenticate: true);
Expand Down
Expand Up @@ -182,9 +182,9 @@ await client.GetAsync(Configuration.Http.RemoteEchoServer, HttpCompletionOption.
Assert.True(task.IsCompleted, "Task was not yet completed");

// Verify that the task completed successfully or is canceled.
if (PlatformDetection.IsWindows)
if (IsWinHttpHandler)
{
// On Windows, we may fault because canceling the task destroys the request handle
// With WinHttpHandler, we may fault because canceling the task destroys the request handle
// which may randomly cause an ObjectDisposedException (or other exception).
Assert.True(
task.Status == TaskStatus.RanToCompletion ||
Expand Down

0 comments on commit c2db574

Please sign in to comment.