Adding multi-machine scripts and unifying configuration.
authorCristian Pop <Cristian.Pop@microsoft.com>
Thu, 9 Jun 2016 00:32:30 +0000 (17:32 -0700)
committerCristian Pop <Cristian.Pop@microsoft.com>
Tue, 28 Jun 2016 19:38:07 +0000 (12:38 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/c354b2d44f6988a20a9f7be4a1b996ef7fbc873a

85 files changed:
src/libraries/Common/tests/Scripts/Prerequisites/config.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_activedirectory_client.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_activedirectory_domaincontroller.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_certificates.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_client.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_common.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_firewall.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Prerequisites/setup_iisserver.ps1 [new file with mode: 0644]
src/libraries/Common/tests/Scripts/Tools/ParallelTestExecution.ps1 [moved from src/libraries/Common/tests/Scripts/ParallelTestExecution.ps1 with 100% similarity]
src/libraries/Common/tests/System/Net/Capability.Security.cs
src/libraries/Common/tests/System/Net/CertificateConfiguration.cs [deleted file]
src/libraries/Common/tests/System/Net/Configuration.Certificates.cs [new file with mode: 0644]
src/libraries/Common/tests/System/Net/Configuration.Http.cs [new file with mode: 0644]
src/libraries/Common/tests/System/Net/Configuration.Security.cs
src/libraries/Common/tests/System/Net/Configuration.Sockets.cs [new file with mode: 0644]
src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs [new file with mode: 0644]
src/libraries/Common/tests/System/Net/Configuration.cs
src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs
src/libraries/Common/tests/System/Net/HttpTestServers.cs [deleted file]
src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs
src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs [moved from src/libraries/Common/tests/System/Net/Sockets/Configuration.cs with 89% similarity]
src/libraries/Common/tests/System/Net/TestSettings.cs [deleted file]
src/libraries/Common/tests/System/Net/WebSocketTestServers.cs [deleted file]
src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ServerCertificateTest.cs
src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj
src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/DefaultCredentialsTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ClientCertificates.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.DefaultProxyCredentials.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.MaxConnectionsPerServer.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.MaxResponseHeadersLength.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.SslProtocols.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/PostScenarioTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/SchSendAuxRecordHttpTest.cs
src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
src/libraries/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs
src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj
src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs
src/libraries/System.Net.Requests/tests/HttpWebResponseTest.cs
src/libraries/System.Net.Requests/tests/RequestStreamTest.cs
src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj
src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationClientServer.cs
src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationRemoteServer.cs
src/libraries/System.Net.Security/tests/FunctionalTests/DummyTcpServer.cs
src/libraries/System.Net.Security/tests/FunctionalTests/NegotiateStreamKerberosTest.cs
src/libraries/System.Net.Security/tests/FunctionalTests/ServerAsyncAuthenticateTest.cs
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSchSendAuxRecordTest.cs
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamStreamToStreamTest.cs
src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj
src/libraries/System.Net.Security/tests/Scripts/Unix/kdc.conf [moved from src/libraries/System.Net.Security/tests/Scripts/kdc.conf with 100% similarity]
src/libraries/System.Net.Security/tests/Scripts/Unix/kdc.conf.centos [moved from src/libraries/System.Net.Security/tests/Scripts/kdc.conf.centos with 100% similarity]
src/libraries/System.Net.Security/tests/Scripts/Unix/kdc.conf.opensuse [moved from src/libraries/System.Net.Security/tests/Scripts/kdc.conf.opensuse with 100% similarity]
src/libraries/System.Net.Security/tests/Scripts/Unix/kdc.conf.ubuntu [moved from src/libraries/System.Net.Security/tests/Scripts/kdc.conf.ubuntu with 100% similarity]
src/libraries/System.Net.Security/tests/Scripts/Unix/krb5.conf [moved from src/libraries/System.Net.Security/tests/Scripts/krb5.conf with 100% similarity]
src/libraries/System.Net.Security/tests/Scripts/Unix/setup-kdc.sh [moved from src/libraries/System.Net.Security/tests/Scripts/setup-kdc.sh with 100% similarity, mode: 0644]
src/libraries/System.Net.Sockets/tests/FunctionalTests/AcceptAsync.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/ConnectAsync.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/ConnectExTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/IPPacketInformationTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/ReceiveMessageFrom.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/ReceiveMessageFromAsync.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SelectAndPollTests.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj
src/libraries/System.Net.Sockets/tests/FunctionalTests/TcpClientTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/TimeoutTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs
src/libraries/System.Net.Sockets/tests/PerformanceTests/System.Net.Sockets.Async.Performance.Tests.csproj
src/libraries/System.Net.Sockets/tests/Scripts/ClearReuseUnicastPort.ps1 [moved from src/libraries/System.Net.Sockets/tests/FunctionalTests/prerequisites/ClearReuseUnicastPort.ps1 with 100% similarity]
src/libraries/System.Net.Sockets/tests/Scripts/SetReuseUnicastPort.ps1 [moved from src/libraries/System.Net.Sockets/tests/FunctionalTests/prerequisites/SetReuseUnicastPort.ps1 with 100% similarity]
src/libraries/System.Net.Sockets/tests/Scripts/readme.txt [moved from src/libraries/System.Net.Sockets/tests/FunctionalTests/prerequisites/readme.txt with 100% similarity]
src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketTestBase.cs
src/libraries/System.Net.WebSockets.Client/tests/KeepAliveTest.cs
src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj

diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/config.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/config.ps1
new file mode 100644 (file)
index 0000000..a608206
--- /dev/null
@@ -0,0 +1,96 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#
+# CoreFX - Net configuration
+#
+
+# -- Machine selection
+
+# You can find the host name by logging on to the target machine and typing "hostname" in a cmd console.
+# You can find the IP address by logging on to the target machine and typing "ipconfig" in a cmd console.
+# Requirements:
+#  - The machines below should be within the same LAN network.
+#  - All machines must have Powershell >3.0 installed. 
+
+# IMPORTANT: 
+#           The state for the following machines will be changed irreversably. 
+#           The uninstall step will remove the installed components regardless if it existed before the deployment or
+#           was altered/customized after deployment. 
+#
+
+# A Windows Server SKU hosting Active Directory services. This machine will become the Domain Controller:
+$COREFX_NET_AD_Machine = ""         #Example: "TESTAD"
+$COREFX_NET_AD_MachineIP = ""         #Example: "192.168.0.1" - must be a Static IPv4 address.
+
+# A Windows Client or Server SKU hosting the IIS Server. This machine will be joined to the Domain.
+$COREFX_NET_IISSERVER_Machine = ""  #Example: "TESTIIS"
+$COREFX_NET_IISSERVER_MachineIP = ""        #Example: "192.168.0.1" - must be a Static IPv4 address.
+
+# A Windows Client or Server SKU hosting the corefx enlistment. This machine will be joined to the Domain.
+$COREFX_NET_CLIENT_Machine = ""     #Example: "TESTCLIENT"
+
+# -- Test parameters
+
+# For security reasons, it's advisable that the default username/password pairs below are changed regularly.
+
+$script:domainName = "corp.contoso.com"
+$script:domainNetbios = "corefx-net-ad"
+
+$script:domainUserName = "testaduser"
+$script:domainUserPassword = "Test-ADPassword"
+
+$script:basicUserName = "testbasic"
+$script:basicUserPassword = "Test-Basic"
+
+# Changing the IISServer FQDN may require changing certificates.
+$script:iisServerFQDN = "testserver.contoso.com"
+
+$script:PreRebootRoles = @(
+    @{Name = "COREFX_NET_AD_CLIENT"; Script = "setup_activedirectory_client.ps1"; MachineName = $COREFX_NET_IISSERVER_Machine},
+    @{Name = "COREFX_NET_AD_CLIENT"; Script = "setup_activedirectory_client.ps1"; MachineName = $COREFX_NET_CLIENT_Machine},
+    @{Name = "COREFX_NET_AD_DC"; Script = "setup_activedirectory_domaincontroller.ps1"; MachineName = $COREFX_NET_AD_Machine; MachineIP = $COREFX_NET_AD_MachineIP}
+)
+
+$script:Roles = @(
+    @{Name = "COREFX_NET_IISSERVER"; Script = "setup_iisserver.ps1"; MachineName = $COREFX_NET_IISSERVER_Machine; MachineIP = $COREFX_NET_IISSERVER_MachineIP},
+    @{Name = "COREFX_NET_CLIENT"; Script = "setup_client.ps1"; MachineName = $COREFX_NET_CLIENT_Machine},
+    @{Name = "COREFX_NET_AD_DC"; Script = "setup_activedirectory_domaincontroller.ps1"; MachineName = $COREFX_NET_AD_Machine; MachineIP = $COREFX_NET_AD_MachineIP}
+)
+
+# The following variable names should match the ones read by Configuration.*.cs code.
+$script:ClientConfiguration = @(
+
+# TODO #9048: 
+    # Configuration.Http:
+#    @{Name = "COREFX_HTTPHOST"; Value = $script:iisServerFQDN},
+#    @{Name = "COREFX_SECUREHTTPHOST"; Value = $script:iisServerFQDN},
+#    @{Name = "COREFX_HTTP2HOST"; Value = $script:iisServerFQDN},                # Requires Windows 10 and above.
+#    @{Name = "COREFX_DOMAINJOINED_HTTPHOST"; Value = $script:iisServerFQDN},
+#    @{Name = "COREFX_DOMAINJOINED_PROXYHOST"; Value = $null},                   # TODO 9048: Install & configure ISA/TMG or Squid
+#    @{Name = "COREFX_DOMAINJOINED_PROXYPORT"; Value = $null},                   # TODO 9048: Install & configure ISA/TMG or Squid
+#    @{Name = "COREFX_HTTPHOST_SSL2"; Value = $null},                            # TODO 9048: move to a localhost server or configure these websites.
+#    @{Name = "COREFX_HTTPHOST_SSL3"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_TLS10"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_TLS11"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_TLS12"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_EXPIREDCERT"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_WRONGHOSTNAME"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_SELFSIGNEDCERT"; Value = $null},
+#    @{Name = "COREFX_HTTPHOST_REVOKEDCERT"; Value = $null},
+#    @{Name = "COREFX_STRESS_HTTP"; Value = "1"},
+
+    # Configuration.WebSockets:
+#    @{Name = "COREFX_WEBSOCKETHOST"; Value = $script:domainNetbios},
+#    @{Name = "COREFX_SECUREWEBSOCKETHOST"; Value = $script:domainNetbios},
+
+    # Configuration.Security:
+    @{Name = "COREFX_NET_AD_DOMAINNAME"; Value = $script:domainNetbios},
+    @{Name = "COREFX_NET_AD_USERNAME"; Value = $script:domainUserName},
+    @{Name = "COREFX_NET_AD_PASSWORD"; Value = $script:domainUserPassword},
+    @{Name = "COREFX_NET_SECURITY_NEGOSERVERURI"; Value = "http://$($script:iisServerFQDN)"},
+    @{Name = "COREFX_NET_SECURITY_TLSSERVERURI"; Value = "https://$($script:iisServerFQDN)"},
+
+    @{Name = "COREFX_NET_SOCKETS_SERVERURI"; Value = "http://$($script:iisServerFQDN)"}
+)
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup.ps1
new file mode 100644 (file)
index 0000000..961e024
--- /dev/null
@@ -0,0 +1,221 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#Requires -RunAsAdministrator
+
+Param (
+    [switch] $uninstall=$false
+)
+
+# Import configuration.
+. .\setup_common.ps1
+
+Function TestMachineStatus($role)
+{
+    try 
+    {
+        $status = Invoke-Command -ComputerName $role.MachineName -ArgumentList $role.Name -ErrorAction Stop { [Environment]::GetEnvironmentVariable($args[0], "Machine") }
+        
+        $role.Reachable = $true
+        if ($status -eq "Installed")
+        {
+            $role.Installed = $true
+        }
+        else 
+        {
+            if (-not [string]::IsNullOrWhiteSpace($status))
+            {
+                Write-Warning "Role $($role.Name) found to have status of: $status."
+                Write-Warning "The script will try to resume the installation. To manually resume installation, manually run the $($role.Script) on $($role.MachineName) as Administrator."
+            }
+        }
+    }
+    catch [System.Exception] 
+    {
+        $role.Reachable = $false
+    }
+}
+
+Function CheckRoles
+{
+    Write-Host "Verifying roles:"
+    foreach ($role in ($script:Roles + $script:PreRebootRoles))
+    {
+        Write-Host -ForegroundColor DarkGray "`t" $role.Name
+        if (-not (Test-Path $role.Script))
+        {
+            throw "Cannot find installation script for $($role.Name): $($role.Script)"
+        }
+
+        if ([string]::IsNullOrWhiteSpace($role.MachineName))
+        {
+            throw "Please edit config.ps1 and set a valid value name for $($role.Name)_Machine."
+        }
+
+        TestMachineStatus $role
+    }
+
+    Write-Host "OK."
+}
+
+Function EnsurePreRebootForCurrentMachine
+{
+    $machineInfo = Get-WmiObject win32_computersystem
+    $currentRole = GetPreRebootRoleForMachine($Env:COMPUTERNAME)
+
+    if (($machineInfo.PartOfDomain -eq $true) -and `
+        ($machineInfo.Domain -eq $script:domainName) -and `
+        ($currentRole.Installed -eq $true))
+    {
+        return $true
+    }
+    elseif (($machineInfo.PartOfDomain -eq $true) -and ` 
+            ($machineInfo.Domain -ne $script:domainName))
+    {
+        Write-Error "The current machine is already joiend to the $($machineInfo.Domain) domain."
+        Write-Error "Either change config.ps1 to use the correct domain information, select a different machine or remove the machine from the current domain."
+        throw "Cannot use the current machine: already joined to a domain."
+    }
+
+    & (".\" + $currentRole.Script)
+}
+
+Function CreateDestinationPath($s)
+{
+    return Invoke-Command -Session $s `
+    {
+        $destPath = Join-Path $env:SystemDrive "COREFX_NET_Scripts"
+        mkdir $destPath -ErrorAction SilentlyContinue | Out-Null  
+        return $destPath  
+    }    
+}
+
+Function CopyScripts($s, $remotePath)
+{
+    foreach ($file in (dir *.ps1))
+    {
+        Copy-Item -Force -Path $file -Destination $remotePath -ToSession $s -ErrorAction Stop
+    }
+}
+
+Function InstallRoles
+{
+    Write-Host -ForegroundColor Cyan "Remotely installing all roles."
+
+    foreach ($role in $script:Roles)
+    {
+        Write-Host -ForegroundColor DarkCyan "Installing role [$($role.Name)]: $($role.MachineName)"
+
+        Write-Host -ForegroundColor DarkGray "`tConnecting"
+        $s = New-PSSession -ComputerName $role.MachineName
+                 
+        Write-Host -ForegroundColor DarkGray "`tCopying scripts"
+        # Copy scripts
+        $remotePath = CreateDestinationPath $s
+        CopyScripts $s $remotePath
+
+        Write-Host -ForegroundColor DarkGray "`tInstalling"
+        # Run remote scripts
+        Invoke-Command -Session $s -ArgumentList $remotePath, $role.Script `
+        { 
+            $path = $args[0]
+            $script = $args[1]
+            
+            cd $path
+            & (".\" + $script)
+        }
+
+        Write-Host -ForegroundColor DarkCyan "Role [$($role.Name)]: $($role.MachineName) installation complete."
+        Write-Host
+        Write-Host
+    }
+}
+
+Function Install
+{
+    Write-Host -ForegroundColor Cyan "Install/Update CoreFX Networking multi-machine prerequisites"
+    Write-Host
+    CheckRoles
+
+    EnsurePreRebootForCurrentMachine
+
+    if (($script:Roles | where {$_.Reachable -ne $true}).Count -ne 0)
+    {
+        Write-Warning "Not all roles are reachable from this host."
+        Write-Host "Log-on to the following machines, copy all scripts and run .\setup.ps1 as Administrator:"
+        $script:Roles | where {$_.Reachable -ne $true}
+        Write-Host -ForegroundColor Cyan "Rerun this command after all machines have been started and joined to the $($script:domainNetBios) domain."
+        return
+    }
+
+    InstallRoles
+
+    Write-Host -ForegroundColor Cyan "Role installation complete."
+}
+
+Function UnistallMachines
+{
+    Write-Host -ForegroundColor Cyan "Remotely uninstalling roles."
+
+    foreach ($role in $script:Roles)
+    {
+        Write-Host -ForegroundColor DarkCyan "Uninstalling role [$($role.Name)]: $($role.MachineName)"
+
+        Write-Host -ForegroundColor DarkGray "`tConnecting"
+        $s = New-PSSession -ComputerName $role.MachineName
+                 
+        Write-Host -ForegroundColor DarkGray "`tCopying scripts"
+        # Copy scripts
+        $remotePath = CreateDestinationPath $s
+        CopyScripts $s $remotePath
+
+        $preRebootRole = GetPreRebootRoleForMachine $role.MachineName
+
+        Write-Host -ForegroundColor DarkGray "`tUninstalling"
+        # Run remote scripts
+        Invoke-Command -Session $s -ArgumentList $remotePath, $role.Script, $preRebootRole.Script `
+        {
+            $path = $args[0]
+            $script = $args[1]
+            $preRebootScript = $args[2]
+            
+            cd $path
+            & (".\" + $script) -uninstall
+            & (".\" + $preRebootScript) -uninstall
+        }
+
+        Write-Host -ForegroundColor DarkCyan "Role [$($role.Name)]: $($role.MachineName) uninstall complete."
+        Write-Host
+        Write-Host
+    }
+}
+
+Function Uninstall
+{
+    Write-Host -ForegroundColor Cyan "Uninstall CoreFX Networking multi-machine prerequisites"
+    Write-Host
+    CheckRoles
+    Write-Host
+    
+    Write-Warning "Some of the installed components may have existed before or got changes outside of this setup script."
+    Write-Warning "The scripts will attempt to remove all components regardless of these changes."
+    $continue = Read-Host "Do you want to continue? [Y/N]"
+
+    if ($continue.ToUpper() -ne "Y")
+    {
+        Write-Warning "Aborted by user."
+        return
+    }
+
+    UnistallMachines
+}
+
+if ($uninstall)
+{
+    Uninstall
+}
+else
+{
+    Install
+}
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_activedirectory_client.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_activedirectory_client.ps1
new file mode 100644 (file)
index 0000000..cc3ffb6
--- /dev/null
@@ -0,0 +1,82 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#Requires -RunAsAdministrator
+
+#
+#   Run this script on all Active Directory client machines.
+#   Tested on Windows 2016 TP5 and Windows 10.
+#
+Param (
+    [switch] $uninstall=$false
+)
+
+# Imports:
+. .\setup_common.ps1
+
+$script:COREFX_ROLE_NAME = "COREFX_NET_AD_CLIENT"
+
+Function ConfigureDNS
+{
+    Write-Host -ForegroundColor Cyan "Configuring DNS"
+
+    $dcRole = GetRole "COREFX_NET_AD_DC"
+
+    if (-not (Test-Connection $dcRole.MachineIP))
+    {
+        throw "The local machine cannot ping the Domain Controller/DNS Server at $($dcRole.MachineIP).`n" + `
+        "Ensure that the setup was completed on the machine then try re-running the script on this machine again."
+    }
+
+    $ipv4DnsInterfaces = Get-DnsClientServerAddress | where {($_.AddressFamily -eq 2) -and ($_.InterfaceAlias -eq "Ethernet")}
+    $ifIndex = $ipv4DnsInterfaces[0].InterfaceIndex
+    
+    Set-DnsClientServerAddress -InterfaceIndex $ifIndex -ServerAddresses ($dcRole.MachineIP)
+}
+
+Function EnableAD
+{
+    Write-Host -ForegroundColor Cyan "Adding computer to domain. Please use the domain administrator password for the $($script:domainNetbios) domain."
+    Add-Computer -DomainName $script:domainNetbios
+}
+
+Function Install
+{
+    Write-Host -ForegroundColor Cyan "Installing prerequisites for test role: $($script:COREFX_ROLE_NAME)"
+
+    CheckPreRebootMachineInfo
+    ConfigureDNS
+    EnableAD
+    Enable-PSRemoting
+    EnvironmentSetRebootPendingRoleStatus
+    Write-Host -ForegroundColor Cyan "Please re-start one instance of the script on any of the machines after reboot to resume the installation."
+    Read-Host "[Press ENTER to reboot.]"
+    Restart-Computer
+    EnvironmentSetInstalledRoleStatus
+}
+
+Function Uninstall
+{
+    Write-Host -ForegroundColor Cyan "Removing prerequisites for test role: $($script:COREFX_ROLE_NAME)."
+    
+    EnvironmentCheckUninstallRoleStatus
+
+    Remove-Computer
+    EnvironmentRemoveRoleStatus
+
+    Write-Warning "Current DNS configuration:"
+    Get-DnsClientServerAddress
+    Write-Warning "To complete the uninstallation, you may need to change the DNS client address configuration."
+    Read-Host "[Press ENTER to reboot.]"
+    Restart-Computer
+}
+
+if ($uninstall)
+{
+    Uninstall
+}
+else
+{
+    Install
+}
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_activedirectory_domaincontroller.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_activedirectory_domaincontroller.ps1
new file mode 100644 (file)
index 0000000..4c108ce
--- /dev/null
@@ -0,0 +1,96 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#Requires -RunAsAdministrator
+
+#
+#   Run this script on the Active Directory Domain Controller machine.
+#   Tested on Windows 2016 TP5
+#
+
+Param (
+    [switch] $uninstall=$false
+)
+
+# Import configuration.
+. .\setup_common.ps1
+
+$script:COREFX_ROLE_NAME = "COREFX_NET_AD_DC"
+
+Function EnableAD
+{
+    Write-Host -ForegroundColor Cyan "Installing Active Directory."
+    CheckPreRebootMachineInfo
+    
+    # From https://technet.microsoft.com/en-us/library/hh472162.aspx
+    Install-Windowsfeature -name AD-Domain-Services -IncludeManagementTools
+   
+    # Will prompt for SafeModeAdministratorPassword:
+    Install-ADDSForest -domainname $script:domainName -DomainNetbiosName $script:domainNetbios -NoRebootOnCompletion
+}
+
+Function AddUser
+{
+    Write-Host -ForegroundColor Cyan "Creating domain user."
+    Remove-ADUser $script:domainUserName -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
+    New-ADUser $script:domainUserName -Enabled $true -PasswordNeverExpires $true -AccountPassword (ConvertTo-SecureString $script:domainUserPassword -AsPlainText -force)
+}
+
+Function ConfigureDNS
+{
+    Write-Host -ForegroundColor Cyan "Configuring DNS."
+    
+    # TODO: Extract IIS Machine IP from Config.
+    $iisServer  = GetRole "COREFX_NET_IISSERVER"
+
+    $serverName = ($script:iisServerFQDN).Split('.')[0];
+    $zoneName = ($script:iisServerFQDN).Substring($serverName.Length + 1)  
+    
+    Remove-DnsServerZone -Name $zoneName -Force -ErrorAction SilentlyContinue | Out-Null
+    Add-DnsServerPrimaryZone -Name $zoneName -ReplicationScope "Forest"
+    Add-DnsServerResourceRecordA -Name $serverName -ZoneName $zoneName -AllowUpdateAny -IPv4Address $iisServer.MachineIP -TimeToLive 01:00:00 
+}
+
+Function Install
+{
+    Write-Host -ForegroundColor Cyan "Installing prerequisites for test role: $($script:COREFX_ROLE_NAME)."
+
+    if ((-not (EnvironmentIsRoleInstalled)) -and (-not (EnvironmentIsRoleRebootPending)))
+    {
+        EnableAD
+        EnvironmentSetRebootPendingRoleStatus
+        Write-Host -ForegroundColor Cyan "Please re-start the script after the machine reboots."
+        Read-Host "[Press ENTER to reboot.]"
+        Restart-Computer
+    }
+    else
+    {
+        AddUser
+        ConfigureDNS
+        Enable-PSRemoting
+        EnvironmentSetInstalledRoleStatus
+        Write-Host -ForegroundColor Cyan "Prerequisites installed for $($script:COREFX_ROLE_NAME)."
+        Write-Host
+    }
+}
+
+Function Uninstall
+{
+    Write-Host -ForegroundColor Cyan "Removing prerequisites for test role: $($script:COREFX_ROLE_NAME)."
+
+    EnvironmentCheckUninstallRoleStatus
+    EnvironmentRemoveRoleStatus
+    
+    # Will reboot.
+    Uninstall-ADDSDomainController -LastDomainControllerInDomain -RemoveApplicationPartitions -IgnoreLastDNSServerForZone
+}
+
+if ($uninstall)
+{
+    Uninstall
+}
+else
+{
+    Install
+}
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_certificates.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_certificates.ps1
new file mode 100644 (file)
index 0000000..ec7ed4b
--- /dev/null
@@ -0,0 +1,129 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#Requires -RunAsAdministrator
+
+# Certificate configuration
+
+$script:testDataUri = "https://github.com/dotnet/corefx-testdata/archive/master.zip" 
+$script:testData = "corefx-testdata"
+$script:certificatePath = "$($script:testData)\corefx-testdata-master\System.Net.TestData"
+
+$script:clientPrivateKeyPath = Join-Path $script:certificatePath "testclient1_at_contoso.com.pfx"
+$script:clientPrivateKeyPassword = "testcertificate"
+
+$script:serverPrivateKeyPath = Join-Path $script:certificatePath "contoso.com.pfx"
+$script:serverPrivateKeyPassword = "testcertificate"
+
+Function GetFullPath($relativePath)
+{
+    return (Get-Item $relativePath).FullName
+}
+
+Function DeleteTestData
+{
+    if (Test-Path $script:testData)
+    {
+        rmdir $script:testData -Recurse -Force 
+    }
+    
+    del ($testData + ".zip") -ErrorAction SilentlyContinue
+}
+
+Function DownloadTestData
+{
+    DeleteTestData
+    DownloadFile $script:testDataUri ($testData + ".zip")
+    Expand-Archive ($testData + ".zip")
+}
+
+Function LoadCertificateAndRoot($fileName, $password)
+{
+    $privateCerts = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
+    $fullPath = GetFullPath $fileName
+   
+    $privateCerts.Import($fullPath, $password, ("MachineKeySet", "PersistKeySet", "Exportable"))
+
+    $privateKeyCert = $null
+    foreach ($cert in $privateCerts)
+    {
+        if ($privateKeyCert -eq $null -and $cert.HasPrivateKey)
+        {
+            $privateKeyCert = $cert
+        }
+    }
+
+    $rootCACert = $privateCerts | where {$_.Subject -eq $privateKeyCert.Issuer}
+
+    return ($privateKeyCert, $rootCACert)
+}
+
+Function AddCertificateToStore($certificate, $storeName, $storeLocation)
+{
+    $rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store($storeName, $storeLocation)
+    $rootStore.Open("ReadWrite")
+    $rootStore.Add($certificate)
+    $rootStore.Close()
+}
+
+Function InstallCertificates($fileName, $password)
+{
+    Write-Host "Acquiring test data."
+    DownloadTestData
+
+    Write-Host "Adding certificates"
+    ($private, $root) = LoadCertificateAndRoot $fileName $password
+
+    Write-Host -ForegroundColor DarkGray "`tAdding root certificate: $($root.Subject)"
+    AddCertificateToStore $root "Root" "LocalMachine"
+
+    Write-Host -ForegroundColor DarkGray "`tAdding private key certificate: $($private.Subject)"
+    AddCertificateToStore $private "My" "LocalMachine"
+
+    Write-Host "Removing temporary files"
+    DeleteTestData
+}
+
+Function InstallClientCertificates
+{
+    Write-Host -ForegroundColor Cyan "Installing Client Certificates"
+    InstallCertificates $script:clientPrivateKeyPath $script:clientPrivateKeyPassword
+}
+
+Function InstallServerCertificates
+{
+    Write-Host -ForegroundColor Cyan "Installing Server Certificates"
+    InstallCertificates $script:serverPrivateKeyPath $script:serverPrivateKeyPassword
+}
+
+Function GetServerCertificate
+{
+    return dir Cert:\LocalMachine\My | where { $_.DnsNameList | where{$_.Punycode -eq $script:iisServerFQDN} }
+}
+
+Function RemoveCertificates($filename, $password)
+{
+    Write-Host "Acquiring test data."
+    DownloadTestData
+    ($private, $root) = LoadCertificateAndRoot $fileName $password
+    
+    Write-Host -ForegroundColor DarkGray "`tRemoving root certificate: $($root.Subject)"
+    dir Cert:\LocalMachine\Root | where {$_.Subject -eq $root.Subject} | foreach { rm (Join-Path Cert:\LocalMachine\Root $_.Thumbprint) }
+    Write-Host -ForegroundColor DarkGray "`tRemoving private key certificate: $($private.Subject)"
+    dir Cert:\LocalMachine\My | where {$_.Subject -eq $private.Subject} | foreach { rm (Join-Path Cert:\LocalMachine\My $_.Thumbprint) -DeleteKey }
+    
+    DeleteTestData
+}
+
+Function RemoveClientCertificates
+{
+    Write-Host -ForegroundColor Cyan "Removing Client Certificates"
+    RemoveCertificates $script:clientPrivateKeyPath $script:clientPrivateKeyPassword
+}
+
+Function RemoveServerCertificates
+{
+    Write-Host -ForegroundColor Cyan "Removing Server Certificates"
+    RemoveCertificates $script:serverPrivateKeyPath $script:serverPrivateKeyPassword
+}
\ No newline at end of file
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_client.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_client.ps1
new file mode 100644 (file)
index 0000000..c3b347b
--- /dev/null
@@ -0,0 +1,64 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Param (
+    [switch] $uninstall=$false
+)
+
+# Imports:
+. .\setup_common.ps1
+. .\setup_certificates.ps1
+
+$script:COREFX_ROLE_NAME = "COREFX_NET_CLIENT"
+
+Function InstallClientEnvironmentConfiguration
+{
+    Write-Host -ForegroundColor Cyan "Installing client configuration."
+
+    foreach ($configEntry in $script:ClientConfiguration)
+    {  
+        [Environment]::SetEnvironmentVariable($configEntry.Name, $configEntry.Value, "Machine")
+    }
+}
+
+Function UninstallClientEnvironmentConfiguration
+{
+    Write-Host -ForegroundColor Cyan "Removing client configuration."
+
+    foreach ($configEntry in $script:ClientConfiguration)
+    {  
+        [Environment]::SetEnvironmentVariable($configEntry.Name, $null, "Machine")
+    }
+}
+
+Function Install
+{
+    Write-Host -ForegroundColor Cyan "Installing prerequisites for test role: $($script:COREFX_ROLE_NAME)."
+    CheckMachineInfo
+
+    InstallClientCertificates
+    InstallClientEnvironmentConfiguration
+
+    EnvironmentSetInstalledRoleStatus
+}
+
+Function Uninstall
+{
+    Write-Host -ForegroundColor Cyan "Removing prerequisites for test role: $($script:COREFX_ROLE_NAME)."
+    EnvironmentCheckUninstallRoleStatus
+
+    RemoveClientCertificates
+    UninstallClientEnvironmentConfiguration
+
+    EnvironmentRemoveRoleStatus
+}
+
+if ($uninstall)
+{
+    Uninstall
+}
+else
+{
+    Install
+}
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_common.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_common.ps1
new file mode 100644 (file)
index 0000000..63483fc
--- /dev/null
@@ -0,0 +1,110 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+. .\config.ps1
+
+Function GetRoleForMachine($machineName)
+{
+    return $script:Roles | where {$_.MachineName.ToUpper() -eq $machineName.ToUpper()}
+}
+
+Function GetPreRebootRoleForMachine($machineName)
+{
+    return $script:PreRebootRoles | where {$_.MachineName.ToUpper() -eq $machineName.ToUpper()}
+}
+
+Function GetRole($roleName)
+{
+    return $script:Roles | where {$_.Name.ToUpper() -eq $roleName.ToUpper()}
+}
+
+Function CheckPreRebootMachineInfo
+{
+    $role = GetPreRebootRoleForMachine $Env:COMPUTERNAME
+
+    if ($role.Name -ne $script:COREFX_ROLE_NAME)
+    {
+        throw "This script needs to run on machines part of the $($role.Name) role."
+    }
+
+    if ((-not [string]::IsNullOrWhiteSpace($role.MachineIP)) -and ((Get-NetIPAddress | where {$_.IPAddress -eq $role.MachineIP}).Count -eq 0))
+    {
+        throw "The current machine doesn't have the expected Static IP address: $($role.MachineIP)"
+    }
+}
+
+Function CheckMachineInfo
+{
+    $role = GetRoleForMachine $Env:COMPUTERNAME
+
+    if ($role.Name -ne $script:COREFX_ROLE_NAME)
+    {
+        throw "This script needs to run on machines part of the $($role.Name) role."
+    }
+
+    if ((-not [string]::IsNullOrWhiteSpace($role.MachineIP)) -and ((Get-NetIPAddress | where {$_.IPAddress -eq $role.MachineIP}).Count -eq 0))
+    {
+        throw "The current machine doesn't have the expected Static IP address: $($role.MachineIP)"
+    }
+}
+
+Function EnvironmentAddRoleStatus($status)
+{
+    [Environment]::SetEnvironmentVariable($script:COREFX_ROLE_NAME, $status, "Machine")
+}
+
+Function EnvironmentSetInstalledRoleStatus
+{
+    EnvironmentAddRoleStatus "Installed"
+}
+
+Function EnvironmentSetRebootPendingRoleStatus
+{
+    EnvironmentAddRoleStatus "PendingReboot"
+}
+
+Function EnvironmentRemoveRoleStatus
+{
+    [Environment]::SetEnvironmentVariable($script:COREFX_ROLE_NAME, $null, "Machine")
+}
+
+Function EnvironmentCheckUninstallRoleStatus
+{
+    if ([Environment]::GetEnvironmentVariable($script:COREFX_ROLE_NAME, "Machine") -ne "Installed")
+    {
+        Write-Warning "The machine doesn't appear to be in the $($script:COREFX_ROLE_NAME) role."
+        $continue = Read-Host "Do you want to continue? [Y/N]"
+        if ($continue.ToUpper() -ne "Y")
+        {
+            Write-Warning "Aborted by user."
+            exit
+        }
+    }
+}
+
+Function EnvironmentIsRoleRebootPending
+{
+    return [Environment]::GetEnvironmentVariable($script:COREFX_ROLE_NAME, "Machine") -eq "PendingReboot"
+}
+
+Function EnvironmentIsRoleInstalled
+{
+    return [Environment]::GetEnvironmentVariable($script:COREFX_ROLE_NAME, "Machine") -eq "Installed"
+}
+
+Function DownloadFile($source, $destination)
+{
+    # BITS remoting doesn't work on systems <= TH2.
+    if ([System.Environment]::OSVersion.Version -gt (new-object 'Version' 10,0,10586,0))
+    {
+        Start-BitsTransfer -Source $source -Destination $destination
+    }
+    else 
+    {
+        # BUG: taking very long: Invoke-WebRequest $source -OutFile $destination
+        $fqDestination = Join-Path (pwd) $destination
+        $wc = New-Object System.Net.WebClient
+        $wc.Downloadfile($source, $fqDestination.ToString())
+    }
+}
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_firewall.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_firewall.ps1
new file mode 100644 (file)
index 0000000..0964ee4
--- /dev/null
@@ -0,0 +1,32 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#Requires -RunAsAdministrator
+
+# Firewall configuration
+$script:firewallGroup = "CoreFX Testing"
+$script:firewallRules = @(
+    @{Name = "CoreFXNet - HTTP 80"; Port = 80},
+    @{Name = "CoreFXNet - HTTP 443"; Port = 443}
+)
+
+Function InstallServerFirewall
+{
+    Write-Host -ForegroundColor Cyan "Installing Firewall rules."
+    foreach ($rule in $script:firewallRules)
+    {
+        Write-Host -ForegroundColor DarkGray "`t" $rule.Name
+        New-NetFirewallRule -DisplayName $rule.Name -Group $script:firewallGroup -Direction Inbound -Protocol TCP -LocalPort $rule.Port -Action Allow | Out-Null
+    }
+}
+
+Function RemoveServerFirewall
+{
+    Write-Host -ForegroundColor Cyan "Removing Firewall rules."
+    foreach ($rule in $script:firewallRules)
+    {
+        Write-Host -ForegroundColor DarkGray "`t" $rule.Name
+        Remove-NetFirewallRule -DisplayName $rule.Name | Out-Null
+    }
+}
diff --git a/src/libraries/Common/tests/Scripts/Prerequisites/setup_iisserver.ps1 b/src/libraries/Common/tests/Scripts/Prerequisites/setup_iisserver.ps1
new file mode 100644 (file)
index 0000000..e23f001
--- /dev/null
@@ -0,0 +1,227 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+#Requires -RunAsAdministrator
+
+#
+#   Run this script on the IIS server machine.
+#   Tested on Windows 2016 TP5
+# 
+
+Param (
+    [switch] $uninstall=$false
+)
+
+# Imports:
+. .\setup_common.ps1
+. .\setup_certificates.ps1
+. .\setup_firewall.ps1
+
+# Server application configuration
+$script:serverCodeUri = "https://github.com/davidsh/corefx-net-testservers/archive/master.zip"
+$script:serverCodeZip = "serverCode"
+$script:iisWwwRoot = "$env:systemdrive\inetpub\wwwroot"
+$script:serverCodeRootPath = "$($script:serverCodeZip)\corefx-net-testservers-master\CoreFxNetCloudService"
+$script:defaultWebSite = "Default Web Site"
+
+$script:webApps = @(
+    @{Name = "NoAuth"; 
+        IISRelativePath = ""; 
+        SourceRelativePath = "WebServer"; 
+
+        Configuration = @()
+     },
+
+    @{Name = "BasicAuth"; 
+        IISRelativePath = "BasicAuth"; 
+        SourceRelativePath = "WebServer"; 
+        Configuration  = @(
+            @{ Path = "/system.webServer/security/authentication/anonymousAuthentication"; Name = "Enabled"; Value = "False" }
+            @{ Path = "/system.webServer/security/authentication/basicAuthentication"; Name = "Enabled"; Value = "True" }
+        );
+        UserAccess = @( $script:basicUserName )
+     },
+
+    @{Name = "DigestAuth"; 
+        IISRelativePath = "DigestAuth"; 
+        SourceRelativePath = "WebServer"; 
+        Configuration  = @(
+            @{ Path = "/system.webServer/security/authentication/anonymousAuthentication"; Name = "Enabled"; Value = "False" }
+            @{ Path = "/system.webServer/security/authentication/digestAuthentication"; Name = "Enabled"; Value = "True" }
+        );
+        UserAccess = @( $script:basicUserName )
+     },
+
+    @{Name = "WindowsAuth"; 
+        IISRelativePath = "WindowsAuth"; 
+        SourceRelativePath = "WebServer";
+        Configuration  = @(
+            @{ Path = "/system.webServer/security/authentication/anonymousAuthentication"; Name = "Enabled"; Value = "False" }
+            @{ Path = "/system.webServer/security/authentication/windowsAuthentication"; Name = "Enabled"; Value = "True" }
+        );
+        UserAccess = @( "$($script:domainNetbios)\$($script:domainUserName)" )
+     }
+)
+
+$script:COREFX_ROLE_NAME = "COREFX_NET_IISSERVER"
+
+Function InstallIIS
+{
+    Write-Host -ForegroundColor Cyan "Installing IIS components."
+    Install-WindowsFeature -Name Web-Server,Web-Basic-Auth,Web-Digest-Auth,Web-Windows-Auth,Web-Cert-Auth,Web-Asp-Net45,Web-WebSockets -IncludeManagementTools -ErrorAction Stop | Out-Null
+}
+
+Function RemoveIIS
+{
+    Write-Host -ForegroundColor Cyan "Removing IIS components."
+    Uninstall-WindowsFeature -Name Web-Server -IncludeManagementTools
+}
+
+Function CreateLocalUser
+{
+    # A local user is required to allow Basic and Digest authentication. (WDigest not supported.)
+    Write-Host -ForegroundColor Cyan "Creating local user account."
+    Remove-LocalUser $script:basicUserName -Confirm:$false -ErrorAction SilentlyContinue
+    New-LocalUser $script:basicUserName -PasswordNeverExpires -Password (ConvertTo-SecureString $script:basicUserPassword -AsPlainText -force) | Out-Null
+}
+
+Function RemoveLocalUser
+{
+    Write-Host -ForegroundColor Cyan "Removing local user account."
+    Remove-LocalUser $script:basicUserName -Confirm:$false
+}
+
+Function DeleteTemporaryFiles
+{
+    if (Test-Path $script:serverCodeZip)
+    {
+        rmdir $script:serverCodeZip -Recurse -Force 
+    }
+    
+    del ($script:serverCodeZip + ".zip") -ErrorAction SilentlyContinue
+}
+
+Function DownloadServerCode
+{
+    DeleteTemporaryFiles
+    DownloadFile $script:serverCodeUri ($script:serverCodeZip + ".zip")
+    Expand-Archive ($script:serverCodeZip + ".zip")
+}
+
+Function ConfigureWebSites
+{
+    Write-Host -ForegroundColor Cyan "Configuring IIS websites."
+
+    # SSL Bindings
+    $sslCert = GetServerCertificate
+    
+    Get-WebBinding -Port 443 -Name $script:defaultWebSite | Remove-WebBinding
+    New-WebBinding -Name $script:defaultWebSite -Protocol https -Port 443
+
+    Remove-Item -Path "IIS:\SslBindings\*"
+    New-Item -Path "IIS:\SslBindings\0.0.0.0!443" -Value $sslCert -Force | Out-Null
+}
+
+Function GrantUserAccess($path, $userAccess)
+{
+    foreach ($user in $userAccess)
+    {
+        $acl = Get-Acl $path
+        $ar = New-Object System.Security.AccessControl.FileSystemAccessRule($user, "ReadAndExecute", "Allow")
+        $acl.SetAccessRule($ar)
+        Set-Acl $path $acl
+    }
+}
+
+Function InstallServerCode
+{
+    Write-Host -ForegroundColor Cyan "Acquiring server code."
+    DownloadServerCode
+    
+    Write-Host -ForegroundColor Cyan "Installing applications."
+
+    foreach ($app in $script:webApps)
+    {
+        Write-Host -ForegroundColor DarkGray "`tInstalling webApp: $($app.Name)"
+        
+        $appPath = Join-Path $script:iisWwwRoot $app.IISRelativePath
+
+        if ($(Get-WebApplication $app.Name) -ne $null)
+        {
+            Write-Host "`tRemoving $($app.Name)"
+            Remove-WebApplication -Site $script:defaultWebSite -Name $app.Name
+            Remove-Item ($appPath + "\*") -Recurse -Force -ErrorAction SilentlyContinue
+        }
+
+        Write-Host "`tAdding $($app.Name)"
+
+        $tempPath = Join-Path $script:serverCodeRootPath $app.SourceRelativePath
+        mkdir $appPath -ErrorAction SilentlyContinue | Out-Null
+        Copy-Item ($tempPath + "\*") $appPath -Recurse -ErrorAction Stop
+        
+        New-WebApplication -Site $script:defaultWebSite -Name $app.Name -PhysicalPath $appPath | Out-Null
+
+        foreach ($config in $app.Configuration)
+        {
+            Set-WebConfigurationProperty -Filter $config.Path -Name $config.Name -Value $config.Value -PSPath IIS:\ -location "$($script:defaultWebSite)/$($app.Name)" -ErrorAction Stop
+        }
+
+        GrantUserAccess $appPath $app.UserAccess
+    }
+    
+    Write-Host "Removing temporary files."
+    DeleteTemporaryFiles
+}
+
+Function RemoveServerCode
+{
+    Write-Host -ForegroundColor Cyan "Removing server code."
+    foreach ($app in $script:webApps)
+    {
+        Write-Host -ForegroundColor DarkGray "`tRemoving webApp files: $($app.Name)"
+        $appPath = Join-Path $script:iisWwwRoot $app.IISRelativePath
+        rmdir -Recurse -Force $appPath -ErrorAction SilentlyContinue
+    }
+}
+
+Function Install
+{
+    Write-Host -ForegroundColor Cyan "Installing prerequisites for test role: $($script:COREFX_ROLE_NAME)"
+    CheckMachineInfo
+
+    InstallIIS
+    InstallServerCertificates
+    CreateLocalUser
+    ConfigureWebSites
+    InstallServerCode
+    InstallServerFirewall
+
+    EnvironmentSetInstalledRoleStatus
+    # TODO:
+    # - Grant AD user permissions for all auth methods and sites.
+}
+
+Function Uninstall
+{
+    Write-Host -ForegroundColor Cyan "Removing prerequisites for test role: $($script:COREFX_ROLE_NAME)"
+
+    EnvironmentCheckUninstallRoleStatus
+
+    RemoveServerFirewall
+    RemoveIIS
+    RemoveServerCertificates
+    RemoveLocalUser
+    RemoveServerCode
+    
+    EnvironmentRemoveRoleStatus
+}
+
+if ($uninstall)
+{
+    Uninstall
+}
+else
+{
+    Install
+}
index 49cf192..58b5af9 100644 (file)
@@ -24,12 +24,12 @@ namespace System.Net.Test.Common
 
         public static bool IsDomainAvailable()
         {
-            return !string.IsNullOrWhiteSpace(Configuration.ActiveDirectoryName);
+            return !string.IsNullOrWhiteSpace(Configuration.Security.ActiveDirectoryName);
         }
 
         public static bool IsNegotiateServerAvailable()
         {
-            return !(Configuration.NegotiateServer == null);
+            return !(Configuration.Security.NegotiateServer == null);
         }
 
         private static bool InitializeTrustedRootCertificateCapability()
diff --git a/src/libraries/Common/tests/System/Net/CertificateConfiguration.cs b/src/libraries/Common/tests/System/Net/CertificateConfiguration.cs
deleted file mode 100644 (file)
index c2844a6..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-
-using Xunit;
-
-namespace System.Net.Tests
-{
-    internal static class CertificateConfiguration
-    {
-        private const string CertificatePassword = "testcertificate";
-        private const string TestDataFolder = "TestData";
-
-        public static X509Certificate2 GetServerCertificate() => GetCertWithPrivateKey(GetServerCertificateCollection());
-
-        public static X509Certificate2 GetClientCertificate() => GetCertWithPrivateKey(GetClientCertificateCollection());
-
-        public static X509Certificate2Collection GetServerCertificateCollection() => GetCertificateCollection("contoso.com.pfx");
-
-        public static X509Certificate2Collection GetClientCertificateCollection() => GetCertificateCollection("testclient1_at_contoso.com.pfx");
-
-        private static X509Certificate2Collection GetCertificateCollection(string certificateFileName)
-        {
-            var certCollection = new X509Certificate2Collection();
-            certCollection.Import(Path.Combine(TestDataFolder, certificateFileName), CertificatePassword, X509KeyStorageFlags.DefaultKeySet);
-            return certCollection;
-        }
-
-        private static X509Certificate2 GetCertWithPrivateKey(X509Certificate2Collection certCollection)
-        {
-            X509Certificate2 certificate = null;
-
-            foreach (X509Certificate2 c in certCollection)
-            {
-                if (certificate == null && c.HasPrivateKey)
-                {
-                    certificate = c;
-                }
-                else
-                {
-                    c.Dispose();
-                }
-            }
-
-            Assert.NotNull(certificate);
-            return certificate;
-        }
-    }
-}
diff --git a/src/libraries/Common/tests/System/Net/Configuration.Certificates.cs b/src/libraries/Common/tests/System/Net/Configuration.Certificates.cs
new file mode 100644 (file)
index 0000000..85c9781
--- /dev/null
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
+
+using Xunit;
+
+namespace System.Net.Test.Common
+{
+    public static partial class Configuration
+    {
+        public static partial class Certificates
+        {
+            private const string CertificatePassword = "testcertificate";
+            private const string TestDataFolder = "TestData";
+
+            public static X509Certificate2 GetServerCertificate() => GetCertWithPrivateKey(GetServerCertificateCollection());
+
+            public static X509Certificate2 GetClientCertificate() => GetCertWithPrivateKey(GetClientCertificateCollection());
+
+            public static X509Certificate2Collection GetServerCertificateCollection() => GetCertificateCollection("contoso.com.pfx");
+
+            public static X509Certificate2Collection GetClientCertificateCollection() => GetCertificateCollection("testclient1_at_contoso.com.pfx");
+
+            private static X509Certificate2Collection GetCertificateCollection(string certificateFileName)
+            {
+                var certCollection = new X509Certificate2Collection();
+                certCollection.Import(Path.Combine(TestDataFolder, certificateFileName), CertificatePassword, X509KeyStorageFlags.DefaultKeySet);
+                return certCollection;
+            }
+
+            private static X509Certificate2 GetCertWithPrivateKey(X509Certificate2Collection certCollection)
+            {
+                X509Certificate2 certificate = null;
+
+                foreach (X509Certificate2 c in certCollection)
+                {
+                    if (certificate == null && c.HasPrivateKey)
+                    {
+                        certificate = c;
+                    }
+                    else
+                    {
+                        c.Dispose();
+                    }
+                }
+
+                Assert.NotNull(certificate);
+                return certificate;
+            }
+        }
+    }
+}
diff --git a/src/libraries/Common/tests/System/Net/Configuration.Http.cs b/src/libraries/Common/tests/System/Net/Configuration.Http.cs
new file mode 100644 (file)
index 0000000..b7005ad
--- /dev/null
@@ -0,0 +1,151 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Net.Test.Common
+{
+    public static partial class Configuration
+    {
+        public static partial class Http
+        {
+            private readonly static string DefaultAzureServer = "corefx-net.cloudapp.net";  
+
+            public static string Host => GetValue("COREFX_HTTPHOST", DefaultAzureServer);
+
+            public static string SecureHost => GetValue("COREFX_SECUREHTTPHOST", DefaultAzureServer);
+
+            public static string Http2Host => GetValue("COREFX_HTTP2HOST", "http2.akamai.com");
+
+            public static string DomainJoinedHttpHost => GetValue("COREFX_DOMAINJOINED_HTTPHOST");
+
+            public static string DomainJoinedProxyHost => GetValue("COREFX_DOMAINJOINED_PROXYHOST");
+
+            public static string DomainJoinedProxyPort => GetValue("COREFX_DOMAINJOINED_PROXYPORT");
+
+            public static bool StressEnabled => GetValue("COREFX_STRESS_HTTP", "0") == "1";
+
+            public static string SSLv2RemoteServer => GetValue("COREFX_HTTPHOST_SSL2", "https://www.ssllabs.com:10200/");
+            public static string SSLv3RemoteServer => GetValue("COREFX_HTTPHOST_SSL3", "https://www.ssllabs.com:10300/");
+            public static string TLSv10RemoteServer => GetValue("COREFX_HTTPHOST_TLS10", "https://www.ssllabs.com:10301/");
+            public static string TLSv11RemoteServer => GetValue("COREFX_HTTPHOST_TLS11", "https://www.ssllabs.com:10302/");
+            public static string TLSv12RemoteServer => GetValue("COREFX_HTTPHOST_TLS12", "https://www.ssllabs.com:10303/");
+
+            public static string ExpiredCertRemoteServer => GetValue("COREFX_HTTPHOST_EXPIREDCERT", "https://expired.badssl.com/");
+            public static string WrongHostNameCertRemoteServer => GetValue("COREFX_HTTPHOST_WRONGHOSTNAME", "https://wrong.host.badssl.com/");
+            public static string SelfSignedCertRemoteServer => GetValue("COREFX_HTTPHOST_SELFSIGNEDCERT", "https://self-signed.badssl.com/");
+            public static string RevokedCertRemoteServer => GetValue("COREFX_HTTPHOST_REVOKEDCERT", "https://revoked.grc.com/");
+
+            private const string HttpScheme = "http";
+            private const string HttpsScheme = "https";
+
+            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";
+            private const string GZipHandler = "GZip.ashx";
+
+            public readonly static Uri RemoteEchoServer = new Uri("http://" + Host + "/" + EchoHandler);
+            public readonly static Uri SecureRemoteEchoServer = new Uri("https://" + SecureHost + "/" + EchoHandler);
+
+            public readonly static Uri RemoteVerifyUploadServer = new Uri("http://" + Host + "/" + VerifyUploadHandler);
+            public readonly static Uri SecureRemoteVerifyUploadServer = new Uri("https://" + SecureHost + "/" + VerifyUploadHandler);
+
+            public readonly static Uri RemoteEmptyContentServer = new Uri("http://" + Host + "/" + EmptyContentHandler);
+            public readonly static Uri RemoteDeflateServer = new Uri("http://" + Host + "/" + DeflateHandler);
+            public readonly static Uri RemoteGZipServer = new Uri("http://" + Host + "/" + GZipHandler);
+
+            public readonly static object[][] EchoServers = { new object[] { RemoteEchoServer }, new object[] { SecureRemoteEchoServer } };
+            public readonly static object[][] VerifyUploadServers = { new object[] { RemoteVerifyUploadServer }, new object[] { SecureRemoteVerifyUploadServer } };
+            public readonly static object[][] CompressedServers = { new object[] { RemoteDeflateServer }, new object[] { RemoteGZipServer } };
+            public readonly static object[][] Http2Servers = { new object[] { new Uri("https://" + Http2Host) } };
+
+            public static Uri NegotiateAuthUriForDefaultCreds(bool secure)
+            {
+                return new Uri(
+                    string.Format(
+                        "{0}://{1}/{2}?auth=negotiate",
+                        secure ? HttpsScheme : HttpScheme,
+                        Host,
+                        EchoHandler));
+            }
+
+            public static Uri BasicAuthUriForCreds(bool secure, string userName, string password)
+            {
+                return new Uri(
+                    string.Format(
+                        "{0}://{1}/{2}?auth=basic&user={3}&password={4}",
+                        secure ? HttpsScheme : HttpScheme,
+                        Host,
+                        EchoHandler,
+                        userName,
+                        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;
+                string destination = Uri.EscapeDataString(relative ? destinationUri.PathAndQuery : destinationUri.AbsoluteUri);
+
+                if (hops > 1)
+                {
+                    uriString = string.Format("{0}://{1}/{2}?statuscode={3}&uri={4}&hops={5}",
+                        secure ? HttpsScheme : HttpScheme,
+                        Host,
+                        RedirectHandler,
+                        statusCode,
+                        destination,
+                        hops);
+                }
+                else
+                {
+                    uriString = string.Format("{0}://{1}/{2}?statuscode={3}&uri={4}",
+                        secure ? HttpsScheme : HttpScheme,
+                        Host,
+                        RedirectHandler,
+                        statusCode,
+                        destination);
+                }
+                
+                return new Uri(uriString);
+            }
+
+            public static Uri RedirectUriForCreds(bool secure, int statusCode, string userName, string password)
+            {
+                Uri destinationUri = BasicAuthUriForCreds(secure, userName, password);
+                string destination = Uri.EscapeDataString(destinationUri.AbsoluteUri);
+                
+                return new Uri(string.Format("{0}://{1}/{2}?statuscode={3}&uri={4}",
+                    secure ? HttpsScheme : HttpScheme,
+                    Host,
+                    RedirectHandler,
+                    statusCode,
+                    destination));
+            }            
+        }
+    }
+}
index 0a039c9..006ac43 100644 (file)
@@ -2,18 +2,23 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System.Text;
-
 namespace System.Net.Test.Common
 {
     public static partial class Configuration
     {
-        public static string ActiveDirectoryName => GetValue("COREFX_NET_AD_DOMAINNAME");
+        public static partial class Security
+        {
+            private readonly static string DefaultAzureServer = "corefx-net.cloudapp.net";
+
+            public static string ActiveDirectoryName => GetValue("COREFX_NET_AD_DOMAINNAME");
+
+            public static string ActiveDirectoryUserName => GetValue("COREFX_NET_AD_USERNAME");
 
-        public static string ActiveDirectoryUserName => GetValue("COREFX_NET_AD_USERNAME");
+            public static string ActiveDirectoryUserPassword => GetValue("COREFX_NET_AD_PASSWORD");
 
-        public static string ActiveDirectoryUserPassword => GetValue("COREFX_NET_AD_PASSWORD");
+            public static Uri TlsServer => GetUriValue("COREFX_NET_SECURITY_TLSSERVERURI", new Uri("https://" + DefaultAzureServer));
 
-        public static Uri NegotiateServer => GetUriValue("COREFX_NET_NEGO_SERVER");
+            public static Uri NegotiateServer => GetUriValue("COREFX_NET_SECURITY_NEGOSERVERURI");
+        }
     }
 }
diff --git a/src/libraries/Common/tests/System/Net/Configuration.Sockets.cs b/src/libraries/Common/tests/System/Net/Configuration.Sockets.cs
new file mode 100644 (file)
index 0000000..4293000
--- /dev/null
@@ -0,0 +1,16 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Net.Sockets;
+
+namespace System.Net.Test.Common
+{
+    public static partial class Configuration
+    {
+        public static partial class Sockets
+        {
+           public static Uri SocketServer => GetUriValue("COREFX_NET_SOCKETS_SERVERURI", new Uri("http://" + DefaultAzureServer));
+        }
+    }
+}
diff --git a/src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs b/src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs
new file mode 100644 (file)
index 0000000..1c1db58
--- /dev/null
@@ -0,0 +1,28 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Net.Test.Common
+{
+    public static partial class Configuration
+    {
+        public static partial class WebSockets
+        {
+            public static string Host => GetValue("COREFX_WEBSOCKETHOST", DefaultAzureServer);
+
+            public static string SecureHost => GetValue("COREFX_SECUREWEBSOCKETHOST", DefaultAzureServer);
+
+            private const string EchoHandler = "WebSocket/EchoWebSocket.ashx";
+            private const string EchoHeadersHandler = "WebSocket/EchoWebSocketHeaders.ashx";
+
+            public readonly static Uri RemoteEchoServer = new Uri("ws://" + Host + "/" + EchoHandler);
+            public readonly static Uri SecureRemoteEchoServer = new Uri("wss://" + SecureHost + "/" + EchoHandler);
+
+            public readonly static Uri RemoteEchoHeadersServer = new Uri("ws://" + Host + "/" + EchoHeadersHandler);
+            public readonly static Uri SecureRemoteEchoHeadersServer = new Uri("wss://" + SecureHost + "/" + EchoHeadersHandler);
+            
+            public readonly static object[][] EchoServers = { new object[] { RemoteEchoServer }, new object[] { SecureRemoteEchoServer } };
+            public readonly static object[][] EchoHeadersServers = { new object[] { RemoteEchoHeadersServer }, new object[] { SecureRemoteEchoHeadersServer } };
+        }
+    }
+}
index 022608c..e6b87f2 100644 (file)
@@ -2,11 +2,14 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-
 namespace System.Net.Test.Common
 {
     public static partial class Configuration
     {
+        #pragma warning disable 414
+        private readonly static string DefaultAzureServer = "corefx-net.cloudapp.net";
+        #pragma warning restore 414
+
         private static string GetValue(string envName, string defaultValue=null)
         {
             string envValue = Environment.GetEnvironmentVariable(envName);
index abb21de..976a5ca 100644 (file)
@@ -8,7 +8,6 @@ using System.Net.Http;
 using System.Net.NetworkInformation;
 using System.Net.Security;
 using System.Net.Sockets;
-using System.Net.Tests;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
 using System.Text;
@@ -95,7 +94,7 @@ namespace System.Net.Test.Common
                 if (options.UseSsl)
                 {
                     var sslStream = new SslStream(stream, false, delegate { return true; });
-                    using (var cert = CertificateConfiguration.GetServerCertificate())
+                    using (var cert = Configuration.Certificates.GetServerCertificate())
                     {
                         await sslStream.AuthenticateAsServerAsync(
                             cert, 
diff --git a/src/libraries/Common/tests/System/Net/HttpTestServers.cs b/src/libraries/Common/tests/System/Net/HttpTestServers.cs
deleted file mode 100644 (file)
index 73831aa..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Net.Test.Common
-{
-    internal class HttpTestServers
-    {
-        public readonly static string Host = TestSettings.Http.Host;
-        public readonly static string SecureHost = TestSettings.Http.SecureHost;
-        public readonly static string Http2Host = TestSettings.Http.Http2Host;
-
-        public const string SSLv2RemoteServer = "https://www.ssllabs.com:10200/";
-        public const string SSLv3RemoteServer = "https://www.ssllabs.com:10300/";
-        public const string TLSv10RemoteServer = "https://www.ssllabs.com:10301/";
-        public const string TLSv11RemoteServer = "https://www.ssllabs.com:10302/";
-        public const string TLSv12RemoteServer = "https://www.ssllabs.com:10303/";
-
-        public const string ExpiredCertRemoteServer = "https://expired.badssl.com/";
-        public const string WrongHostNameCertRemoteServer = "https://wrong.host.badssl.com/";
-        public const string SelfSignedCertRemoteServer = "https://self-signed.badssl.com/";
-        public const string RevokedCertRemoteServer = "https://revoked.grc.com/";
-
-        private const string HttpScheme = "http";
-        private const string HttpsScheme = "https";
-
-        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";
-        private const string GZipHandler = "GZip.ashx";
-
-        public readonly static Uri RemoteEchoServer = new Uri("http://" + Host + "/" + EchoHandler);
-        public readonly static Uri SecureRemoteEchoServer = new Uri("https://" + SecureHost + "/" + EchoHandler);
-
-        public readonly static Uri RemoteVerifyUploadServer = new Uri("http://" + Host + "/" + VerifyUploadHandler);
-        public readonly static Uri SecureRemoteVerifyUploadServer = new Uri("https://" + SecureHost + "/" + VerifyUploadHandler);
-
-        public readonly static Uri RemoteEmptyContentServer = new Uri("http://" + Host + "/" + EmptyContentHandler);
-        public readonly static Uri RemoteDeflateServer = new Uri("http://" + Host + "/" + DeflateHandler);
-        public readonly static Uri RemoteGZipServer = new Uri("http://" + Host + "/" + GZipHandler);
-
-        public readonly static object[][] EchoServers = { new object[] { RemoteEchoServer }, new object[] { SecureRemoteEchoServer } };
-        public readonly static object[][] VerifyUploadServers = { new object[] { RemoteVerifyUploadServer }, new object[] { SecureRemoteVerifyUploadServer } };
-        public readonly static object[][] CompressedServers = { new object[] { RemoteDeflateServer }, new object[] { RemoteGZipServer } };
-        public readonly static object[][] Http2Servers = { new object[] { new Uri("https://" + Http2Host) } };
-
-        public static Uri NegotiateAuthUriForDefaultCreds(bool secure)
-        {
-            return new Uri(
-                string.Format(
-                    "{0}://{1}/{2}?auth=negotiate",
-                    secure ? HttpsScheme : HttpScheme,
-                    Host,
-                    EchoHandler));
-        }
-
-        public static Uri BasicAuthUriForCreds(bool secure, string userName, string password)
-        {
-            return new Uri(
-                string.Format(
-                    "{0}://{1}/{2}?auth=basic&user={3}&password={4}",
-                    secure ? HttpsScheme : HttpScheme,
-                    Host,
-                    EchoHandler,
-                    userName,
-                    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;
-            string destination = Uri.EscapeDataString(relative ? destinationUri.PathAndQuery : destinationUri.AbsoluteUri);
-
-            if (hops > 1)
-            {
-                uriString = string.Format("{0}://{1}/{2}?statuscode={3}&uri={4}&hops={5}",
-                    secure ? HttpsScheme : HttpScheme,
-                    Host,
-                    RedirectHandler,
-                    statusCode,
-                    destination,
-                    hops);
-            }
-            else
-            {
-                uriString = string.Format("{0}://{1}/{2}?statuscode={3}&uri={4}",
-                    secure ? HttpsScheme : HttpScheme,
-                    Host,
-                    RedirectHandler,
-                    statusCode,
-                    destination);
-            }
-            
-            return new Uri(uriString);
-        }
-
-        public static Uri RedirectUriForCreds(bool secure, int statusCode, string userName, string password)
-        {
-            Uri destinationUri = BasicAuthUriForCreds(secure, userName, password);
-            string destination = Uri.EscapeDataString(destinationUri.AbsoluteUri);
-            
-            return new Uri(string.Format("{0}://{1}/{2}?statuscode={3}&uri={4}",
-                secure ? HttpsScheme : HttpScheme,
-                Host,
-                RedirectHandler,
-                statusCode,
-                destination));
-        }
-    }
-}
index cb7c00a..551e9f3 100644 (file)
@@ -139,7 +139,7 @@ namespace System.Net.Sockets.Tests
             }
 
             _log.WriteLine(this.GetHashCode() + " StartAccept(_numConnectedSockets={0})", _numConnectedSockets);
-            Assert.True(_maxNumberAcceptedClientsSemaphore.WaitOne(Configuration.PassingTestTimeout), "Timeout waiting for client connection.");
+            Assert.True(_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestTimeout), "Timeout waiting for client connection.");
 
             if (_listenSocket == null)
             {
@@ -2,11 +2,9 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System.Net.Sockets;
-
 namespace System.Net.Sockets.Tests
 {
-    public static class Configuration
+    public static class TestSettings
     {
         // Timeout values in milliseconds.
         public const int PassingTestTimeout = 5000;
diff --git a/src/libraries/Common/tests/System/Net/TestSettings.cs b/src/libraries/Common/tests/System/Net/TestSettings.cs
deleted file mode 100644 (file)
index a43e062..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Net.Test.Common
-{
-    internal static class TestSettings
-    {
-        public static class Http
-        {
-            public static string Host
-            {
-                get
-                {
-                    string server = Environment.GetEnvironmentVariable("COREFX_HTTPHOST");
-                    if (string.IsNullOrEmpty(server))
-                    {
-                        return "corefx-net.cloudapp.net";
-                    }
-                    else
-                    {
-                        return server;
-                    }
-                }
-            }
-
-            public static string SecureHost
-            {
-                get
-                {
-                    string server = Environment.GetEnvironmentVariable("COREFX_SECUREHTTPHOST");
-                    if (string.IsNullOrEmpty(server))
-                    {
-                        return "corefx-net.cloudapp.net";
-                    }
-                    else
-                    {
-                        return server;
-                    }
-                }
-            }
-
-            public static string Http2Host
-            {
-                get
-                {
-                    string server = Environment.GetEnvironmentVariable("COREFX_HTTP2HOST");
-                    if (string.IsNullOrEmpty(server))
-                    {
-                        return "http2.akamai.com";
-                    }
-                    else
-                    {
-                        return server;
-                    }
-                }
-            }
-
-            public static string DomainJoinedHttpHost => Environment.GetEnvironmentVariable("COREFX_DOMAINJOINED_HTTPHOST");
-            public static string DomainJoinedProxyHost => Environment.GetEnvironmentVariable("COREFX_DOMAINJOINED_PROXYHOST");
-            public static string DomainJoinedProxyPort => Environment.GetEnvironmentVariable("COREFX_DOMAINJOINED_PROXYPORT");
-
-            public static bool StressEnabled => Environment.GetEnvironmentVariable("COREFX_STRESS_HTTP") == "1";
-        }
-
-        public static class WebSocket
-        {
-            public static string Host
-            {
-                get
-                {
-                    string server = Environment.GetEnvironmentVariable("COREFX_WEBSOCKETHOST");
-                    if (string.IsNullOrEmpty(server))
-                    {
-                        return "corefx-net.cloudapp.net";
-                    }
-                    else
-                    {
-                        return server;
-                    }
-                }
-            }
-
-            public static string SecureHost
-            {
-                get
-                {
-                    string server = Environment.GetEnvironmentVariable("COREFX_SECUREWEBSOCKETHOST");
-                    if (string.IsNullOrEmpty(server))
-                    {
-                        return "corefx-net.cloudapp.net";
-                    }
-                    else
-                    {
-                        return server;
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/src/libraries/Common/tests/System/Net/WebSocketTestServers.cs b/src/libraries/Common/tests/System/Net/WebSocketTestServers.cs
deleted file mode 100644 (file)
index c6385f9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Net.Test.Common
-{
-    internal class WebSocketTestServers
-    {
-        public readonly static string Host = TestSettings.WebSocket.Host;
-        public readonly static string SecureHost = TestSettings.WebSocket.SecureHost;
-
-        private const string EchoHandler = "WebSocket/EchoWebSocket.ashx";
-        private const string EchoHeadersHandler = "WebSocket/EchoWebSocketHeaders.ashx";
-
-        public readonly static Uri RemoteEchoServer = new Uri("ws://" + Host + "/" + EchoHandler);
-        public readonly static Uri SecureRemoteEchoServer = new Uri("wss://" + SecureHost + "/" + EchoHandler);
-
-        public readonly static Uri RemoteEchoHeadersServer = new Uri("ws://" + Host + "/" + EchoHeadersHandler);
-        public readonly static Uri SecureRemoteEchoHeadersServer = new Uri("wss://" + SecureHost + "/" + EchoHeadersHandler);
-        
-        public readonly static object[][] EchoServers = { new object[] { RemoteEchoServer }, new object[] { SecureRemoteEchoServer } };
-        public readonly static object[][] EchoHeadersServers = { new object[] { RemoteEchoHeadersServer }, new object[] { SecureRemoteEchoHeadersServer } };
-    }
-}
index f714f42..c56a89c 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             var handler = new WinHttpHandler();
             using (var client = new HttpClient(handler))
             {
-                HttpResponseMessage response = await client.GetAsync(HttpTestServers.SecureRemoteEchoServer);
+                HttpResponseMessage response = await client.GetAsync(Configuration.Http.SecureRemoteEchoServer);
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 Assert.False(_validationCallbackHistory.WasCalled);
             }
@@ -47,7 +47,7 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
             using (var client = new HttpClient(handler))
             {
-                HttpResponseMessage response = await client.GetAsync(HttpTestServers.RemoteEchoServer);
+                HttpResponseMessage response = await client.GetAsync(Configuration.Http.RemoteEchoServer);
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 Assert.False(_validationCallbackHistory.WasCalled);
             }
@@ -60,18 +60,18 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
             using (var client = new HttpClient(handler))
             {
-                HttpResponseMessage response = await client.GetAsync(HttpTestServers.SecureRemoteEchoServer);
+                HttpResponseMessage response = await client.GetAsync(Configuration.Http.SecureRemoteEchoServer);
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 Assert.True(_validationCallbackHistory.WasCalled);
                 
-                ConfirmValidCertificate(HttpTestServers.Host);
+                ConfirmValidCertificate(Configuration.Http.Host);
             }
         }
 
         [Fact]
         public async Task UseCallback_RedirectandValidCertificate_ExpectedValuesDuringCallback()
         {
-            Uri uri = HttpTestServers.RedirectUriForDestinationUri(true, 302, HttpTestServers.SecureRemoteEchoServer, 1);
+            Uri uri = Configuration.Http.RedirectUriForDestinationUri(true, 302, Configuration.Http.SecureRemoteEchoServer, 1);
 
             var handler = new WinHttpHandler();
             handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
@@ -81,7 +81,7 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 Assert.True(_validationCallbackHistory.WasCalled);
                 
-                ConfirmValidCertificate(HttpTestServers.Host);
+                ConfirmValidCertificate(Configuration.Http.Host);
             }
         }
 
@@ -94,10 +94,10 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback;
             using (var client = new HttpClient(handler))
             {
-                var request = new HttpRequestMessage(HttpMethod.Get, HttpTestServers.SecureRemoteEchoServer);
+                var request = new HttpRequestMessage(HttpMethod.Get, Configuration.Http.SecureRemoteEchoServer);
                 _validationCallbackHistory.ReturnFailure = true;
                 HttpRequestException ex = await Assert.ThrowsAsync<HttpRequestException>(() =>
-                    client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                    client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
                 var innerEx = (Win32Exception)ex.InnerException;
                 Assert.Equal(ERROR_WINHTTP_SECURE_FAILURE, innerEx.NativeErrorCode);
             }
@@ -111,7 +111,7 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             using (var client = new HttpClient(handler))
             {
                 _validationCallbackHistory.ThrowException = true;
-                await Assert.ThrowsAsync<CustomException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                await Assert.ThrowsAsync<CustomException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
             }
         }
 
index ea3dbe0..c5a4737 100644 (file)
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Windows_Debug|AnyCPU'" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Windows_Release|AnyCPU'" />
   <ItemGroup Condition=" '$(TargetsWindows)' == 'true' ">
-    <Compile Include="$(CommonTestPath)\System\Net\HttpTestServers.cs">
-      <Link>Common\System\Net\HttpTestServers.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
+      <Link>Common\System\Net\Configuration.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Http.cs">
+      <Link>Common\System\Net\Configuration.Http.cs</Link>
     </Compile>
     <Compile Include="ServerCertificateTest.cs" />
     <Compile Include="WinHttpHandlerTest.cs" />
index 912b0ca..a53248d 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             using (var client = new HttpClient(handler))
             {
                 // TODO: This is a placeholder until GitHub Issue #2383 gets resolved.
-                var response = client.GetAsync(HttpTestServers.RemoteEchoServer).Result;
+                var response = client.GetAsync(Configuration.Http.RemoteEchoServer).Result;
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 var responseContent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                 _output.WriteLine(responseContent);
@@ -52,7 +52,7 @@ namespace System.Net.Http.WinHttpHandlerFunctional.Tests
             string cookieName,
             string cookieValue)
         {
-            Uri uri = HttpTestServers.RedirectUriForDestinationUri(false, 302, HttpTestServers.RemoteEchoServer, 1);
+            Uri uri = Configuration.Http.RedirectUriForDestinationUri(false, 302, Configuration.Http.RemoteEchoServer, 1);
             var handler = new WinHttpHandler();
             handler.WindowsProxyUsePolicy = WindowsProxyUsePolicy.UseWinInetProxy;
             handler.CookieUsePolicy = cookieUsePolicy;
index e83a213..4a058ab 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Net.Http.Functional.Tests
     // TODO: #2383 - Consolidate the use of the environment variable settings to Common/tests.
     public class DefaultCredentialsTest
     {
-        private static string DomainJoinedTestServer => TestSettings.Http.DomainJoinedHttpHost;
+        private static string DomainJoinedTestServer => Configuration.Http.DomainJoinedHttpHost;
         private static bool DomainJoinedTestsEnabled => !string.IsNullOrEmpty(DomainJoinedTestServer);
         private static string SpecificUserName = "test";
         private static string SpecificPassword = "Password1";
@@ -156,7 +156,7 @@ namespace System.Net.Http.Functional.Tests
             handler.Proxy = new AuthenticatedProxy(null);
 
             using (var client = new HttpClient(handler))
-            using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+            using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.RemoteEchoServer))
             {
                 Assert.Equal(HttpStatusCode.ProxyAuthenticationRequired, response.StatusCode);
             }
@@ -169,7 +169,7 @@ namespace System.Net.Http.Functional.Tests
             handler.Proxy = new AuthenticatedProxy(CredentialCache.DefaultCredentials);
 
             using (var client = new HttpClient(handler))
-            using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+            using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.RemoteEchoServer))
             {
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             }
@@ -187,7 +187,7 @@ namespace System.Net.Http.Functional.Tests
             handler.Proxy = new AuthenticatedProxy(wrappedCreds);
 
             using (var client = new HttpClient(handler))
-            using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+            using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.RemoteEchoServer))
             {
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             }
@@ -234,10 +234,10 @@ namespace System.Net.Http.Functional.Tests
             {
                 _credentials = credentials;
 
-                string host = TestSettings.Http.DomainJoinedProxyHost;
+                string host = Configuration.Http.DomainJoinedProxyHost;
                 Assert.False(string.IsNullOrEmpty(host), "TestSettings.Http.DomainJoinedProxyHost must specify proxy hostname");
 
-                string portString = TestSettings.Http.DomainJoinedProxyPort;
+                string portString = Configuration.Http.DomainJoinedProxyPort;
                 Assert.False(string.IsNullOrEmpty(portString), "TestSettings.Http.DomainJoinedProxyPort must specify proxy port number");
 
                 int port;
index 08858d7..5d22b1e 100644 (file)
@@ -61,7 +61,7 @@ namespace System.Net.Http.Functional.Tests
                     diagnosticListenerObserver.Enable();
                     using (var client = new HttpClient())
                     {
-                        var response = client.GetAsync(HttpTestServers.RemoteEchoServer).Result;
+                        var response = client.GetAsync(Configuration.Http.RemoteEchoServer).Result;
                     }
 
                     Assert.True(requestLogged, "Request was not logged.");
@@ -103,7 +103,7 @@ namespace System.Net.Http.Functional.Tests
                 {
                     using (var client = new HttpClient())
                     {
-                        var response = client.GetAsync(HttpTestServers.RemoteEchoServer).Result;
+                        var response = client.GetAsync(Configuration.Http.RemoteEchoServer).Result;
                     }
 
                     Assert.False(requestLogged, "Request was logged while logging disabled.");
@@ -138,7 +138,7 @@ namespace System.Net.Http.Functional.Tests
                             byte[] expectedData = Enumerable.Range(0, 20000).Select(i => (byte)i).ToArray();
                             HttpContent content = new ByteArrayContent(expectedData);
                             content.Headers.ContentMD5 = TestHelper.ComputeMD5Hash(expectedData);
-                            using (HttpResponseMessage response = await client.PostAsync(HttpTestServers.RemoteEchoServer, content))
+                            using (HttpResponseMessage response = await client.PostAsync(Configuration.Http.RemoteEchoServer, content))
                             {
                                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                             }
index db05e7b..792bc27 100644 (file)
@@ -5,7 +5,6 @@
 using System.Net.Security;
 using System.Net.Sockets;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Runtime.InteropServices;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading.Tasks;
@@ -52,7 +51,7 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient(new HttpClientHandler() { ClientCertificateOptions = ClientCertificateOption.Automatic }))
             {
-                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
             }
         }
 
@@ -60,10 +59,10 @@ namespace System.Net.Http.Functional.Tests
         public async Task Manual_SSLBackendNotSupported_ThrowsPlatformNotSupportedException()
         {
             var handler = new HttpClientHandler();
-            handler.ClientCertificates.Add(CertificateConfiguration.GetClientCertificate());
+            handler.ClientCertificates.Add(Configuration.Certificates.GetClientCertificate());
             using (var client = new HttpClient(handler))
             {
-                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
             }
         }
 
@@ -76,7 +75,7 @@ namespace System.Net.Http.Functional.Tests
             bool reuseClient) // validate behavior with and without connection pooling, which impacts client cert usage
         {
             var options = new LoopbackServer.Options { UseSsl = true };
-            using (X509Certificate2 cert = CertificateConfiguration.GetClientCertificate())
+            using (X509Certificate2 cert = Configuration.Certificates.GetClientCertificate())
             {
                 Func<HttpClient> createClient = () =>
                 {
index 8e446e4..3bf8d88 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Net.Http.Functional.Tests
                 handler.Proxy = new UseSpecifiedUriWebProxy(proxyUrl, rightCreds);
                 handler.DefaultProxyCredentials = wrongCreds;
 
-                Task<HttpResponseMessage> responseTask = client.GetAsync(HttpTestServers.RemoteEchoServer);
+                Task<HttpResponseMessage> responseTask = client.GetAsync(Configuration.Http.RemoteEchoServer);
                 Task<string> responseStringTask = responseTask.ContinueWith(t => t.Result.Content.ReadAsStringAsync(), TaskScheduler.Default).Unwrap();
                 Task.WaitAll(proxyTask, responseTask, responseStringTask);
 
@@ -86,7 +86,7 @@ namespace System.Net.Http.Functional.Tests
                     var creds = new NetworkCredential(ExpectedUsername, ExpectedPassword);
                     handler.DefaultProxyCredentials = creds;
 
-                    Task<HttpResponseMessage> responseTask = client.GetAsync(HttpTestServers.RemoteEchoServer);
+                    Task<HttpResponseMessage> responseTask = client.GetAsync(Configuration.Http.RemoteEchoServer);
                     Task<string> responseStringTask = responseTask.ContinueWith(t => t.Result.Content.ReadAsStringAsync(), TaskScheduler.Default).Unwrap();
                     Task.WaitAll(responseTask, responseStringTask);
 
index 670f7cb..21a7709 100644 (file)
@@ -72,7 +72,7 @@ namespace System.Net.Http.Functional.Tests
 
                 await Task.WhenAll(
                     from i in Enumerable.Range(0, 5)
-                    select client.GetAsync(HttpTestServers.RemoteEchoServer));
+                    select client.GetAsync(Configuration.Http.RemoteEchoServer));
             }
         }
     }
index a928643..f144f07 100644 (file)
@@ -54,7 +54,7 @@ namespace System.Net.Http.Functional.Tests
             using (var client = new HttpClient(handler))
             {
                 handler.MaxResponseHeadersLength = int.MaxValue;
-                await client.GetStreamAsync(HttpTestServers.RemoteEchoServer);
+                await client.GetStreamAsync(Configuration.Http.RemoteEchoServer);
                 Assert.Throws<InvalidOperationException>(() => handler.MaxResponseHeadersLength = int.MaxValue);
             }
         }
index 7518d10..f69ed25 100644 (file)
@@ -24,7 +24,7 @@ namespace System.Net.Http.Functional.Tests
                 Assert.Null(handler.ServerCertificateCustomValidationCallback);
                 Assert.False(handler.CheckCertificateRevocationList);
 
-                using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.SecureRemoteEchoServer))
+                using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.SecureRemoteEchoServer))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 }
@@ -43,7 +43,7 @@ namespace System.Net.Http.Functional.Tests
                 bool callbackCalled = false;
                 handler.ServerCertificateCustomValidationCallback = delegate { callbackCalled = true; return true; };
 
-                using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+                using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.RemoteEchoServer))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                 }
@@ -56,12 +56,12 @@ namespace System.Net.Http.Functional.Tests
         {
             foreach (bool checkRevocation in new[] { true, false })
             {
-                yield return new object[] { HttpTestServers.SecureRemoteEchoServer, checkRevocation };
+                yield return new object[] { Configuration.Http.SecureRemoteEchoServer, checkRevocation };
                 yield return new object[] {
-                    HttpTestServers.RedirectUriForDestinationUri(
+                    Configuration.Http.RedirectUriForDestinationUri(
                         secure:true,
                         statusCode:302,
-                        destinationUri:HttpTestServers.SecureRemoteEchoServer,
+                        destinationUri:Configuration.Http.SecureRemoteEchoServer,
                         hops:1),
                     checkRevocation };
             }
@@ -102,7 +102,7 @@ namespace System.Net.Http.Functional.Tests
             using (var client = new HttpClient(handler))
             {
                 handler.ServerCertificateCustomValidationCallback = delegate { return false; };
-                await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
             }
         }
 
@@ -114,14 +114,19 @@ namespace System.Net.Http.Functional.Tests
             {
                 var e = new DivideByZeroException();
                 handler.ServerCertificateCustomValidationCallback = delegate { throw e; };
-                Assert.Same(e, await Assert.ThrowsAsync<DivideByZeroException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer)));
+                Assert.Same(e, await Assert.ThrowsAsync<DivideByZeroException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer)));
             }
         }
 
+        public readonly static object[][] CertificateValidationServers = 
+        {
+            new object[] { Configuration.Http.ExpiredCertRemoteServer },
+            new object[] { Configuration.Http.SelfSignedCertRemoteServer },
+            new object[] { Configuration.Http.WrongHostNameCertRemoteServer },
+        };
+
         [Theory]
-        [InlineData(HttpTestServers.ExpiredCertRemoteServer)]
-        [InlineData(HttpTestServers.SelfSignedCertRemoteServer)]
-        [InlineData(HttpTestServers.WrongHostNameCertRemoteServer)]
+        [MemberData(nameof(CertificateValidationServers))]
         public async Task NoCallback_BadCertificate_ThrowsException(string url)
         {
             using (var client = new HttpClient())
@@ -134,7 +139,7 @@ namespace System.Net.Http.Functional.Tests
         public async Task NoCallback_RevokedCertificate_NoRevocationChecking_Succeeds()
         {
             using (var client = new HttpClient())
-            using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.RevokedCertRemoteServer))
+            using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.RevokedCertRemoteServer))
             {
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             }
@@ -146,15 +151,20 @@ namespace System.Net.Http.Functional.Tests
             var handler = new HttpClientHandler() { CheckCertificateRevocationList = true };
             using (var client = new HttpClient(handler))
             {
-                await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(HttpTestServers.RevokedCertRemoteServer));
+                await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(Configuration.Http.RevokedCertRemoteServer));
             }
         }
 
+        public readonly static object[][] CertificateValidationServersAndExpectedPolicies =
+        {
+            new object[] { Configuration.Http.ExpiredCertRemoteServer, SslPolicyErrors.RemoteCertificateChainErrors },
+            new object[] { Configuration.Http.SelfSignedCertRemoteServer, SslPolicyErrors.RemoteCertificateChainErrors },
+            new object[] { Configuration.Http.WrongHostNameCertRemoteServer , SslPolicyErrors.RemoteCertificateNameMismatch},
+        };
+
         [ActiveIssue(7812, PlatformID.Windows)]
         [ConditionalTheory(nameof(BackendSupportsCustomCertificateHandling))]
-        [InlineData(HttpTestServers.ExpiredCertRemoteServer, SslPolicyErrors.RemoteCertificateChainErrors)]
-        [InlineData(HttpTestServers.SelfSignedCertRemoteServer, SslPolicyErrors.RemoteCertificateChainErrors)]
-        [InlineData(HttpTestServers.WrongHostNameCertRemoteServer, SslPolicyErrors.RemoteCertificateNameMismatch)]
+        [MemberData(nameof(CertificateValidationServersAndExpectedPolicies))]
         public async Task UseCallback_BadCertificate_ExpectedPolicyErrors(string url, SslPolicyErrors expectedErrors)
         {
             var handler = new HttpClientHandler();
@@ -186,7 +196,7 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient(new HttpClientHandler() { ServerCertificateCustomValidationCallback = delegate { return true; } }))
             {
-                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
             }
         }
 
@@ -195,7 +205,7 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient(new HttpClientHandler() { CheckCertificateRevocationList = true }))
             {
-                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(HttpTestServers.SecureRemoteEchoServer));
+                await Assert.ThrowsAsync<PlatformNotSupportedException>(() => client.GetAsync(Configuration.Http.SecureRemoteEchoServer));
             }
         }
 
@@ -205,7 +215,7 @@ namespace System.Net.Http.Functional.Tests
         {
             var content = new ChannelBindingAwareContent("Test contest");
             using (var client = new HttpClient())
-            using (HttpResponseMessage response = await client.PostAsync(HttpTestServers.SecureRemoteEchoServer, content))
+            using (HttpResponseMessage response = await client.PostAsync(Configuration.Http.SecureRemoteEchoServer, content))
             {
                 // Validate status.
                 Assert.Equal(HttpStatusCode.OK, response.StatusCode);
index 7d0984e..f29f05e 100644 (file)
@@ -101,15 +101,20 @@ namespace System.Net.Http.Functional.Tests
             }
         }
 
+        public readonly static object [][] SupportedSSLVersionServers =
+        {
+            new object[] {"TLSv1.0", Configuration.Http.TLSv10RemoteServer},
+            new object[] {"TLSv1.1", Configuration.Http.TLSv11RemoteServer},
+            new object[] {"TLSv1.2", Configuration.Http.TLSv12RemoteServer},
+        };
+
         // This test is logically the same as the above test, albeit using remote servers
         // instead of local ones.  We're keeping it for now (as outerloop) because it helps
         // to validate against another SSL implementation that what we mean by a particular
         // TLS version matches that other implementation.
         [OuterLoop] // avoid www.ssllabs.com dependency in innerloop
         [Theory]
-        [InlineData("TLSv1.0", HttpTestServers.TLSv10RemoteServer)]
-        [InlineData("TLSv1.1", HttpTestServers.TLSv11RemoteServer)]
-        [InlineData("TLSv1.2", HttpTestServers.TLSv12RemoteServer)]
+        [MemberData(nameof(SupportedSSLVersionServers))]
         public async Task GetAsync_SupportedSSLVersion_Succeeds(string name, string url)
         {
             using (var client = new HttpClient())
@@ -118,14 +123,19 @@ namespace System.Net.Http.Functional.Tests
             }
         }
 
+        public readonly static object[][] NotSupportedSSLVersionServers =
+        {
+            new object[] {"SSLv2", Configuration.Http.SSLv2RemoteServer},
+            new object[] {"SSLv3", Configuration.Http.SSLv3RemoteServer},
+        };
+
         // It would be easy to remove the dependency on these remote servers if we didn't
         // explicitly disallow creating SslStream with SSLv2/3.  Since we explicitly throw
         // when trying to use such an SslStream, we can't stand up a localhost server that
         // only speaks those protocols.
         [OuterLoop] // avoid www.ssllabs.com dependency in innerloop
         [Theory]
-        [InlineData("SSLv2", HttpTestServers.SSLv2RemoteServer)]
-        [InlineData("SSLv3", HttpTestServers.SSLv3RemoteServer)]
+        [MemberData(nameof(NotSupportedSSLVersionServers))]
         public async Task GetAsync_UnsupportedSSLVersion_Throws(string name, string url)
         {
             using (var client = new HttpClient())
index d0398ad..e23ed2f 100644 (file)
@@ -32,24 +32,24 @@ namespace System.Net.Http.Functional.Tests
 
         private readonly NetworkCredential _credential = new NetworkCredential(Username, Password);
 
-        public readonly static object[][] EchoServers = HttpTestServers.EchoServers;
-        public readonly static object[][] VerifyUploadServers = HttpTestServers.VerifyUploadServers;
-        public readonly static object[][] CompressedServers = HttpTestServers.CompressedServers;
+        public readonly static object[][] EchoServers = Configuration.Http.EchoServers;
+        public readonly static object[][] VerifyUploadServers = Configuration.Http.VerifyUploadServers;
+        public readonly static object[][] CompressedServers = Configuration.Http.CompressedServers;
         public readonly static object[][] HeaderValueAndUris = {
-            new object[] { "X-CustomHeader", "x-value", HttpTestServers.RemoteEchoServer },
-            new object[] { "X-Cust-Header-NoValue", "" , HttpTestServers.RemoteEchoServer },
-            new object[] { "X-CustomHeader", "x-value", HttpTestServers.RedirectUriForDestinationUri(
+            new object[] { "X-CustomHeader", "x-value", Configuration.Http.RemoteEchoServer },
+            new object[] { "X-Cust-Header-NoValue", "" , Configuration.Http.RemoteEchoServer },
+            new object[] { "X-CustomHeader", "x-value", Configuration.Http.RedirectUriForDestinationUri(
                 secure:false,
                 statusCode:302,
-                destinationUri:HttpTestServers.RemoteEchoServer,
+                destinationUri:Configuration.Http.RemoteEchoServer,
                 hops:1) },
-            new object[] { "X-Cust-Header-NoValue", "" , HttpTestServers.RedirectUriForDestinationUri(
+            new object[] { "X-Cust-Header-NoValue", "" , Configuration.Http.RedirectUriForDestinationUri(
                 secure:false,
                 statusCode:302,
-                destinationUri:HttpTestServers.RemoteEchoServer,
+                destinationUri:Configuration.Http.RemoteEchoServer,
                 hops:1) },
         };
-        public readonly static object[][] Http2Servers = HttpTestServers.Http2Servers;
+        public readonly static object[][] Http2Servers = Configuration.Http.Http2Servers;
 
         public readonly static object[][] RedirectStatusCodes = {
             new object[] { 300 },
@@ -141,7 +141,7 @@ namespace System.Net.Http.Functional.Tests
             handler.UseDefaultCredentials = false;
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.NegotiateAuthUriForDefaultCreds(secure:false);
+                Uri uri = Configuration.Http.NegotiateAuthUriForDefaultCreds(secure:false);
                 _output.WriteLine("Uri: {0}", uri);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
                 {
@@ -226,7 +226,7 @@ namespace System.Net.Http.Functional.Tests
                 HttpResponseMessage response;
                 for (int i = 0; i < 3; i++)
                 {
-                    response = await client.GetAsync(HttpTestServers.RemoteEchoServer);
+                    response = await client.GetAsync(Configuration.Http.RemoteEchoServer);
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                     response.Dispose();
                 }
@@ -240,7 +240,7 @@ namespace System.Net.Http.Functional.Tests
             using (var handler = new HttpClientHandler())
             using (var client = new HttpClient(handler))
             {
-                response = await client.GetAsync(HttpTestServers.SecureRemoteEchoServer);
+                response = await client.GetAsync(Configuration.Http.SecureRemoteEchoServer);
             }
             Assert.NotNull(response);
             string responseContent = await response.Content.ReadAsStringAsync();
@@ -259,7 +259,7 @@ namespace System.Net.Http.Functional.Tests
             cts.Cancel();
             using (var client = new HttpClient())
             {
-                var request = new HttpRequestMessage(HttpMethod.Post, HttpTestServers.RemoteEchoServer);
+                var request = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.RemoteEchoServer);
                 TaskCanceledException ex = await Assert.ThrowsAsync<TaskCanceledException>(() =>
                     client.SendAsync(request, cts.Token));
                 Assert.True(cts.Token.IsCancellationRequested, "cts token IsCancellationRequested");
@@ -306,7 +306,7 @@ namespace System.Net.Http.Functional.Tests
             handler.Credentials = _credential;
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
+                Uri uri = Configuration.Http.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@@ -319,7 +319,7 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient())
             {
-                Uri uri = HttpTestServers.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
+                Uri uri = Configuration.Http.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
                 {
                     Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
@@ -334,10 +334,10 @@ namespace System.Net.Http.Functional.Tests
             handler.AllowAutoRedirect = false;
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+                Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                     secure:false,
                     statusCode:statusCode,
-                    destinationUri:HttpTestServers.RemoteEchoServer,
+                    destinationUri:Configuration.Http.RemoteEchoServer,
                     hops:1);
                 _output.WriteLine("Uri: {0}", uri);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
@@ -355,16 +355,16 @@ namespace System.Net.Http.Functional.Tests
             handler.AllowAutoRedirect = true;
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+                Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                     secure:false,
                     statusCode:statusCode,
-                    destinationUri:HttpTestServers.RemoteEchoServer,
+                    destinationUri:Configuration.Http.RemoteEchoServer,
                     hops:1);
                 _output.WriteLine("Uri: {0}", uri);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
-                    Assert.Equal(HttpTestServers.RemoteEchoServer, response.RequestMessage.RequestUri);
+                    Assert.Equal(Configuration.Http.RemoteEchoServer, response.RequestMessage.RequestUri);
                 }
             }
         }
@@ -376,16 +376,16 @@ namespace System.Net.Http.Functional.Tests
             handler.AllowAutoRedirect = true;
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+                Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                     secure:false,
                     statusCode:302,
-                    destinationUri:HttpTestServers.SecureRemoteEchoServer,
+                    destinationUri:Configuration.Http.SecureRemoteEchoServer,
                     hops:1);
                 _output.WriteLine("Uri: {0}", uri);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
-                    Assert.Equal(HttpTestServers.SecureRemoteEchoServer, response.RequestMessage.RequestUri);
+                    Assert.Equal(Configuration.Http.SecureRemoteEchoServer, response.RequestMessage.RequestUri);
                 }
             }
         }
@@ -397,10 +397,10 @@ namespace System.Net.Http.Functional.Tests
             handler.AllowAutoRedirect = true;
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+                Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                     secure:true,
                     statusCode:302,
-                    destinationUri:HttpTestServers.RemoteEchoServer,
+                    destinationUri:Configuration.Http.RemoteEchoServer,
                     hops:1);
                 _output.WriteLine("Uri: {0}", uri);
                 using (HttpResponseMessage response = await client.GetAsync(uri))
@@ -416,10 +416,10 @@ namespace System.Net.Http.Functional.Tests
         {
             var handler = new HttpClientHandler();
             handler.AllowAutoRedirect = true;
-            Uri targetUri = HttpTestServers.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
+            Uri targetUri = Configuration.Http.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
             using (var client = new HttpClient(handler))
             {
-                Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+                Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                     secure:false,
                     statusCode:302,
                     destinationUri:targetUri,
@@ -442,10 +442,10 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient(new HttpClientHandler() { MaxAutomaticRedirections = maxHops }))
             {
-                Task<HttpResponseMessage> t = client.GetAsync(HttpTestServers.RedirectUriForDestinationUri(
+                Task<HttpResponseMessage> t = client.GetAsync(Configuration.Http.RedirectUriForDestinationUri(
                     secure: false,
                     statusCode: 302,
-                    destinationUri: HttpTestServers.RemoteEchoServer,
+                    destinationUri: Configuration.Http.RemoteEchoServer,
                     hops: hops));
 
                 if (hops <= maxHops)
@@ -453,7 +453,7 @@ namespace System.Net.Http.Functional.Tests
                     using (HttpResponseMessage response = await t)
                     {
                         Assert.Equal(HttpStatusCode.OK, response.StatusCode);
-                        Assert.Equal(HttpTestServers.RemoteEchoServer, response.RequestMessage.RequestUri);
+                        Assert.Equal(Configuration.Http.RemoteEchoServer, response.RequestMessage.RequestUri);
                     }
                 }
                 else
@@ -468,10 +468,10 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = true }))
             {
-                Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+                Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                     secure: false,
                     statusCode: 302,
-                    destinationUri: HttpTestServers.RemoteEchoServer,
+                    destinationUri: Configuration.Http.RemoteEchoServer,
                     hops: 1,
                     relative: true);
                 _output.WriteLine("Uri: {0}", uri);
@@ -479,7 +479,7 @@ namespace System.Net.Http.Functional.Tests
                 using (HttpResponseMessage response = await client.GetAsync(uri))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
-                    Assert.Equal(HttpTestServers.RemoteEchoServer, response.RequestMessage.RequestUri);
+                    Assert.Equal(Configuration.Http.RemoteEchoServer, response.RequestMessage.RequestUri);
                 }
             }
         }
@@ -570,7 +570,7 @@ namespace System.Net.Http.Functional.Tests
             handler.Credentials = _credential;
             using (var client = new HttpClient(handler))
             {
-                Uri redirectUri = HttpTestServers.RedirectUriForCreds(
+                Uri redirectUri = Configuration.Http.RedirectUriForCreds(
                     secure:false,
                     statusCode:302,
                     userName:Username,
@@ -585,8 +585,8 @@ namespace System.Net.Http.Functional.Tests
         [Theory, MemberData(nameof(RedirectStatusCodes))]
         public async Task GetAsync_CredentialIsCredentialCacheUriRedirect_StatusCodeOK(int statusCode)
         {
-            Uri uri = HttpTestServers.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
-            Uri redirectUri = HttpTestServers.RedirectUriForCreds(
+            Uri uri = Configuration.Http.BasicAuthUriForCreds(secure:false, userName:Username, password:Password);
+            Uri redirectUri = Configuration.Http.RedirectUriForCreds(
                 secure:false,
                 statusCode:statusCode,
                 userName:Username,
@@ -613,7 +613,7 @@ namespace System.Net.Http.Functional.Tests
         {
             using (HttpClient client = new HttpClient())
             {
-                using (HttpResponseMessage httpResponse = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+                using (HttpResponseMessage httpResponse = await client.GetAsync(Configuration.Http.RemoteEchoServer))
                 {
                     string responseText = await httpResponse.Content.ReadAsStringAsync();
                     _output.WriteLine(responseText);
@@ -628,11 +628,11 @@ namespace System.Net.Http.Functional.Tests
         {
             var handler = new HttpClientHandler();
             var cookieContainer = new CookieContainer();
-            cookieContainer.Add(HttpTestServers.RemoteEchoServer, new Cookie(cookieName, cookieValue));
+            cookieContainer.Add(Configuration.Http.RemoteEchoServer, new Cookie(cookieName, cookieValue));
             handler.CookieContainer = cookieContainer;
             using (var client = new HttpClient(handler))
             {
-                using (HttpResponseMessage httpResponse = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+                using (HttpResponseMessage httpResponse = await client.GetAsync(Configuration.Http.RemoteEchoServer))
                 {
                     Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
                     string responseText = await httpResponse.Content.ReadAsStringAsync();
@@ -646,10 +646,10 @@ namespace System.Net.Http.Functional.Tests
         [InlineData("cookieName1", "cookieValue1")]
         public async Task GetAsync_RedirectResponseHasCookie_CookieSentToFinalUri(string cookieName, string cookieValue)
         {
-            Uri uri = HttpTestServers.RedirectUriForDestinationUri(
+            Uri uri = Configuration.Http.RedirectUriForDestinationUri(
                 secure:false,
                 statusCode:302,
-                destinationUri:HttpTestServers.RemoteEchoServer,
+                destinationUri:Configuration.Http.RemoteEchoServer,
                 hops:1);
             using (HttpClient client = new HttpClient())
             {
@@ -769,7 +769,7 @@ namespace System.Net.Http.Functional.Tests
             {
                 const int NumGets = 5;
                 Task<HttpResponseMessage>[] responseTasks = (from _ in Enumerable.Range(0, NumGets)
-                                                             select client.GetAsync(HttpTestServers.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead)).ToArray();
+                                                             select client.GetAsync(Configuration.Http.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead)).ToArray();
                 for (int i = responseTasks.Length - 1; i >= 0; i--) // read backwards to increase likelihood that we wait on a different task than has data available
                 {
                     using (HttpResponseMessage response = await responseTasks[i])
@@ -789,7 +789,7 @@ namespace System.Net.Http.Functional.Tests
         [Fact]
         public async Task SendAsync_HttpRequestMsgResponseHeadersRead_StatusCodeOK()
         {
-            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, HttpTestServers.SecureRemoteEchoServer);
+            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, Configuration.Http.SecureRemoteEchoServer);
             using (var client = new HttpClient())
             {
                 using (HttpResponseMessage response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
@@ -1118,10 +1118,10 @@ namespace System.Net.Http.Functional.Tests
         {
             const string ContentString = "This is the content string.";
             var content = new StringContent(ContentString);
-            Uri redirectUri = HttpTestServers.RedirectUriForDestinationUri(
+            Uri redirectUri = Configuration.Http.RedirectUriForDestinationUri(
                 secure,
                 302,
-                secure ? HttpTestServers.SecureRemoteEchoServer : HttpTestServers.RemoteEchoServer,
+                secure ? Configuration.Http.SecureRemoteEchoServer : Configuration.Http.RemoteEchoServer,
                 1);
 
             using (var client = new HttpClient())
@@ -1148,7 +1148,7 @@ namespace System.Net.Http.Functional.Tests
                 fs.Flush(flushToDisk: true);
                 fs.Position = 0;
 
-                Uri redirectUri = HttpTestServers.RedirectUriForDestinationUri(false, statusCode, HttpTestServers.SecureRemoteEchoServer, 1);
+                Uri redirectUri = Configuration.Http.RedirectUriForDestinationUri(false, statusCode, Configuration.Http.SecureRemoteEchoServer, 1);
 
                 using (var client = new HttpClient())
                 using (HttpResponseMessage response = await client.PostAsync(redirectUri, new StreamContent(fs)))
@@ -1306,7 +1306,7 @@ namespace System.Net.Http.Functional.Tests
         {
             using (var client = new HttpClient())
             {
-                using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.StatusCodeUri(
+                using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.StatusCodeUri(
                     false,
                     (int)statusCode,
                     reasonPhrase)))
@@ -1325,7 +1325,7 @@ namespace System.Net.Http.Functional.Tests
             {
                 string expectedContent = "Test contest";
                 var content = new ChannelBindingAwareContent(expectedContent);
-                using (HttpResponseMessage response = await client.PostAsync(HttpTestServers.SecureRemoteEchoServer, content))
+                using (HttpResponseMessage response = await client.PostAsync(Configuration.Http.SecureRemoteEchoServer, content))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
@@ -1349,7 +1349,7 @@ namespace System.Net.Http.Functional.Tests
             {
                 var request = new HttpRequestMessage(
                     new HttpMethod(method), 
-                    secureServer ? HttpTestServers.SecureRemoteEchoServer : HttpTestServers.RemoteEchoServer);
+                    secureServer ? Configuration.Http.SecureRemoteEchoServer : Configuration.Http.RemoteEchoServer);
                 using (HttpResponseMessage response = await client.SendAsync(request))
                 {
                     Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@@ -1367,7 +1367,7 @@ namespace System.Net.Http.Functional.Tests
             {
                 var request = new HttpRequestMessage(
                     new HttpMethod(method), 
-                    secureServer ? HttpTestServers.SecureRemoteEchoServer : HttpTestServers.RemoteEchoServer);
+                    secureServer ? Configuration.Http.SecureRemoteEchoServer : Configuration.Http.RemoteEchoServer);
                 request.Content = new StringContent(ExpectedContent);
                 using (HttpResponseMessage response = await client.SendAsync(request))
                 {
@@ -1397,7 +1397,7 @@ namespace System.Net.Http.Functional.Tests
                 var content = new MemoryStream();
                 content.Write(byteContent, 0, byteContent.Length);
                 content.Position = startingPosition;
-                var request = new HttpRequestMessage(HttpMethod.Post, HttpTestServers.RemoteEchoServer) { Content = new StreamContent(content) };
+                var request = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.RemoteEchoServer) { Content = new StreamContent(content) };
 
                 for (int iter = 0; iter < 2; iter++)
                 {
@@ -1428,7 +1428,7 @@ namespace System.Net.Http.Functional.Tests
             {
                 var request = new HttpRequestMessage(
                     new HttpMethod(method),
-                    secureServer ? HttpTestServers.SecureRemoteEchoServer : HttpTestServers.RemoteEchoServer)
+                    secureServer ? Configuration.Http.SecureRemoteEchoServer : Configuration.Http.RemoteEchoServer)
                 {
                     Content = new StringContent(ExpectedContent)
                 };
@@ -1594,7 +1594,7 @@ namespace System.Net.Http.Functional.Tests
             using (var handler = new HttpClientHandler() { Proxy = new UseSpecifiedUriWebProxy(proxyUrl, creds) })
             using (var client = new HttpClient(handler))
             {
-                Task<HttpResponseMessage> responseTask = client.GetAsync(HttpTestServers.RemoteEchoServer);
+                Task<HttpResponseMessage> responseTask = client.GetAsync(Configuration.Http.RemoteEchoServer);
                 Task<string> responseStringTask = responseTask.ContinueWith(t => t.Result.Content.ReadAsStringAsync(), TaskScheduler.Default).Unwrap();
                 Task.WaitAll(proxyTask, responseTask, responseStringTask);
 
@@ -1615,7 +1615,7 @@ namespace System.Net.Http.Functional.Tests
         public async Task Proxy_BypassTrue_GetRequestDoesntGoesThroughCustomProxy(IWebProxy proxy)
         {
             using (var client = new HttpClient(new HttpClientHandler() { Proxy = proxy }))
-            using (HttpResponseMessage response = await client.GetAsync(HttpTestServers.RemoteEchoServer))
+            using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.RemoteEchoServer))
             {
                 TestHelper.VerifyResponseBody(
                     await response.Content.ReadAsStringAsync(),
@@ -1638,7 +1638,7 @@ namespace System.Net.Http.Functional.Tests
             using (var handler = new HttpClientHandler() { Proxy = new UseSpecifiedUriWebProxy(proxyUrl, null) })
             using (var client = new HttpClient(handler))
             {
-                Task<HttpResponseMessage> responseTask = client.GetAsync(HttpTestServers.RemoteEchoServer);
+                Task<HttpResponseMessage> responseTask = client.GetAsync(Configuration.Http.RemoteEchoServer);
                 Task.WaitAll(proxyTask, responseTask);
 
                 Assert.Equal(HttpStatusCode.ProxyAuthenticationRequired, responseTask.Result.StatusCode);
index d4a1caa..15b446f 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Net.Http.Functional.Tests
 {
     public class HttpClientMiniStress
     {
-        private static bool HttpStressEnabled => TestSettings.Http.StressEnabled;
+        private static bool HttpStressEnabled => Configuration.Http.StressEnabled;
 
         [ConditionalTheory(nameof(HttpStressEnabled))]
         [MemberData(nameof(GetStressOptions))]
index 12897ed..05063d3 100644 (file)
@@ -116,7 +116,7 @@ namespace System.Net.Http.Functional.Tests
             using (var client = new HttpClient())
             {
                 client.MaxResponseContentBufferSize = 1;
-                await Assert.ThrowsAsync<HttpRequestException>(() => client.GetStringAsync(HttpTestServers.RemoteEchoServer));
+                await Assert.ThrowsAsync<HttpRequestException>(() => client.GetStringAsync(Configuration.Http.RemoteEchoServer));
             }
         }
 
index 67d0cba..d64dd69 100644 (file)
@@ -23,13 +23,13 @@ namespace System.Net.Http.Functional.Tests
         private const string UserName = "user1";
         private const string Password = "password1";
         private readonly static Uri BasicAuthServerUri =
-            HttpTestServers.BasicAuthUriForCreds(false, UserName, Password);
+            Configuration.Http.BasicAuthUriForCreds(false, UserName, Password);
         private readonly static Uri SecureBasicAuthServerUri =
-            HttpTestServers.BasicAuthUriForCreds(true, UserName, Password);
+            Configuration.Http.BasicAuthUriForCreds(true, UserName, Password);
 
         private readonly ITestOutputHelper _output;
 
-        public readonly static object[][] EchoServers = HttpTestServers.EchoServers;
+        public readonly static object[][] EchoServers = Configuration.Http.EchoServers;
 
         public readonly static object[][] BasicAuthEchoServers =
             new object[][]
@@ -120,7 +120,7 @@ namespace System.Net.Http.Functional.Tests
             }
             string content = sb.ToString();
 
-            await PostHelper(HttpTestServers.RemoteEchoServer, content, new StringContent(content),
+            await PostHelper(Configuration.Http.RemoteEchoServer, content, new StringContent(content),
                 useContentLengthUpload: true, useChunkedEncodingUpload: false);
         }
 
index a3437fa..bde7f80 100644 (file)
@@ -30,7 +30,7 @@ namespace System.Net.Http.Functional.Tests
             var client = new HttpClient();
             client.DefaultRequestHeaders.Add("X-ResponseStreamTest", customHeaderValue);
 
-            Stream stream = await client.GetStreamAsync(HttpTestServers.RemoteEchoServer);
+            Stream stream = await client.GetStreamAsync(Configuration.Http.RemoteEchoServer);
             using (var reader = new StreamReader(stream))
             {
                 string responseBody = reader.ReadToEnd();
@@ -49,7 +49,7 @@ namespace System.Net.Http.Functional.Tests
             var client = new HttpClient();
 
             HttpResponseMessage response =
-                await client.GetAsync(HttpTestServers.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead);
+                await client.GetAsync(Configuration.Http.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead);
             await response.Content.LoadIntoBufferAsync();
 
             string responseBody = await response.Content.ReadAsStringAsync();
@@ -67,7 +67,7 @@ namespace System.Net.Http.Functional.Tests
             var client = new HttpClient();
 
             HttpResponseMessage response =
-                await client.GetAsync(HttpTestServers.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead);
+                await client.GetAsync(Configuration.Http.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead);
 
             var memoryStream = new MemoryStream();
             await response.Content.CopyToAsync(memoryStream);
@@ -92,7 +92,7 @@ namespace System.Net.Http.Functional.Tests
 
             using (var client = new HttpClient())
             using (HttpResponseMessage response =
-                    await client.GetAsync(HttpTestServers.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead))
+                    await client.GetAsync(Configuration.Http.RemoteEchoServer, HttpCompletionOption.ResponseHeadersRead))
             using (Stream stream = await response.Content.ReadAsStreamAsync())
             {
                 var buffer = new byte[2048];
index f29e139..05c2b85 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Net.Security.Tests;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading.Tasks;
@@ -27,7 +26,7 @@ namespace System.Net.Http.Functional.Tests
         [PlatformSpecific(PlatformID.Windows)]
         public async Task HttpClient_ClientUsesAuxRecord_Ok()
         {
-            X509Certificate2 serverCert = CertificateConfiguration.GetServerCertificate();
+            X509Certificate2 serverCert = Configuration.Certificates.GetServerCertificate();
 
             var server = new SchSendAuxRecordTestServer(serverCert);
             int port = server.StartServer();
index 2178b5a..c40559a 100644 (file)
     <Compile Include="$(CommonTestPath)\System\IO\FileCleanupTestBase.cs">
       <Link>Common\System\IO\FileCleanupTestBase.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\CertificateConfiguration.cs">
-      <Link>Common\System\Net\CertificateConfiguration.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Certificates.cs">
+      <Link>Common\System\Net\Configuration.Certificates.cs</Link>
     </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\EventSourceTestLogging.cs">
       <Link>Common\System\Net\EventSourceTestLogging.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\HttpTestServers.cs">
-      <Link>Common\System\Net\HttpTestServers.cs</Link>
-    </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\SchSendAuxRecordTestServer.cs">
       <Link>Common\System\Net\SchSendAuxRecordTestServer.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
+      <Link>Common\System\Net\Configuration.cs</Link>
+    </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Http.cs">
+      <Link>Common\System\Net\Configuration.Http.cs</Link>
     </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\TestWebProxies.cs">
       <Link>Common\System\Net\TestWebProxies.cs</Link>
index 87c58c3..d5f52da 100644 (file)
@@ -70,7 +70,7 @@ namespace System.Net.NameResolution.PalTests
         [Fact]
         public void GetHostByName_HostName_GetHostByAddr()
         {
-            IPHostEntry hostEntry1 = NameResolutionPal.GetHostByName(TestSettings.Http.Http2Host);
+            IPHostEntry hostEntry1 = NameResolutionPal.GetHostByName(Configuration.Http.Http2Host);
             Assert.NotNull(hostEntry1);
 
             IPAddress[] list1 = hostEntry1.AddressList;
index 45a5e5b..694e4b9 100644 (file)
       <Link>Common\System\Net\IPEndPointStatics.cs</Link>
     </Compile>
 
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
+      <Link>Common\System\Net\Configuration.cs</Link>
+    </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Http.cs">
+      <Link>Common\System\Net\Configuration.Http.cs</Link>
     </Compile>
   </ItemGroup>
 
index 96bc949..de2463f 100644 (file)
@@ -27,7 +27,7 @@ namespace System.Net.Tests
         private int _responseCallbackCallCount = 0;
         private readonly ITestOutputHelper _output;
 
-        public readonly static object[][] EchoServers = HttpTestServers.EchoServers;
+        public readonly static object[][] EchoServers = Configuration.Http.EchoServers;
 
         public HttpWebRequestTest(ITestOutputHelper output)
         {
@@ -333,7 +333,7 @@ namespace System.Net.Tests
             {
                 strContent = sr.ReadToEnd();
             }
-            Assert.True(strContent.Contains("\"Host\": \"" + HttpTestServers.Host + "\""));
+            Assert.True(strContent.Contains("\"Host\": \"" + Configuration.Http.Host + "\""));
         }
 
         [Theory, MemberData(nameof(EchoServers))]
@@ -375,8 +375,8 @@ namespace System.Net.Tests
         }
 
         public static object[][] StatusCodeServers = {
-            new object[] { HttpTestServers.StatusCodeUri(false, 404) },
-            new object[] { HttpTestServers.StatusCodeUri(true, 404) },
+            new object[] { Configuration.Http.StatusCodeUri(false, 404) },
+            new object[] { Configuration.Http.StatusCodeUri(true, 404) },
         };
 
         [Theory, MemberData(nameof(StatusCodeServers))]
index e481c25..aaccc6b 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Net.Tests
         [Fact]
         public async Task ContentType_ServerResponseHasContentTypeHeader_ContentTypeIsNonEmptyString()
         {
-            HttpWebRequest request = WebRequest.CreateHttp(HttpTestServers.RemoteEchoServer);
+            HttpWebRequest request = WebRequest.CreateHttp(Configuration.Http.RemoteEchoServer);
             request.Method = HttpMethod.Get.Method;
             WebResponse response = await request.GetResponseAsync();
             Assert.True(!string.IsNullOrEmpty(response.ContentType));
index 0a10fce..66bfeba 100644 (file)
@@ -106,7 +106,7 @@ namespace System.Net.Tests
 
         private Stream GetRequestStream()
         {
-            HttpWebRequest request = HttpWebRequest.CreateHttp(HttpTestServers.RemoteEchoServer);
+            HttpWebRequest request = HttpWebRequest.CreateHttp(Configuration.Http.RemoteEchoServer);
             request.Method = "POST";
             return request.GetRequestStreamAsync().GetAwaiter().GetResult();
         }
index c28ed5e..ecbd071 100644 (file)
     <Compile Include="RequestStreamTest.cs" />
     <Compile Include="WebRequestTest.cs" />
 
-    <Compile Include="$(CommonTestPath)\System\Net\CertificateConfiguration.cs">
-      <Link>Common\System\Net\CertificateConfiguration.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
+      <Link>Common\System\Net\Configuration.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\HttpTestServers.cs">
-      <Link>Common\System\Net\HttpTestServers.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Certificates.cs">
+      <Link>Common\System\Net\Configuration.Certificates.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Http.cs">
+      <Link>Common\System\Net\Configuration.Http.cs</Link>
     </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\Http\LoopbackServer.cs">
       <Link>Common\System\Net\Http\LoopbackServer.cs</Link>
index 4f1884a..42b6106 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Net.Sockets;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading.Tasks;
 
@@ -22,11 +21,11 @@ namespace System.Net.Security.Tests
 
         public CertificateValidationClientServer()
         {
-            _serverCertificateCollection = CertificateConfiguration.GetServerCertificateCollection();
-            _serverCertificate = CertificateConfiguration.GetServerCertificate();
+            _serverCertificateCollection = Configuration.Certificates.GetServerCertificateCollection();
+            _serverCertificate = Configuration.Certificates.GetServerCertificate();
 
-            _clientCertificateCollection = CertificateConfiguration.GetClientCertificateCollection();
-            _clientCertificate = CertificateConfiguration.GetClientCertificate();
+            _clientCertificateCollection = Configuration.Certificates.GetClientCertificateCollection();
+            _clientCertificate = Configuration.Certificates.GetClientCertificate();
         }
 
         public void Dispose()
index 9c37bc8..8bb9b13 100644 (file)
@@ -18,11 +18,11 @@ namespace System.Net.Security.Tests
         {
             using (var client = new TcpClient(AddressFamily.InterNetwork))
             {
-                await client.ConnectAsync(TestSettings.Http.SecureHost, 443);
+                await client.ConnectAsync(Configuration.Security.TlsServer.IdnHost, Configuration.Security.TlsServer.Port);
 
                 using (SslStream sslStream = new SslStream(client.GetStream(), false, RemoteHttpsCertValidation, null))
                 {
-                    await sslStream.AuthenticateAsClientAsync(TestSettings.Http.SecureHost);
+                    await sslStream.AuthenticateAsClientAsync(Configuration.Security.TlsServer.IdnHost);
                 }
             }
         }
index e01de69..9d10d9c 100644 (file)
@@ -5,7 +5,6 @@
 using System.IO;
 using System.Net.Sockets;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading.Tasks;
@@ -148,7 +147,7 @@ namespace System.Net.Security.Tests
 
 
                     SslStream sslStream = null;
-                    X509Certificate2 certificate = CertificateConfiguration.GetServerCertificate();
+                    X509Certificate2 certificate = Configuration.Certificates.GetServerCertificate();
 
                     try
                     {
index 67162aa..c8c66da 100644 (file)
@@ -25,19 +25,19 @@ namespace System.Net.Security.Tests
             {
                 yield return new object[] { CredentialCache.DefaultNetworkCredentials };
                 yield return new object[] { new NetworkCredential(
-                    Configuration.ActiveDirectoryUserName,
-                    Configuration.ActiveDirectoryUserPassword,
-                    Configuration.ActiveDirectoryName) };
+                    Configuration.Security.ActiveDirectoryUserName,
+                    Configuration.Security.ActiveDirectoryUserPassword,
+                    Configuration.Security.ActiveDirectoryName) };
                 
                 // Anonymous (with domain name).
                 yield return new object[] { new NetworkCredential(
-                    Configuration.ActiveDirectoryUserName,
+                    Configuration.Security.ActiveDirectoryUserName,
                     null,
-                    Configuration.ActiveDirectoryName) };
+                    Configuration.Security.ActiveDirectoryName) };
                 
                 // Anonymous (without domain).
                 yield return new object[] { new NetworkCredential(
-                    Configuration.ActiveDirectoryUserName,
+                    Configuration.Security.ActiveDirectoryUserName,
                     null,
                     null) };
             }
@@ -47,16 +47,16 @@ namespace System.Net.Security.Tests
         {
             get
             {
-                yield return new object[] { new NetworkCredential(null, null, Configuration.ActiveDirectoryName) };
+                yield return new object[] { new NetworkCredential(null, null, Configuration.Security.ActiveDirectoryName) };
                 yield return new object[] { new NetworkCredential(null, null, null) };
                 yield return new object[] { new NetworkCredential(
                     "baduser", 
                     null, 
-                    Configuration.ActiveDirectoryName) };
+                    Configuration.Security.ActiveDirectoryName) };
                 yield return new object[] { new NetworkCredential(
                     "baduser", 
                     "badpassword", 
-                    Configuration.ActiveDirectoryName) };
+                    Configuration.Security.ActiveDirectoryName) };
             }
         }
 
@@ -80,8 +80,8 @@ namespace System.Net.Security.Tests
 
         private async Task VerifyAuthentication(NetworkCredential credential)
         {
-            string serverName = Configuration.NegotiateServer.Host;
-            int port = Configuration.NegotiateServer.Port;
+            string serverName = Configuration.Security.NegotiateServer.Host;
+            int port = Configuration.Security.NegotiateServer.Port;
             string serverSPN = "HOST/" + serverName;
             bool isLocalhost = await IsLocalHost(serverName);
             
index f1a34ca..b95c912 100644 (file)
@@ -5,7 +5,6 @@
 using System.Collections.Generic;
 using System.Net.Sockets;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Runtime.ExceptionServices;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
@@ -26,7 +25,7 @@ namespace System.Net.Security.Tests
         {
             _log = TestLogging.GetInstance();
             _logVerbose = VerboseTestLogging.GetInstance();
-            _serverCertificate = CertificateConfiguration.GetServerCertificate();
+            _serverCertificate = Configuration.Certificates.GetServerCertificate();
         }
 
         public void Dispose()
index b7b8b9c..5849cde 100644 (file)
@@ -3,7 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Net.Sockets;
-using System.Net.Tests;
+using System.Net.Test.Common;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading.Tasks;
@@ -19,7 +19,7 @@ namespace System.Net.Security.Tests
         {
             TcpListener listener = new TcpListener(IPAddress.Any, 0);
 
-            using (X509Certificate2 serverCertificate = CertificateConfiguration.GetServerCertificate())
+            using (X509Certificate2 serverCertificate = Configuration.Certificates.GetServerCertificate())
             using (TcpClient client = new TcpClient())
             {
                 listener.Start();
index 6d37362..1a09659 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Net.Sockets;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Security.Cryptography.X509Certificates;
 using System.Text;
 using System.Threading.Tasks;
@@ -27,7 +26,7 @@ namespace System.Net.Security.Tests
         [PlatformSpecific(PlatformID.Windows)]
         public async Task SslStream_ClientAndServerUsesAuxRecord_Ok()
         {
-            X509Certificate2 serverCert = CertificateConfiguration.GetServerCertificate();
+            X509Certificate2 serverCert = Configuration.Certificates.GetServerCertificate();
             var server = new SchSendAuxRecordTestServer(serverCert);
 
             int port = server.StartServer();
index d0ea11a..edcb723 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Linq;
 using System.Net.Test.Common;
-using System.Net.Tests;
 using System.Security.Authentication;
 using System.Security.Cryptography.X509Certificates;
 using System.Text;
@@ -27,7 +26,7 @@ namespace System.Net.Security.Tests
             using (var serverStream = new VirtualNetworkStream(network, isServer: true))
             using (var client = new SslStream(clientStream, false, AllowAnyServerCertificate))
             using (var server = new SslStream(serverStream))
-            using (X509Certificate2 certificate = CertificateConfiguration.GetServerCertificate())
+            using (X509Certificate2 certificate = Configuration.Certificates.GetServerCertificate())
             {
                 Task[] auth = new Task[2];
                 auth[0] = client.AuthenticateAsClientAsync(certificate.GetNameInfo(X509NameType.SimpleName, false));
@@ -47,7 +46,7 @@ namespace System.Net.Security.Tests
             using (var serverStream = new VirtualNetworkStream(network, isServer: true))
             using (var client = new SslStream(clientStream))
             using (var server = new SslStream(serverStream))
-            using (var certificate = CertificateConfiguration.GetServerCertificate())
+            using (var certificate = Configuration.Certificates.GetServerCertificate())
             {
                 Task[] auth = new Task[2];
                 auth[0] = client.AuthenticateAsClientAsync("incorrectServer");
@@ -226,7 +225,7 @@ namespace System.Net.Security.Tests
 
         private bool DoHandshake(SslStream clientSslStream, SslStream serverSslStream)
         {
-            using (X509Certificate2 certificate = CertificateConfiguration.GetServerCertificate())
+            using (X509Certificate2 certificate = Configuration.Certificates.GetServerCertificate())
             {
                 Task[] auth = new Task[2];
 
index 8080c61..c3fcbcd 100644 (file)
@@ -58,9 +58,6 @@
     <Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
       <Link>Common\System\PlatformDetection.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\CertificateConfiguration.cs">
-      <Link>Common\System\Net\CertificateConfiguration.cs</Link>
-    </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\Capability.Security.cs">
       <Link>Common\System\Net\Capability.Security.cs</Link>
     </Compile>
@@ -70,6 +67,9 @@
     <Compile Include="$(CommonTestPath)\System\Net\Configuration.Security.cs">
       <Link>Common\System\Net\Configuration.Security.cs</Link>
     </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Certificates.cs">
+      <Link>Common\System\Net\Configuration.Certificates.cs</Link>
+    </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\SchSendAuxRecordTestServer.cs">
       <Link>Common\System\Net\SchSendAuxRecordTestServer.cs</Link>
     </Compile>
@@ -79,9 +79,6 @@
     <Compile Include="$(CommonTestPath)\System\Net\TestLogging.cs">
       <Link>Common\System\Net\TestLogging.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
-    </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\VerboseTestLogging.cs">
       <Link>Common\System\Net\VerboseTestLogging.cs</Link>
     </Compile>
     <Compile Include="IdentityValidator.Unix.cs" />
   </ItemGroup>
   <ItemGroup Condition=" '$(TargetsLinux)' == 'true' ">
-    <None Include="..\Scripts\setup-kdc.sh">
+    <None Include="..\Scripts\Unix\setup-kdc.sh">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Include="..\Scripts\krb5.conf">
+    <None Include="..\Scripts\Unix\krb5.conf">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Include="..\Scripts\kdc.conf.ubuntu">
+    <None Include="..\Scripts\Unix\kdc.conf.ubuntu">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Include="..\Scripts\kdc.conf.centos">
+    <None Include="..\Scripts\Unix\kdc.conf.centos">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Include="..\Scripts\kdc.conf.opensuse">
+    <None Include="..\Scripts\Unix\kdc.conf.opensuse">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
     <Compile Include="NegotiateStreamTestForUnix.cs" />
index 56d8024..3839e99 100644 (file)
@@ -150,7 +150,7 @@ namespace System.Net.Sockets.Tests
                 }
 
                 Assert.True(
-                    accepted.WaitOne(Configuration.PassingTestTimeout), "Test completed in alotted time");
+                    accepted.WaitOne(TestSettings.PassingTestTimeout), "Test completed in alotted time");
 
                 Assert.Equal(
                     SocketError.Success, acceptArgs.SocketError);
index 1170705..6bca550 100644 (file)
@@ -47,7 +47,7 @@ namespace System.Net.Sockets.Tests
                 using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                 {
                     Assert.True(client.ConnectAsync(args));
-                    Assert.True(completed.WaitOne(Configuration.PassingTestTimeout), "IPv4: Timed out while waiting for connection");
+                    Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "IPv4: Timed out while waiting for connection");
                     Assert.Equal<SocketError>(SocketError.Success, args.SocketError);
                 }
             }
@@ -74,7 +74,7 @@ namespace System.Net.Sockets.Tests
                 using (Socket client = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
                 {
                     Assert.True(client.ConnectAsync(args));
-                    Assert.True(completed.WaitOne(Configuration.PassingTestTimeout), "IPv6: Timed out while waiting for connection");
+                    Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "IPv6: Timed out while waiting for connection");
                     Assert.Equal<SocketError>(SocketError.Success, args.SocketError);
                 }
             }
index 906881f..072a4cd 100644 (file)
@@ -52,7 +52,7 @@ namespace System.Net.Sockets.Tests
                 args.UserToken = complete;
 
                 Assert.True(sock.ConnectAsync(args));
-                Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "IPv4: Timed out while waiting for connection");
+                Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "IPv4: Timed out while waiting for connection");
                 Assert.True(args.SocketError == SocketError.Success);
 
                 sock.Dispose();
@@ -62,7 +62,7 @@ namespace System.Net.Sockets.Tests
                 complete.Reset();
 
                 Assert.True(sock.ConnectAsync(args));
-                Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "IPv6: Timed out while waiting for connection");
+                Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "IPv6: Timed out while waiting for connection");
                 Assert.True(args.SocketError == SocketError.Success);
             }
             finally
index b544997..0eea635 100644 (file)
@@ -174,7 +174,7 @@ namespace System.Net.Sockets.Tests
             bool willRaiseEvent = sock.ConnectAsync(args);
             if (willRaiseEvent)
             {
-                Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+                Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
             }
 
             Assert.Equal(SocketError.Success, args.SocketError);
@@ -204,7 +204,7 @@ namespace System.Net.Sockets.Tests
             bool willRaiseEvent = sock.ConnectAsync(args);
             if (willRaiseEvent)
             {
-                Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+                Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
             }
 
             AssertHostNotFoundOrNoData(args);
@@ -232,7 +232,7 @@ namespace System.Net.Sockets.Tests
             bool willRaiseEvent = sock.ConnectAsync(args);
             if (willRaiseEvent)
             {
-                Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+                Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
             }
 
             Assert.Equal(SocketError.ConnectionRefused, args.SocketError);
@@ -266,7 +266,7 @@ namespace System.Net.Sockets.Tests
 
             Assert.True(Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args));
 
-            Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+            Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
 
             Assert.Equal(SocketError.Success, args.SocketError);
             Assert.Null(args.ConnectByNameError);
@@ -281,7 +281,7 @@ namespace System.Net.Sockets.Tests
 
             Assert.True(Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args));
 
-            Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+            Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
 
             Assert.Equal(SocketError.Success, args.SocketError);
             Assert.Null(args.ConnectByNameError);
@@ -311,7 +311,7 @@ namespace System.Net.Sockets.Tests
                 OnConnectAsyncCompleted(null, args);
             }
 
-            Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+            Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
 
             AssertHostNotFoundOrNoData(args);
 
@@ -336,7 +336,7 @@ namespace System.Net.Sockets.Tests
                 OnConnectAsyncCompleted(null, args);
             }
 
-            Assert.True(complete.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+            Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
 
             Assert.Equal(SocketError.ConnectionRefused, args.SocketError);
             Assert.True(args.ConnectByNameError is SocketException);
index 92ab028..f06fc99 100644 (file)
@@ -572,7 +572,7 @@ namespace System.Net.Sockets.Tests
 
                 socket.ConnectAsync(args);
 
-                Assert.True(waitHandle.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+                Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
                 if (args.SocketError != SocketError.Success)
                 {
                     throw new SocketException((int)args.SocketError);
@@ -598,7 +598,7 @@ namespace System.Net.Sockets.Tests
 
                 socket.ConnectAsync(args);
 
-                Assert.True(waitHandle.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+                Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
                 if (args.SocketError != SocketError.Success)
                 {
                     throw new SocketException((int)args.SocketError);
@@ -623,7 +623,7 @@ namespace System.Net.Sockets.Tests
 
                 Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args);
 
-                Assert.True(waitHandle.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+                Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
                 if (args.SocketError != SocketError.Success)
                 {
                     throw new SocketException((int)args.SocketError);
@@ -879,7 +879,7 @@ namespace System.Net.Sockets.Tests
                 catch (SocketException) { }
 
                 Assert.True(
-                    client.WaitHandle.WaitOne(Configuration.PassingTestTimeout),
+                    client.WaitHandle.WaitOne(TestSettings.PassingTestTimeout),
                     "Timed out while waiting for connection");
 
                 if (client.Error != SocketError.Success)
@@ -976,7 +976,7 @@ namespace System.Net.Sockets.Tests
                 waitHandles[0] = waitHandle;
                 waitHandles[1] = client.WaitHandle;
 
-                int completedHandle = WaitHandle.WaitAny(waitHandles, Configuration.PassingTestTimeout);
+                int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestTimeout);
 
                 if (completedHandle == WaitHandle.WaitTimeout)
                 {
@@ -1101,13 +1101,13 @@ namespace System.Net.Sockets.Tests
             using (SocketUdpServer server = new SocketUdpServer(_log, listenOn, dualModeServer, out port))
             {
                 // Send a few packets, in case they aren't delivered reliably.
-                for (int i = 0; i < (expectedToTimeout ? 1 : Configuration.UDPRedundancy); i++)
+                for (int i = 0; i < (expectedToTimeout ? 1 : TestSettings.UDPRedundancy); i++)
                 {
                     int sent = client.SendTo(new byte[1], new IPEndPoint(connectTo, port));
                     Assert.Equal(1, sent);
                 }
 
-                bool success = server.WaitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout); // Make sure the bytes were received
+                bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received
                 if (!success)
                 {
                     throw new TimeoutException();
@@ -1198,7 +1198,7 @@ namespace System.Net.Sockets.Tests
             using (SocketUdpServer server = new SocketUdpServer(_log, listenOn, dualModeServer, out port))
             {
                 // Send a few packets, in case they aren't delivered reliably.
-                for (int i = 0; i < (expectedToTimeout ? 1 : Configuration.UDPRedundancy); i++)
+                for (int i = 0; i < (expectedToTimeout ? 1 : TestSettings.UDPRedundancy); i++)
                 {
                     IAsyncResult async = client.BeginSendTo(new byte[1], 0, 1, SocketFlags.None, new IPEndPoint(connectTo, port), null, null);
 
@@ -1206,7 +1206,7 @@ namespace System.Net.Sockets.Tests
                     Assert.Equal(1, sent);
                 }
 
-                bool success = server.WaitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout); // Make sure the bytes were received
+                bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received
                 if (!success)
                 {
                     throw new TimeoutException();
@@ -1314,7 +1314,7 @@ namespace System.Net.Sockets.Tests
             using (SocketUdpServer server = new SocketUdpServer(_log, listenOn, dualModeServer, out port))
             {
                 // Send a few packets, in case they aren't delivered reliably.
-                for (int i = 0; i < (expectedToTimeout ? 1 : Configuration.UDPRedundancy); i++)
+                for (int i = 0; i < (expectedToTimeout ? 1 : TestSettings.UDPRedundancy); i++)
                 {
                     using (ManualResetEvent waitHandle = new ManualResetEvent(false))
                     {
@@ -1327,7 +1327,7 @@ namespace System.Net.Sockets.Tests
                         bool async = client.SendToAsync(args);
                         if (async)
                         {
-                            Assert.True(waitHandle.WaitOne(Configuration.PassingTestTimeout), "Timeout while waiting for connection");
+                            Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timeout while waiting for connection");
                         }
 
                         Assert.Equal(1, args.BytesTransferred);
@@ -1338,7 +1338,7 @@ namespace System.Net.Sockets.Tests
                     }
                 }
 
-                bool success = server.WaitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout); // Make sure the bytes were received
+                bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received
                 if (!success)
                 {
                     throw new TimeoutException();
@@ -1624,7 +1624,7 @@ namespace System.Net.Sockets.Tests
                 // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address);
 
                 SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port, redundant: !expectedToTimeout);
-                bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout);
+                bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout);
                 if (!success)
                 {
                     throw new TimeoutException();
@@ -1766,7 +1766,7 @@ namespace System.Net.Sockets.Tests
 
                 bool async = serverSocket.ReceiveFromAsync(args);
                 SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port, redundant: !expectedToTimeout);
-                if (async && !waitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout))
+                if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout))
                 {
                     throw new TimeoutException();
                 }
@@ -1986,7 +1986,7 @@ namespace System.Net.Sockets.Tests
                 IPPacketInformation ipPacketInformation;
                 int received = 0;
 
-                serverSocket.ReceiveTimeout = Configuration.FailingTestTimeout;
+                serverSocket.ReceiveTimeout = TestSettings.FailingTestTimeout;
 
                 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                 {
@@ -2012,7 +2012,7 @@ namespace System.Net.Sockets.Tests
                     });
                 }
 
-                serverSocket.ReceiveTimeout = expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout;
+                serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout;
 
                 SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port);
 
@@ -2182,7 +2182,7 @@ namespace System.Net.Sockets.Tests
                 // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address);
 
                 SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port, redundant: !expectedToTimeout);
-                bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout);
+                bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout);
                 if (!success)
                 {
                     throw new TimeoutException();
@@ -2341,7 +2341,7 @@ namespace System.Net.Sockets.Tests
         {
             using (Socket serverSocket = new Socket(SocketType.Dgram, ProtocolType.Udp))
             {
-                serverSocket.ReceiveTimeout = expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout;
+                serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout;
                 int port = serverSocket.BindToAnonymousPort(listenOn);
 
                 ManualResetEvent waitHandle = new ManualResetEvent(false);
@@ -2582,7 +2582,7 @@ namespace System.Net.Sockets.Tests
                 catch (SocketException ex)
                 {
                     Error = ex.SocketErrorCode;
-                    Task.Delay(Configuration.FailingTestTimeout).Wait(); // Give the other end a chance to call Accept().
+                    Task.Delay(TestSettings.FailingTestTimeout).Wait(); // Give the other end a chance to call Accept().
                     _serverSocket.Dispose(); // Cancels the test
                     _waitHandle.Set();
                 }
@@ -2597,7 +2597,7 @@ namespace System.Net.Sockets.Tests
                 Error = e.SocketError;
                 if (Error != SocketError.Success)
                 {
-                    Task.Delay(Configuration.FailingTestTimeout).Wait(); // Give the other end a chance to call Accept().
+                    Task.Delay(TestSettings.FailingTestTimeout).Wait(); // Give the other end a chance to call Accept().
                     _serverSocket.Dispose(); // Cancels the test
                 }
                 handle.Set();
@@ -2683,7 +2683,7 @@ namespace System.Net.Sockets.Tests
                 {
                     Socket socket = new Socket(_connectTo.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
 
-                    for (int i = 0; i < (redundant ? Configuration.UDPRedundancy : 1); i++)
+                    for (int i = 0; i < (redundant ? TestSettings.UDPRedundancy : 1); i++)
                     {
                         SocketAsyncEventArgs e = new SocketAsyncEventArgs();
                         e.RemoteEndPoint = new IPEndPoint(_connectTo, _port);
index 4df57e7..f62c023 100644 (file)
@@ -73,7 +73,7 @@ namespace System.Net.Sockets.Tests
                 Assert.True(receiver.ReceiveMessageFromAsync(receiveArgs));
 
                 // Send a few packets, in case they aren't delivered reliably.
-                for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                 {
                     sender.SendTo(new byte[1], new IPEndPoint(IPAddress.Loopback, port));
                 }
index a2edc52..d174da2 100644 (file)
@@ -21,7 +21,7 @@ namespace System.Net.Sockets.Tests
                     Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                     sender.Bind(new IPEndPoint(IPAddress.Loopback, 0));
 
-                    for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                    for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                     {
                         sender.SendTo(new byte[1024], new IPEndPoint(IPAddress.Loopback, port));
                     }
index 78f22e6..2f4f8b2 100644 (file)
@@ -32,7 +32,7 @@ namespace System.Net.Sockets.Tests
                     Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                     sender.Bind(new IPEndPoint(IPAddress.Loopback, 0));
 
-                    for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                    for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                     {
                         sender.SendTo(new byte[1024], new IPEndPoint(IPAddress.Loopback, port));
                     }
@@ -45,7 +45,7 @@ namespace System.Net.Sockets.Tests
 
                     Assert.True(receiver.ReceiveMessageFromAsync(args));
 
-                    Assert.True(completed.WaitOne(Configuration.PassingTestTimeout), "Timeout while waiting for connection");
+                    Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timeout while waiting for connection");
 
                     Assert.Equal(1024, args.BytesTransferred);
                     Assert.Equal(sender.LocalEndPoint, args.RemoteEndPoint);
index d21ea03..bdd5dd8 100644 (file)
@@ -41,7 +41,7 @@ namespace System.Net.Sockets.Tests
                 int receiverPort = receiver.BindToAnonymousPort(IPAddress.Loopback);
                 var receiverEndpoint = new IPEndPoint(IPAddress.Loopback, receiverPort);
 
-                for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                 {
                     sender.SendTo(new byte[1], SocketFlags.None, receiverEndpoint);
                 }
@@ -81,7 +81,7 @@ namespace System.Net.Sockets.Tests
                 int secondReceiverPort = secondReceiver.BindToAnonymousPort(IPAddress.Loopback);
                 var secondReceiverEndpoint = new IPEndPoint(IPAddress.Loopback, secondReceiverPort);
 
-                for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                 {
                     sender.SendTo(new byte[1], SocketFlags.None, firstReceiverEndpoint);
                     sender.SendTo(new byte[1], SocketFlags.None, secondReceiverEndpoint);
@@ -132,7 +132,7 @@ namespace System.Net.Sockets.Tests
                 int secondReceiverPort = secondReceiver.BindToAnonymousPort(IPAddress.Loopback);
                 var secondReceiverEndpoint = new IPEndPoint(IPAddress.Loopback, secondReceiverPort);
 
-                for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                 {
                     sender.SendTo(new byte[1], SocketFlags.None, secondReceiverEndpoint);
                 }
@@ -281,7 +281,7 @@ namespace System.Net.Sockets.Tests
                 int receiverPort = receiver.BindToAnonymousPort(IPAddress.Loopback);
                 var receiverEndpoint = new IPEndPoint(IPAddress.Loopback, receiverPort);
 
-                for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                 {
                     sender.SendTo(new byte[1], SocketFlags.None, receiverEndpoint);
                 }
index b5f74f4..6da5040 100644 (file)
@@ -247,7 +247,7 @@ namespace System.Net.Sockets.Tests
 
                         if (sock.SendPacketsAsync(args))
                         {
-                            Assert.True(completed.WaitOne(Configuration.PassingTestTimeout), "Timed out");
+                            Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out");
                         }
                         Assert.Equal(SocketError.Success, args.SocketError);
                         Assert.Equal(0, args.BytesTransferred);
@@ -261,7 +261,7 @@ namespace System.Net.Sockets.Tests
 
                         if (sock.SendPacketsAsync(args))
                         {
-                            Assert.True(completed.WaitOne(Configuration.PassingTestTimeout), "Timed out");
+                            Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out");
                         }
                         Assert.Equal(SocketError.Success, args.SocketError);
                         Assert.Equal(4, args.BytesTransferred);
@@ -449,7 +449,7 @@ namespace System.Net.Sockets.Tests
 
                         if (sock.SendPacketsAsync(args))
                         {
-                            Assert.True(completed.WaitOne(Configuration.PassingTestTimeout), "Timed out");
+                            Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out");
                         }
                         Assert.Equal(expectedResut, args.SocketError);
                         Assert.Equal(bytesExpected, args.BytesTransferred);
index c21868b..727f797 100644 (file)
@@ -129,7 +129,7 @@ namespace System.Net.Sockets.Tests
 
                 sendSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, IPAddress.HostToNetworkOrder(interfaceIndex));
 
-                for (int i = 0; i < Configuration.UDPRedundancy; i++)
+                for (int i = 0; i < TestSettings.UDPRedundancy; i++)
                 {
                     sendSocket.SendTo(Encoding.UTF8.GetBytes(message), new IPEndPoint(multicastAddress, port));
                 }
index 89d30f0..a26ac8d 100644 (file)
     <Compile Include="UnixDomainSocketTest.cs" />
     
     <!-- Common Sockets files -->
-    <Compile Include="$(CommonTestPath)\System\Net\Sockets\Configuration.cs">
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
       <Link>SocketCommon\Configuration.cs</Link>
     </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Sockets.cs">
+      <Link>SocketCommon\Configuration.Sockets.cs</Link>
+    </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Sockets\TestSettings.cs">
+      <Link>SocketCommon\TestSettings.cs</Link>
+    </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\Sockets\Fletcher32.cs">
       <Link>SocketCommon\Fletcher32.cs</Link>
     </Compile>
@@ -68,9 +74,6 @@
     <Compile Include="$(CommonTestPath)\System\Net\TestLogging.cs">
       <Link>Common\System\Net\TestLogging.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
-    </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\VerboseTestLogging.cs">
       <Link>Common\System\Net\VerboseTestLogging.cs</Link>
     </Compile>
index 6385e44..f9ed620 100644 (file)
@@ -30,8 +30,8 @@ namespace System.Net.Sockets.Tests
             {
                 Assert.False(client.Connected);
 
-                string host = TestSettings.Http.Host;
-                const int port = 80;
+                string host = Configuration.Sockets.SocketServer.IdnHost;
+                int port = Configuration.Sockets.SocketServer.Port;
 
                 if (mode == 0)
                 {
@@ -164,7 +164,7 @@ namespace System.Net.Sockets.Tests
                 client.ReceiveTimeout = 42;
                 client.SendTimeout = 84;
 
-                await client.ConnectAsync(TestSettings.Http.Host, 80);
+                await client.ConnectAsync(Configuration.Sockets.SocketServer.IdnHost, Configuration.Sockets.SocketServer.Port);
 
                 // Verify their values remain as were set before connecting
                 Assert.True(client.LingerState.Enabled);
index 1d27bcb..f965955 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Net.Sockets.Tests
                     remoteSocket.Connect(IPAddress.IPv6Loopback, port);
 
                     Socket acceptedSocket = localSocket.EndAccept(localAsync);
-                    acceptedSocket.ReceiveTimeout = Configuration.FailingTestTimeout;
+                    acceptedSocket.ReceiveTimeout = TestSettings.FailingTestTimeout;
 
                     SocketException sockEx = Assert.Throws<SocketException>(() =>
                    {
@@ -67,7 +67,7 @@ namespace System.Net.Sockets.Tests
                     remoteSocket.Connect(IPAddress.IPv6Loopback, port);
 
                     Socket acceptedSocket = localSocket.EndAccept(localAsync);
-                    acceptedSocket.SendTimeout = Configuration.PassingTestTimeout;
+                    acceptedSocket.SendTimeout = TestSettings.PassingTestTimeout;
 
                     // Note that Send almost never times out because it only has to copy the data to the native buffer.
                     int bytes = acceptedSocket.Send(new byte[100]);
index f2f4cdb..e0499ed 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Net.Sockets.Tests
             _waitHandle.Reset();
             udpClient.BeginSend(sendBytes, sendBytes.Length, remoteServer, new AsyncCallback(AsyncCompleted), udpClient);
 
-            Assert.True(_waitHandle.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
+            Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
         }
 
         [Fact]
index a255e89..2eee8f6 100644 (file)
@@ -21,8 +21,8 @@
     <Compile Include="SocketTestServerAPMMock.cs" />
 
     <!-- Common Sockets files -->
-    <Compile Include="$(CommonTestPath)\System\Net\Sockets\Configuration.cs">
-      <Link>SocketCommon\Configuration.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Sockets\TestSettings.cs">
+      <Link>SocketCommon\TestSettings.cs</Link>
     </Compile>
     <Compile Include="$(CommonTestPath)\System\Net\Sockets\SocketTestServer.cs">
       <Link>SocketCommon\SocketTestServer.cs</Link>
index 2acada9..41f423d 100644 (file)
@@ -17,8 +17,8 @@ namespace System.Net.WebSockets.Client.Tests
     /// </summary>
     public class ClientWebSocketTestBase
     {
-        public readonly static object[][] EchoServers = WebSocketTestServers.EchoServers;
-        public readonly static object[][] EchoHeadersServers = WebSocketTestServers.EchoHeadersServers;
+        public readonly static object[][] EchoServers = Configuration.WebSockets.EchoServers;
+        public readonly static object[][] EchoHeadersServers = Configuration.WebSockets.EchoHeadersServers;
 
         public const int TimeOutMilliseconds = 10000;
         public const int CloseDescriptionMaxLength = 123;
@@ -43,7 +43,7 @@ namespace System.Net.WebSockets.Client.Tests
 
                 // Known server but not a real websocket endpoint.
                 {
-                    server = HttpTestServers.RemoteEchoServer;
+                    server = Configuration.Http.RemoteEchoServer;
                     var ub = new UriBuilder("ws", server.Host, server.Port, server.PathAndQuery);
 
                     yield return new object[] { ub.Uri };
index 150f61a..b8ab2ca 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Net.WebSockets.Client.Tests
         [OuterLoop] // involves long delay
         public async Task KeepAlive_LongDelayBetweenSendReceives_Succeeds()
         {
-            using (ClientWebSocket cws = await WebSocketHelper.GetConnectedWebSocket(WebSocketTestServers.RemoteEchoServer, TimeOutMilliseconds, _output, TimeSpan.FromSeconds(10)))
+            using (ClientWebSocket cws = await WebSocketHelper.GetConnectedWebSocket(Configuration.WebSockets.RemoteEchoServer, TimeOutMilliseconds, _output, TimeSpan.FromSeconds(10)))
             {
                 await cws.SendAsync(new ArraySegment<byte>(new byte[1] { 42 }), WebSocketMessageType.Binary, true, CancellationToken.None);
 
index 8e9dfec..989997c 100644 (file)
     <Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
       <Link>Common\System\AssertExtensions.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\HttpTestServers.cs">
-      <Link>Common\System\Net\HttpTestServers.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
+      <Link>Common\System\Net\Configuration.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\TestSettings.cs">
-      <Link>Common\System\Net\TestSettings.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.Http.cs">
+      <Link>Common\System\Net\Configuration.Http.cs</Link>
     </Compile>
-    <Compile Include="$(CommonTestPath)\System\Net\WebSocketTestServers.cs">
-      <Link>Common\System\Net\WebSocketTestServers.cs</Link>
+    <Compile Include="$(CommonTestPath)\System\Net\Configuration.WebSockets.cs">
+      <Link>Common\System\Net\Configuration.WebSockets.cs</Link>
     </Compile>
     <Compile Include="AbortTest.cs" />
     <Compile Include="CancelTest.cs" />