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

[release/2.1] Clean up some tests and move to new Azure endpoint #41603

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Common/tests/System/Net/Configuration.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static partial class Configuration
{
public static partial class Http
{
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net";

public static string Host => GetValue("COREFX_HTTPHOST", DefaultAzureServer);

Expand Down
2 changes: 1 addition & 1 deletion src/Common/tests/System/Net/Configuration.Security.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static partial class Configuration
{
public static partial class Security
{
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net";

public static string ActiveDirectoryName => GetValue("COREFX_NET_AD_DOMAINNAME");

Expand Down
2 changes: 1 addition & 1 deletion src/Common/tests/System/Net/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace System.Net.Test.Common
public static partial class Configuration
{
#pragma warning disable 414
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net";
#pragma warning restore 414

private static string GetValue(string envName, string defaultValue=null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public async Task NoCallback_BadCertificate_ThrowsException(string url)
}
}

[ActiveIssue(41108)]
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "UAP doesn't allow revocation checking to be turned off")]
[OuterLoop] // TODO: Issue #11345
[ConditionalFact(nameof(ClientSupportsDHECipherSuites))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2935,17 +2935,16 @@ public async Task PostAsync_ReuseRequestContent_Success(Uri remoteServer)
[InlineData(HttpStatusCode.MethodNotAllowed, "")]
public async Task GetAsync_CallMethod_ExpectedStatusLine(HttpStatusCode statusCode, string reasonPhrase)
{
using (HttpClient client = CreateHttpClient())
await LoopbackServer.CreateClientAndServerAsync(async uri =>
{
using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.StatusCodeUri(
false,
(int)statusCode,
reasonPhrase)))
using (HttpClient client = CreateHttpClient())
using (HttpResponseMessage response = await client.GetAsync(uri))
{
Assert.Equal(statusCode, response.StatusCode);
Assert.Equal(reasonPhrase, response.ReasonPhrase);
}
}
}, server => server.AcceptConnectionSendCustomResponseAndCloseAsync(
$"HTTP/1.1 {(int)statusCode} {reasonPhrase}\r\nContent-Length: 0\r\n\r\n"));
}

#endregion
Expand Down
36 changes: 20 additions & 16 deletions src/System.Net.Requests/tests/HttpWebRequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,31 +456,35 @@ public void KeepAlive_SetThenGetBoolean_ValuesMatch(Uri remoteServer)
[InlineData(false)]
[InlineData(true)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19225")]
public void KeepAlive_CorrectConnectionHeaderSent(bool? keepAlive)
public async Task KeepAlive_CorrectConnectionHeaderSent(bool? keepAlive)
{
HttpWebRequest request = WebRequest.CreateHttp(Test.Common.Configuration.Http.RemoteEchoServer);

if (keepAlive.HasValue)
await LoopbackServer.CreateServerAsync(async (server, url) =>
{
request.KeepAlive = keepAlive.Value;
}
HttpWebRequest request = WebRequest.CreateHttp(url);
request.Proxy = null; // Don't use a proxy since it might interfere with the Connection: headers.
if (keepAlive.HasValue)
{
request.KeepAlive = keepAlive.Value;
}

using (var response = (HttpWebResponse)request.GetResponse())
using (var body = new StreamReader(response.GetResponseStream()))
{
string content = body.ReadToEnd();
Task<WebResponse> getResponseTask = request.GetResponseAsync();
Task<List<string>> serverTask = server.AcceptConnectionSendResponseAndCloseAsync();

await TaskTimeoutExtensions.WhenAllOrAnyFailed(new Task[] { getResponseTask, serverTask });

List<string> requestLines = await serverTask;
if (!keepAlive.HasValue || keepAlive.Value)
{
// Validate that the request doesn't contain Connection: "close", but we can't validate
// that it does contain Connection: "keep-alive", as that's optional as of HTTP 1.1.
Assert.DoesNotContain("\"Connection\": \"close\"", content, StringComparison.OrdinalIgnoreCase);
// Validate that the request doesn't contain "Connection: close", but we can't validate
// that it does contain "Connection: Keep-Alive", as that's optional as of HTTP 1.1.
Assert.DoesNotContain("Connection: close", requestLines, StringComparer.OrdinalIgnoreCase);
}
else
{
Assert.Contains("\"Connection\": \"close\"", content, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("\"Keep-Alive\"", content, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Connection: close", requestLines, StringComparer.OrdinalIgnoreCase);
Assert.DoesNotContain("Keep-Alive", requestLines, StringComparer.OrdinalIgnoreCase);
}
}
});
}

[Theory, MemberData(nameof(EchoServers))]
Expand Down
18 changes: 13 additions & 5 deletions src/System.Net.WebClient/tests/WebClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
Expand All @@ -15,6 +16,8 @@

namespace System.Net.Tests
{
using Configuration = System.Net.Test.Common.Configuration;

public class WebClientTest
{
[Fact]
Expand Down Expand Up @@ -393,21 +396,26 @@ public static async Task RequestHeaders_AddDisallowedHeaderAndSendRequest_Throws
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer));
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
public static IEnumerable<object[]> RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult_MemberData()
{
yield return new object[] { $"http://{Configuration.Http.Host}", true };
yield return new object[] { Configuration.Http.Host, false };
}

[OuterLoop("Uses external servers")]
[Theory]
[InlineData("http://localhost", true)]
[InlineData("localhost", false)]
[MemberData(nameof(RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult_MemberData))]
public static async Task RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult(string hostHeaderValue, bool throwsWebException)
{
var wc = new WebClient();
wc.Headers["Host"] = hostHeaderValue;
if (throwsWebException)
{
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer));
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer));
}
else
{
await wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer);
await wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/System.Net.WebSockets.Client/tests/CloseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class CloseTest : ClientWebSocketTestBase
{
public CloseTest(ITestOutputHelper output) : base(output) { }

[ActiveIssue(36016)]
[OuterLoop] // TODO: Issue #11345
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_ServerInitiatedClose_Success(Uri server)
Expand Down Expand Up @@ -194,6 +195,7 @@ public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri serve
}
}

[ActiveIssue(36016)]
[OuterLoop] // TODO: Issue #11345
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server)
Expand Down
6 changes: 3 additions & 3 deletions src/System.Net.WebSockets.Client/tests/ConnectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public async Task ConnectAsync_AddHostHeader_Success()
{
Uri server = System.Net.Test.Common.Configuration.WebSockets.RemoteEchoServer;

// Send via the physical address such as "corefx-net.cloudapp.net"
// Set the Host header to logical address like "subdomain.corefx-net.cloudapp.net"
// Verify the scenario works and the remote server received "Host: subdomain.corefx-net.cloudapp.net"
// Send via the physical address such as "corefx-net-http11.azurewebsites.net"
// Set the Host header to logical address like "subdomain.corefx-net-http11.azurewebsites.net"
// Verify the scenario works and the remote server received "Host: subdomain.corefx-net-http11.azurewebsites.net"
string logicalHost = "subdomain." + server.Host;

using (var cws = new ClientWebSocket())
Expand Down