Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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
25 changes: 0 additions & 25 deletions src/Common/tests/System/Net/Configuration.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public static partial class Configuration
{
public static partial class Http
{
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
private static readonly string DefaultHttp2AzureServer = "corefx-net-http2.azurewebsites.net";

public static string Host => GetValue("COREFX_HTTPHOST", DefaultAzureServer);
Expand Down Expand Up @@ -49,7 +48,6 @@ public static partial class Http

private const string EchoHandler = "Echo.ashx";
private const string EmptyContentHandler = "EmptyContent.ashx";
private const string StatusCodeHandler = "StatusCode.ashx";
private const string RedirectHandler = "Redirect.ashx";
private const string VerifyUploadHandler = "VerifyUpload.ashx";
private const string DeflateHandler = "Deflate.ashx";
Expand Down Expand Up @@ -99,29 +97,6 @@ public static Uri BasicAuthUriForCreds(bool secure, string userName, string pass
password));
}

public static Uri StatusCodeUri(bool secure, int statusCode)
{
return new Uri(
string.Format(
"{0}://{1}/{2}?statuscode={3}",
secure ? HttpsScheme : HttpScheme,
Host,
StatusCodeHandler,
statusCode));
}

public static Uri StatusCodeUri(bool secure, int statusCode, string statusDescription)
{
return new Uri(
string.Format(
"{0}://{1}/{2}?statuscode={3}&statusDescription={4}",
secure ? HttpsScheme : HttpScheme,
Host,
StatusCodeHandler,
statusCode,
statusDescription));
}

public static Uri RedirectUriForDestinationUri(bool secure, int statusCode, Uri destinationUri, int hops, bool relative = false)
{
string uriString;
Expand Down
2 changes: 0 additions & 2 deletions src/Common/tests/System/Net/Configuration.Security.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public static partial class Configuration
{
public static partial class Security
{
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";

// Domain server environment.
public static string ActiveDirectoryName => GetValue("COREFX_NET_AD_DOMAINNAME");
public static string ActiveDirectoryUserName => GetValue("COREFX_NET_AD_USERNAME");
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
7 changes: 4 additions & 3 deletions src/Common/tests/System/Net/WebSockets/WebSocketCreateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void CreateFromStream_ValidBufferSizes_CreatesWebSocket(int bufferSize)
Assert.NotNull(CreateFromStream(new MemoryStream(), true, null, Timeout.InfiniteTimeSpan));
}

[OuterLoop] // Connects to external server.
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task WebSocketProtocol_CreateFromConnectedStream_CanSendReceiveData(Uri echoUri)
Expand Down Expand Up @@ -150,7 +150,7 @@ public async Task ReceiveAsync_ServerSplitHeader_ValidDataReceived()
}
}

[OuterLoop] // Connects to external server.
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServersAndBoolean))]
public async Task WebSocketProtocol_CreateFromConnectedStream_CloseAsyncClosesStream(Uri echoUri, bool explicitCloseAsync)
Expand Down Expand Up @@ -184,7 +184,8 @@ public async Task WebSocketProtocol_CreateFromConnectedStream_CloseAsyncClosesSt
}
}

[OuterLoop] // Connects to external server.
[ActiveIssue(36016)]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServersAndBoolean))]
public async Task WebSocketProtocol_CreateFromConnectedStream_CloseAsyncAfterCloseReceivedClosesStream(Uri echoUri, bool useCloseOutputAsync)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2349,23 +2349,21 @@ public async Task PostAsync_ReuseRequestContent_Success(Uri remoteServer)
}
}

[OuterLoop("Uses external server")]
[Theory]
[InlineData(HttpStatusCode.MethodNotAllowed, "Custom description")]
[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
19 changes: 9 additions & 10 deletions src/System.Net.Requests/tests/HttpWebRequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,17 +1247,16 @@ public async Task GetResponseAsync_ServerNameNotInDns_ThrowsWebException()
Assert.Equal(WebExceptionStatus.NameResolutionFailure, ex.Status);
}

public static object[][] StatusCodeServers = {
new object[] { System.Net.Test.Common.Configuration.Http.StatusCodeUri(false, 404) },
new object[] { System.Net.Test.Common.Configuration.Http.StatusCodeUri(true, 404) },
};

[Theory, MemberData(nameof(StatusCodeServers))]
public async Task GetResponseAsync_ResourceNotFound_ThrowsWebException(Uri remoteServer)
[Fact]
public async Task GetResponseAsync_ResourceNotFound_ThrowsWebException()
{
HttpWebRequest request = WebRequest.CreateHttp(remoteServer);
WebException ex = await Assert.ThrowsAsync<WebException>(() => request.GetResponseAsync());
Assert.Equal(WebExceptionStatus.ProtocolError, ex.Status);
await LoopbackServer.CreateClientAndServerAsync(async uri =>
{
HttpWebRequest request = WebRequest.CreateHttp(uri);
WebException ex = await Assert.ThrowsAsync<WebException>(() => request.GetResponseAsync());
Assert.Equal(WebExceptionStatus.ProtocolError, ex.Status);
}, server => server.AcceptConnectionSendCustomResponseAndCloseAsync(
$"HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\n\r\n"));
}

[Theory, MemberData(nameof(EchoServers))]
Expand Down
36 changes: 22 additions & 14 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 @@ -382,32 +385,37 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
Assert.Equal("ArbitraryValue", wc.ResponseHeaders["ArbitraryHeader"]);
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[InlineData("Connection", "close")]
[InlineData("Expect", "100-continue")]
public static async Task RequestHeaders_AddDisallowedHeaderAndSendRequest_ThrowsWebException(string headerName, string headerValue)
{
var wc = new WebClient();
wc.Headers[headerName] = headerValue;
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer));
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer));
}

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("Networking test talking to remote server: issue #11345")]
[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 Expand Up @@ -469,7 +477,7 @@ public abstract class WebClientTestBase
{
public const int TimeoutMilliseconds = 30 * 1000;

public static readonly object[][] EchoServers = System.Net.Test.Common.Configuration.Http.EchoServers;
public static readonly object[][] EchoServers = Configuration.Http.EchoServers;
const string ExpectedText =
"To be, or not to be, that is the question:" +
"Whether 'tis Nobler in the mind to suffer" +
Expand Down Expand Up @@ -605,7 +613,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
});
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task OpenWrite_Success(Uri echoServer)
Expand All @@ -618,7 +626,7 @@ public async Task OpenWrite_Success(Uri echoServer)
}
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task UploadData_Success(Uri echoServer)
Expand All @@ -636,7 +644,7 @@ public async Task UploadData_Success(Uri echoServer)
}
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task UploadData_LargeData_Success(Uri echoServer)
Expand All @@ -653,7 +661,7 @@ private static string GetRandomText(int length)
return new string(Enumerable.Range(0, 512 * 1024).Select(_ => (char)('a' + rand.Next(0, 26))).ToArray());
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task UploadFile_Success(Uri echoServer)
Expand All @@ -672,7 +680,7 @@ public async Task UploadFile_Success(Uri echoServer)
}
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task UploadString_Success(Uri echoServer)
Expand All @@ -682,7 +690,7 @@ public async Task UploadString_Success(Uri echoServer)
Assert.Contains(ExpectedText, result);
}

[OuterLoop("Networking test talking to remote server: issue #11345")]
[OuterLoop("Uses external servers")]
[Theory]
[MemberData(nameof(EchoServers))]
public async Task UploadValues_Success(Uri echoServer)
Expand Down
24 changes: 13 additions & 11 deletions src/System.Net.WebSockets.Client/tests/CloseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class CloseTest : ClientWebSocketTestBase
{
public CloseTest(ITestOutputHelper output) : base(output) { }

[OuterLoop] // TODO: Issue #11345
[ActiveIssue(36016)]
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServersAndBoolean))]
public async Task CloseAsync_ServerInitiatedClose_Success(Uri server, bool useCloseOutputAsync)
{
Expand Down Expand Up @@ -64,7 +65,7 @@ await cws.SendAsync(
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_ClientInitiatedClose_Success(Uri server)
{
Expand All @@ -84,7 +85,7 @@ public async Task CloseAsync_ClientInitiatedClose_Success(Uri server)
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_CloseDescriptionIsMaxLength_Success(Uri server)
{
Expand All @@ -98,7 +99,7 @@ public async Task CloseAsync_CloseDescriptionIsMaxLength_Success(Uri server)
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_CloseDescriptionIsMaxLengthPlusOne_ThrowsArgumentException(Uri server)
{
Expand All @@ -123,7 +124,7 @@ public async Task CloseAsync_CloseDescriptionIsMaxLengthPlusOne_ThrowsArgumentEx
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_CloseDescriptionHasUnicode_Success(Uri server)
{
Expand All @@ -141,7 +142,7 @@ public async Task CloseAsync_CloseDescriptionHasUnicode_Success(Uri server)
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_CloseDescriptionIsNull_Success(Uri server)
{
Expand All @@ -158,7 +159,7 @@ public async Task CloseAsync_CloseDescriptionIsNull_Success(Uri server)
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri server)
{
Expand Down Expand Up @@ -196,7 +197,8 @@ public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri serve
}
}

[OuterLoop] // TODO: Issue #11345
[ActiveIssue(36016)]
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server)
{
Expand Down Expand Up @@ -243,7 +245,7 @@ await cws.SendAsync(
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseOutputAsync_CloseDescriptionIsNull_Success(Uri server)
{
Expand All @@ -259,7 +261,7 @@ public async Task CloseOutputAsync_CloseDescriptionIsNull_Success(Uri server)
}

[ActiveIssue(20362, TargetFrameworkMonikers.Netcoreapp)]
[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseOutputAsync_DuringConcurrentReceiveAsync_ExpectedStates(Uri server)
{
Expand Down Expand Up @@ -296,7 +298,7 @@ public async Task CloseOutputAsync_DuringConcurrentReceiveAsync_ExpectedStates(U
}
}

[OuterLoop] // TODO: Issue #11345
[OuterLoop("Uses external server")]
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task CloseAsync_DuringConcurrentReceiveAsync_ExpectedStates(Uri server)
{
Expand Down
8 changes: 4 additions & 4 deletions src/System.Net.WebSockets.Client/tests/ConnectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public async Task ConnectAsync_CookieHeaders_Success(Uri server)

[OuterLoop] // TODO: Issue #11345
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketExceptionWithMessage(Uri server)
public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketException(Uri server)
{
const string AcceptedProtocol = "CustomProtocol";

Expand All @@ -200,13 +200,13 @@ public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketE

WebSocketException ex = await Assert.ThrowsAsync<WebSocketException>(() =>
cws.ConnectAsync(ub.Uri, cts.Token));

_output.WriteLine(ex.Message);
if (PlatformDetection.IsNetCore) // bug fix in netcoreapp: https://github.com/dotnet/corefx/pull/35960
{
Assert.Equal(WebSocketError.Faulted, ex.WebSocketErrorCode);
Assert.True(ex.WebSocketErrorCode == WebSocketError.Faulted ||
ex.WebSocketErrorCode == WebSocketError.NotAWebSocket);
}
Assert.Equal(WebSocketState.Closed, cws.State);
Assert.Equal(ResourceHelper.GetExceptionMessage("net_webstatus_ConnectFailure"), ex.Message);
}
}

Expand Down