diff --git a/src/libraries/Common/tests/System/Net/Configuration.Sockets.cs b/src/libraries/Common/tests/System/Net/Configuration.Sockets.cs
index 52b01903b9a91..8f5cb34c0fab5 100644
--- a/src/libraries/Common/tests/System/Net/Configuration.Sockets.cs
+++ b/src/libraries/Common/tests/System/Net/Configuration.Sockets.cs
@@ -9,6 +9,8 @@ public static partial class Configuration
public static partial class Sockets
{
public static Uri SocketServer => GetUriValue("COREFX_NET_SOCKETS_SERVERURI", new Uri("http://" + DefaultAzureServer));
+
+ public static string InvalidHost => GetValue("COREFX_NET_SOCKETS_INVALIDSERVER", "notahostname.invalid.corp.microsoft.com");
}
}
}
diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
index 8c8a3c63ef348..d10679ea5be2c 100644
--- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
+++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
@@ -2681,7 +2681,7 @@ await LoopbackServerFactory.CreateServerAsync(async (server, rootUrl) =>
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // [ActiveIssue(11057)]
public async Task GetAsync_InvalidUrl_ExpectedExceptionThrown()
{
- string invalidUri = $"http://_{Guid.NewGuid().ToString("N")}";
+ string invalidUri = $"http://{Configuration.Sockets.InvalidHost}";
_output.WriteLine($"{DateTime.Now} connecting to {invalidUri}");
using (HttpClient client = CreateHttpClient())
{
diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
index 7d4d43fb493f6..bf572f89d3cc4 100644
--- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
+++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
@@ -58,6 +58,9 @@
Common\System\Net\Configuration.Security.cs
+
+ Common\System\Net\Configuration.Sockets.cs
+
Common\System\Net\TestWebProxies.cs
diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs
index 607a7ad1322f1..81f40bdddea02 100644
--- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs
+++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs
@@ -10,6 +10,8 @@
namespace System.Net.Sockets.Tests
{
+ using Configuration = System.Net.Test.Common.Configuration;
+
public class DnsEndPointTest : DualModeBase
{
private void OnConnectAsyncCompleted(object sender, SocketAsyncEventArgs args)
@@ -60,7 +62,7 @@ public void Socket_ConnectDnsEndPoint_Failure()
{
SocketException ex = Assert.ThrowsAny(() =>
{
- sock.Connect(new DnsEndPoint("notahostname.invalid.corp.microsoft.com", UnusedPort));
+ sock.Connect(new DnsEndPoint(Configuration.Sockets.InvalidHost, UnusedPort));
});
SocketError errorCode = ex.SocketErrorCode;
@@ -150,7 +152,7 @@ public void Socket_BeginConnectDnsEndPoint_Failure()
{
SocketException ex = Assert.ThrowsAny(() =>
{
- IAsyncResult result = sock.BeginConnect(new DnsEndPoint("notahostname.invalid.corp.microsoft.com", UnusedPort), null, null);
+ IAsyncResult result = sock.BeginConnect(new DnsEndPoint(Configuration.Sockets.InvalidHost, UnusedPort), null, null);
sock.EndConnect(result);
});
@@ -256,7 +258,7 @@ public void Socket_ConnectAsyncDnsEndPoint_HostNotFound()
Assert.True(Capability.IPv4Support());
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
- args.RemoteEndPoint = new DnsEndPoint("notahostname.invalid.corp.microsoft.com", UnusedPort);
+ args.RemoteEndPoint = new DnsEndPoint(Configuration.Sockets.InvalidHost, UnusedPort);
args.Completed += OnConnectAsyncCompleted;
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
@@ -356,7 +358,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type)
public void Socket_StaticConnectAsync_HostNotFound()
{
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
- args.RemoteEndPoint = new DnsEndPoint("notahostname.invalid.corp.microsoft.com", UnusedPort);
+ args.RemoteEndPoint = new DnsEndPoint(Configuration.Sockets.InvalidHost, UnusedPort);
args.Completed += OnConnectAsyncCompleted;
ManualResetEvent complete = new ManualResetEvent(false);