Build pipeline fix, partially done, running locally (#251)

This commit is contained in:
Peter Hsu 2019-05-31 10:29:23 -07:00 коммит произвёл GitHub
Родитель 934360d155
Коммит ed4488593f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
73 изменённых файлов: 527 добавлений и 311 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -275,3 +275,6 @@ test\appsettings.test.json
target
signed
dist
test/Microsoft.IIS.Administration.Tests/test.config.json
test/appsettings.test.json

Просмотреть файл

@ -7,7 +7,7 @@ trigger:
- releases/*
pr:
autoCancel: false
autoCancel: "false"
branches:
include:
- dev
@ -25,8 +25,30 @@ jobs:
- vstest
steps:
- checkout: self
clean: false
submodules: true
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=4.7.1'
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.1.505'
inputs:
version: 2.1.505
- task: NuGetCommand@2
displayName: 'Restore Dependencies'
inputs:
command: restore
restoreSolution: '*.sln'
- task: MSBuild@1
displayName: 'Build IIS Administration'
inputs:
solution: Microsoft.IIS.Administration.sln
msbuildVersion: "15.0"
msbuildArchitecture: x64
configuration: 'release'
msbuildArguments: '/t:publish'
- task: PowerShell@2
displayName: 'PowerShell Script build.ps1'

145
build.ps1
Просмотреть файл

@ -1,23 +1,74 @@
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Entry point for building/testing the project, common usage:
.\build.ps1 -devSetup -publish -install -test -verbose
What the command does
* Ensure local machine is properly setup for build and test the repo
* Build and publish application in `dist` directory
* Build and run installer
* Run functional tests
.PARAMETER publish
build and publish the manifests in dist directory.
Include this switch to build and test the project in a single step. However, its required that msbuild and nuget needs to be in the path when `publish` is set to true
.PARAMETER devSetup
Ensure local machine is properly setup for build and test the repo
.PARAMETER install
Install the built manifest for testing
.PARAMETER keepInstalledApp
Do not uninstall the application after steps are run
.PARAMETER test
Run the functional tests
.PARAMETER testPort
The port to use for service
.PARAMETER pingRetryCount
.PARAMETER pingRetryPeriod
When waiting for the service to come up, these properties defines the fequency and number of time to retry pinging the endpoint
.PARAMETER buildType
Build the binaries in debug or release mode, default: release
.PARAMETER appName
Do not change: the name of the application
#>
[CmdletBinding()]
param(
[switch]
$publish,
[switch]
$devSetup,
[switch]
$install,
[switch]
$keepInstalledApp,
[switch]
$test,
[string]
$publishPath = (Join-Path $PSScriptRoot "dist"),
[string]
$installPath = (Join-Path $env:ProgramFiles "IIS Administration"),
[int]
$testPort = 44326,
[int]
$testPort = 44326
$pingRetryCount = 20,
[int]
$pingRetryPeriod = 10,
[ValidateSet('debug','release')]
[string]
$buildType = 'release',
$appName = "Microsoft IIS Administration"
)
$ErrorActionPreference = "Stop"
@ -39,12 +90,26 @@ function DevEnvSetup() {
}
function Publish() {
& ([System.IO.Path]::Combine($scriptDir, "publish", "publish.ps1")) -OutputPath $publishPath -SkipPrompt
if ($test) {
Write-Host "$(BuildHeader) Overwriting published config file with test configurations..."
$testConfig = [System.IO.Path]::Combine($projectRoot, "test", "appsettings.test.json")
$publishConfig = [System.IO.Path]::Combine($publishPath, "Microsoft.IIS.Administration", "config", "appsettings.json")
Copy-Item -Path $testconfig -Destination $publishConfig -Force
if (!(Where.exe msbuild)) {
throw "msbuild command is required for publish option"
}
dotnet restore
msbuild /t:publish /p:Configuration=$buildType
}
function BuildSetupExe() {
if (!(Where.exe msbuild)) {
throw "msbuild command is required to build installer"
}
if (!(Where.exe nuget)) {
throw "nuget command is required to build installer"
}
Push-Location installer
try {
nuget restore
msbuild /p:Configuration=$buildType
} finally {
Pop-Location
}
}
@ -55,11 +120,13 @@ function EnsureIISFeatures() {
}
function InstallTestService() {
& ([System.IO.Path]::Combine($scriptDir, "setup", "setup.ps1")) Install -DistributablePath $publishPath -Path $installPath -Verbose -Port $testPort
& ([System.IO.Path]::Combine($projectRoot, "installer", "IISAdministrationBundle", "bin", "x64", "Release", "IISAdministrationSetup.exe")) /s /w
}
function UninistallTestService() {
& ([System.IO.Path]::Combine($scriptDir, "setup", "setup.ps1")) Uninstall -Path $installPath -ErrorAction SilentlyContinue | Out-Null
function UninstallTestService() {
$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match $appName }
$app.Uninstall() | Out-Null
Write-Verbose "Uninstalled $appName"
}
function CleanUp() {
@ -73,23 +140,34 @@ function CleanUp() {
throw
}
}
try {
UninistallTestService
} catch {
Write-Warning $_
Write-Warning "Failed to uninistall $serviceName"
if (!$keepInstalledApp) {
try {
UninstallTestService
} catch {
Write-Warning $_
Write-Warning "Failed to uninistall $serviceName"
}
}
}
function StartTestService($hold) {
$group = GetGlobalVariable IIS_ADMIN_API_OWNERS
$member = & ([System.IO.Path]::Combine($scriptDir, "setup", "security.ps1")) CurrentAdUser
Write-Host "$(BuildHeader) Sanity tests..."
$pingEndpoint = "https://localhost:$testPort"
try {
Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing $pingEndpoint | Out-Null
} catch {
$pingSucceeded = $false
while (!$pingSucceeded -and ($pingRetryCount -ge 0)) {
try {
Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing $pingEndpoint | Out-Null
$pingSucceeded = $true
} catch {
Write-Verbose "Failed to ping with status $($_.Exception.Status)"
$pingRetryCount--;
if ($pingRetryCount -ge 0) {
Start-Sleep $pingRetryPeriod
}
}
}
if (!$pingSucceeded) {
Write-Error "Failed to ping test server $pingEndpoint, did you forget to start it manually?"
Exit 1
}
@ -125,7 +203,6 @@ function GetGlobalVariable($name) {
########################################################### Main Script ##################################################################
$debug = $PSBoundParameters['debug']
$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
try {
$projectRoot = git rev-parse --show-toplevel
@ -135,8 +212,7 @@ try {
}
$scriptDir = Join-Path $projectRoot "scripts"
# publish script only takes full path
$publishPath = ForceResolvePath "$publishPath"
$installPath = ForceResolvePath "$installPath"
$publishPath = Join-Path $projectRoot "dist"
$serviceName = GetGlobalVariable DEFAULT_SERVICE_NAME
Write-Host "$(BuildHeader) Starting clean up..."
@ -151,8 +227,15 @@ try {
}
Write-Host "$(BuildHeader) Publishing..."
Publish
if ($publish) {
Publish
& ([System.IO.Path]::Combine($scriptDir, "build", "Clean-BuildDir.ps1")) -manifestDir $publishPath
if ($test) {
& ([System.IO.Path]::Combine($scriptDir, "tests", "Copy-TestConfig.ps1"))
}
BuildSetupExe
}
if ($install) {
Write-Host "$(BuildHeader) Installing service..."
InstallTestService

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 5.8 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 5.8 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 49 KiB

Просмотреть файл

@ -233,9 +233,21 @@
<Component Id="C_Microsoft.Extensions.Logging.Abstractions.dll" Guid="2D7A75AE-6D68-484B-8033-4F9FDDA7E7BF" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.Logging.Abstractions.dll" Source="$(var.APIDir)\Microsoft.Extensions.Logging.Abstractions.dll" />
</Component>
<Component Id="C_Microsoft.Extensions.Logging.Configuration.dll" Guid="90F16829-785B-42CD-9368-B3081B2AA048" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.Logging.Configuration.dll" Source="$(var.APIDir)\Microsoft.Extensions.Logging.Configuration.dll" />
</Component>
<Component Id="C_Microsoft.Extensions.Logging.Console.dll" Guid="A2BB4797-3E9D-4A42-9648-F71195FF607E" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.Logging.Console.dll" Source="$(var.APIDir)\Microsoft.Extensions.Logging.Console.dll" />
</Component>
<Component Id="C_Microsoft.Extensions.Logging.Debug.dll" Guid="89C6C2B7-990F-4C8B-807D-328BCFD29D2E" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.Logging.Debug.dll" Source="$(var.APIDir)\Microsoft.Extensions.Logging.Debug.dll" />
</Component>
<Component Id="C_Microsoft.Extensions.Logging.dll" Guid="A29F4FA6-04EF-41A1-B24B-16901667FB1C" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.Logging.dll" Source="$(var.APIDir)\Microsoft.Extensions.Logging.dll" />
</Component>
<Component Id="C_Microsoft.Extensions.Logging.EventLog.dll" Guid="F3B5C312-8DFC-460C-AB46-4A6E6532D9A1" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.Logging.EventLog.dll" Source="$(var.APIDir)\Microsoft.Extensions.Logging.EventLog.dll" />
</Component>
<Component Id="C_Microsoft.Extensions.ObjectPool.dll" Guid="081C6DBA-8FE3-48FD-A2E7-53536FA656FB" Win64="$(var.IsWin64)">
<File Id="Microsoft.Extensions.ObjectPool.dll" Source="$(var.APIDir)\Microsoft.Extensions.ObjectPool.dll" />
</Component>

Просмотреть файл

@ -0,0 +1,13 @@
try {
$projectRoot = git rev-parse --show-toplevel
} catch {
Write-Warning "Error looking for project root $_, using script location instead"
$projectRoot = [System.IO.Path]::Combine($PSScriptRoot, "..", "..")
}
$publishPath = Join-Path $projectRoot "dist"
Write-Host "$(BuildHeader) Overwriting published config file with test configurations..."
$testConfig = [System.IO.Path]::Combine($projectRoot, "test", "appsettings.test.json")
$publishConfig = [System.IO.Path]::Combine($publishPath, "Microsoft.IIS.Administration", "config", "appsettings.json")
Copy-Item -Path $testconfig -Destination $publishConfig -Force

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.AccessManagement</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.Certificates Class Library</Description>

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.Core Class Library</Description>

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.Files.Core Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.Files Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.AppPools Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Application Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.Authentication Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Authorization Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.CentralCertificates Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Compression Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.DefaultDocument Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Delegation Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.DirectoryBrowsing Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Files Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Handlers Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.HttpRedirect Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.HttpRequestTracing Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.HTTPResponseHeaders Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.IPRestrictions Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Info Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Logging Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Modules Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Monitoring Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.RequestFiltering Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.RequestMonitor Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Scm Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.Sites Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.SslSettings Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.MimeTypes Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.UrlRewrite Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.VirtualDirectory Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer.WorkerProcesses Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\plugins.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\plugins.props" />
<PropertyGroup>
<Description>Microsoft.IIS.Administration.WebServer Class Library</Description>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\sign.props" />
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="$(SolutionDir)\build\Microsoft.IIS.Administration.props" />
<Import Project="..\..\build\sign.props" />
<Import Project="..\..\build\version.props" />
<Import Project="..\..\build\Microsoft.IIS.Administration.props" />
<PropertyGroup>
<VersionPrefix>$(IISAdministrationVersion)</VersionPrefix>
@ -106,11 +106,11 @@
</ItemGroup>
<Target Name="CreatConfigs" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted -command &quot;&amp;'$(SolutionDir)\scripts\build\Copy-Configs.ps1' '$(MSBuildProjectDirectory)'&quot;" />
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted -command &quot;&amp;'..\..\scripts\build\Copy-Configs.ps1' '$(MSBuildProjectDirectory)'&quot;" />
</Target>
<Target Name="CleanBuildDir" Condition="$(CleanBuildDir) != ''" AfterTargets="Build">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted -command &quot;&amp;$(SolutionDir)\scripts\build\Clean-BuildDir.ps1&quot;" />
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted -command &quot;&amp;..\..\scripts\build\Clean-BuildDir.ps1&quot;" />
</Target>
<!-- Workaround for: Files generated during build are not copying to publish directory on first publish https://github.com/dotnet/cli/issues/5498#issuecomment-275932671 -->

Просмотреть файл

@ -9,7 +9,7 @@ namespace Microsoft.IIS.Administration.Tests
public class Api
{
public static readonly string API_URL = $"{Configuration.TEST_SERVER_URL}/api";
public static readonly string API_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api";
[Theory]
[InlineData(1)]

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.IIS.Administration.Tests
public static HttpClient Create()
{
return Create(Configuration.TEST_SERVER_URL);
return Create(Configuration.Instance().TEST_SERVER_URL);
}
public static HttpClient Create(string serverUri)

Просмотреть файл

@ -21,7 +21,7 @@ namespace Microsoft.IIS.Administration.Tests
public const string TEST_APP_POOL_NAME = "test_app_pool";
public static readonly string TEST_APP_POOL = $"{{\"name\": \"{TEST_APP_POOL_NAME}\"}}";
public static readonly string APP_POOLS_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/application-pools";
public static readonly string APP_POOLS_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/application-pools";
[Fact]
public void CreateAndCleanup()

Просмотреть файл

@ -18,7 +18,7 @@ namespace Microsoft.IIS.Administration.Tests
private const string TEST_APPLICATION_SITE_NAME = "test_application_site";
ITestOutputHelper _output;
public static readonly string APPLICATION_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/webapps";
public static readonly string APPLICATION_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/webapps";
public static readonly string TEST_APPLICATION_PHYSICAL_PATH = Path.Combine(Sites.TEST_SITE_PATH, "test_application");
@ -35,7 +35,7 @@ namespace Microsoft.IIS.Administration.Tests
JObject site = null;
Sites.EnsureNoSite(client, TEST_APPLICATION_SITE_NAME);
site = Sites.CreateSite(client, TEST_APPLICATION_SITE_NAME, 50307, Sites.TEST_SITE_PATH);
site = Sites.CreateSite(_output, client, TEST_APPLICATION_SITE_NAME, 50307, Sites.TEST_SITE_PATH);
if (site != null) {
JObject testApp = CreateApplication(client, "/test_application", TEST_APPLICATION_PHYSICAL_PATH, site);

Просмотреть файл

@ -11,12 +11,20 @@ namespace Microsoft.IIS.Administration.Tests
using System.Net.Http;
using System.Text;
using Xunit;
using Xunit.Abstractions;
public class Authorization
{
private const string TEST_SITE_NAME = "authorization_test_site";
public static readonly string AUTHORIZATION_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/authorization";
public static readonly string AUTHORIZATION_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/authorization";
private ITestOutputHelper _output;
public Authorization(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void ChangeAllProperties()
@ -25,7 +33,7 @@ namespace Microsoft.IIS.Administration.Tests
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject feature = GetAuthorizationFeature(client, site.Value<string>("name"), null);
Assert.NotNull(feature);
@ -51,7 +59,7 @@ namespace Microsoft.IIS.Administration.Tests
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject feature = GetAuthorizationFeature(client, site.Value<string>("name"), null);
Assert.NotNull(feature);

Просмотреть файл

@ -20,9 +20,9 @@ namespace Microsoft.IIS.Administration.Tests
public class CentralCertificates
{
private static readonly string CERTIFICATES_API_PATH = $"{Configuration.TEST_SERVER_URL}/api/certificates";
private static readonly string STORES_API_PATH = $"{Configuration.TEST_SERVER_URL}/api/certificates/stores";
private static readonly string FOLDER_PATH = Path.Combine(Configuration.TEST_ROOT_PATH, FOLDER_NAME);
private static readonly string CERTIFICATES_API_PATH = $"{Configuration.Instance().TEST_SERVER_URL}/api/certificates";
private static readonly string STORES_API_PATH = $"{Configuration.Instance().TEST_SERVER_URL}/api/certificates/stores";
private static readonly string FOLDER_PATH = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, FOLDER_NAME);
private const string NAME = "IIS Central Certificate Store";
private const string FOLDER_NAME = "CentralCertStore";
private const string CERT_NAME = "IISAdminLocalTest";
@ -36,7 +36,7 @@ namespace Microsoft.IIS.Administration.Tests
public static string CcsTestUsername {
get {
return Configuration.Raw.Value<string>("ccs_user") ?? "IisAdminCcsTestR";
return Configuration.Instance().CCSUser;
}
}
@ -72,7 +72,7 @@ namespace Microsoft.IIS.Administration.Tests
};
using (var client = ApiHttpClient.Create()) {
JObject webserver = client.Get($"{Configuration.TEST_SERVER_URL}/api/webserver/");
JObject webserver = client.Get($"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/");
string ccsLink = Utils.GetLink(webserver, "central_certificates");
HttpResponseMessage res = client.PostRaw(ccsLink, (object)ccsInfo);
Assert.True((int)res.StatusCode == 403);
@ -97,7 +97,7 @@ namespace Microsoft.IIS.Administration.Tests
};
using (var client = ApiHttpClient.Create()) {
JObject webserver = client.Get($"{Configuration.TEST_SERVER_URL}/api/webserver/");
JObject webserver = client.Get($"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/");
string ccsLink = Utils.GetLink(webserver, "central_certificates");
HttpResponseMessage res = client.PostRaw(ccsLink, (object)ccsInfo);
Assert.True((int)res.StatusCode == 400);
@ -146,7 +146,7 @@ namespace Microsoft.IIS.Administration.Tests
const string siteName = "CcsBindingTestSite";
using (var client = ApiHttpClient.Create()) {
Sites.EnsureNoSite(client, siteName);
site = Sites.CreateSite(client, siteName, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
site = Sites.CreateSite(_output, client, siteName, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
Assert.NotNull(site);
try {
@ -207,7 +207,7 @@ namespace Microsoft.IIS.Administration.Tests
};
using (var client = ApiHttpClient.Create()) {
JObject webserver = client.Get($"{Configuration.TEST_SERVER_URL}/api/webserver/");
JObject webserver = client.Get($"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/");
string ccsLink = Utils.GetLink(webserver, "central_certificates");
return client.Post(ccsLink, (object)ccsInfo) != null;
}
@ -216,7 +216,7 @@ namespace Microsoft.IIS.Administration.Tests
private bool Disable()
{
using (var client = ApiHttpClient.Create()) {
JObject webserver = client.Get($"{Configuration.TEST_SERVER_URL}/api/webserver/");
JObject webserver = client.Get($"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/");
string ccsLink = Utils.GetLink(webserver, "central_certificates");
return client.Delete(ccsLink);
}
@ -225,7 +225,7 @@ namespace Microsoft.IIS.Administration.Tests
private JObject GetCcs()
{
using (var client = ApiHttpClient.Create()) {
JObject webserver = client.Get($"{Configuration.TEST_SERVER_URL}/api/webserver/");
JObject webserver = client.Get($"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/");
return Utils.FollowLink(client, webserver, "central_certificates");
}
}
@ -338,7 +338,7 @@ namespace Microsoft.IIS.Administration.Tests
private static Task CreateLocalUser(string username, string password)
{
var createScriptLocation = Path.Combine(Configuration.PROJECT_PATH, "scripts", "tests", "Create-User.ps1");
var createScriptLocation = Path.Combine(Configuration.Instance().PROJECT_PATH, "scripts", "tests", "Create-User.ps1");
// User creation already implemented in powershell install scripts, vs many interop calls
return RunProcess("PowerShell.exe", $@"""{createScriptLocation}"" -Name '{username}' -Password '{password}'");
}

Просмотреть файл

@ -12,11 +12,19 @@ namespace Microsoft.IIS.Administration.Tests
using System.Net.Http;
using Web.Administration;
using Xunit;
using Xunit.Abstractions;
public class Compression
{
public const string TEST_SITE_NAME = "compression_test_site";
public static readonly string COMPRESSION_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/http-response-compression";
public static readonly string COMPRESSION_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/http-response-compression";
private ITestOutputHelper _output;
public Compression(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void ChangeAllProperties()
@ -31,7 +39,7 @@ namespace Microsoft.IIS.Administration.Tests
// Site Scope
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 53010, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 53010, Sites.TEST_SITE_PATH);
JObject siteFeature = GetCompressionFeature(client, site.Value<string>("name"), null);
SetCompressionOverrideMode(client, siteFeature, OverrideMode.Allow);

Просмотреть файл

@ -7,36 +7,47 @@ namespace Microsoft.IIS.Administration.Tests {
using System;
using System.IO;
public static class Configuration {
private static JObject _config;
static Configuration() {
Initialize();
public class Configuration {
private static Configuration _instance;
public static Configuration Instance()
{
return _instance ?? (_instance = new Configuration());
}
public static string TEST_SERVER {
get {
private JObject _config;
public Configuration()
{
var content = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "test.config.json"));
_config = JObject.Parse(content);
}
public string TEST_SERVER {
get {
return _config.Value<string>("test_server");
}
}
public static string TEST_PORT {
get {
public string TEST_PORT {
get {
return _config.Value<string>("test_port");
}
}
public static string TEST_SERVER_URL {
public string TEST_SERVER_URL {
get {
return $"{TEST_SERVER}:{TEST_PORT}";
}
}
public static string TEST_ROOT_PATH {
get {
public string TEST_ROOT_PATH {
get
{
var val = _config.Value<string>("test_root_path");
if (string.IsNullOrEmpty(val)) {
if (string.IsNullOrEmpty(val))
{
val = AppContext.BaseDirectory;
}
@ -44,7 +55,7 @@ namespace Microsoft.IIS.Administration.Tests {
}
}
public static string PROJECT_PATH
public string PROJECT_PATH
{
get
{
@ -59,17 +70,12 @@ namespace Microsoft.IIS.Administration.Tests {
}
}
public static JObject Raw {
get {
return _config;
}
}
private static void Initialize() {
var content = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "test.config.json"));
_config = JObject.Parse(content);
public string CCSUser
{
get
{
return _config.Value<string>("ccs_user") ?? "IisAdminCcsTestR";
}
}
}
}

Просмотреть файл

@ -16,7 +16,7 @@ namespace Microsoft.IIS.Administration.Tests
{
using (HttpClient client = ApiHttpClient.Create()) {
HttpRequestMessage message = new HttpRequestMessage(new HttpMethod("OPTIONS"), $"{Configuration.TEST_SERVER_URL}/api");
HttpRequestMessage message = new HttpRequestMessage(new HttpMethod("OPTIONS"), $"{Configuration.Instance().TEST_SERVER_URL}/api");
message.Headers.Add("Access-Control-Request-Headers", "X-PINGOTHER");
message.Headers.Add("Access-Control-Request-Method", "GET");

Просмотреть файл

@ -11,12 +11,20 @@ namespace Microsoft.IIS.Administration.Tests
using System.Linq;
using System.Net.Http;
using Xunit;
using Xunit.Abstractions;
public class DefaultDocument
{
private const string TEST_SITE_NAME = "def_doc_test_site";
public static readonly string DEFAULT_DOCUMENT_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/default-documents";
public static readonly string DEFAULT_DOCUMENT_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/default-documents";
private ITestOutputHelper _output;
public DefaultDocument(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void Scope()
@ -24,7 +32,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50311, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50311, Sites.TEST_SITE_PATH);
JObject serverDoc = GetDefaultDocumentFeature(client, null, null);
JObject siteDoc = GetDefaultDocumentFeature(client, site.Value<string>("name"), null);
@ -63,7 +71,7 @@ namespace Microsoft.IIS.Administration.Tests
// Site Scope
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50311, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50311, Sites.TEST_SITE_PATH);
JObject siteFeature = GetDefaultDocumentFeature(client, site.Value<string>("name"), null);
Assert.NotNull(siteFeature);
@ -149,7 +157,7 @@ namespace Microsoft.IIS.Administration.Tests
throw new ArgumentException("docFeature");
}
string filesLink = $"{Configuration.TEST_SERVER_URL}{ docFeature["_links"]["files"].Value<string>("href") }";
string filesLink = $"{Configuration.Instance().TEST_SERVER_URL}{ docFeature["_links"]["files"].Value<string>("href") }";
dynamic feature = new JObject();
feature.id = featureUuid;

Просмотреть файл

@ -10,13 +10,21 @@ namespace Microsoft.IIS.Administration.Tests
using System.Collections.Generic;
using System.Net.Http;
using Xunit;
using Xunit.Abstractions;
public class Delegation
{
public static readonly string DelegationSectionsUri = $"{Configuration.TEST_SERVER_URL}/api/webserver/feature-delegation";
public static readonly string DelegationSectionsUri = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/feature-delegation";
private const string TEST_SITE_NAME = "delegation_test_site";
private ITestOutputHelper _output;
public Delegation(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void SectionLocked()
{
@ -106,7 +114,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
foreach (DelegatableFeature f in features) {
@ -143,7 +151,7 @@ namespace Microsoft.IIS.Administration.Tests
// Try to get the feature at site level, this should result in a feature locked error because the override mode at server
// level is deny
var response = client.GetAsync($"{Configuration.TEST_SERVER_URL}{f.Path}?scope={TEST_SITE_NAME}").Result;
var response = client.GetAsync($"{Configuration.Instance().TEST_SERVER_URL}{f.Path}?scope={TEST_SITE_NAME}").Result;
// Check for proper status code for feature locked error
Assert.True(response.StatusCode == System.Net.HttpStatusCode.Forbidden);
@ -243,7 +251,7 @@ namespace Microsoft.IIS.Administration.Tests
}
string content;
if (!client.Get($"{Configuration.TEST_SERVER_URL}" + feature.Path + "?scope=" + siteName + path, out content)) {
if (!client.Get($"{Configuration.Instance().TEST_SERVER_URL}" + feature.Path + "?scope=" + siteName + path, out content)) {
return null;
}

Просмотреть файл

@ -9,12 +9,20 @@ namespace Microsoft.IIS.Administration.Tests
using System;
using System.Net.Http;
using Xunit;
using Xunit.Abstractions;
public class DirectoryBrowsing
{
private const string TEST_SITE_NAME = "dirbro_test_site";
public static readonly string DIRECTORY_BROWSING_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/directory-browsing";
public static readonly string DIRECTORY_BROWSING_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/directory-browsing";
private ITestOutputHelper _output;
public DirectoryBrowsing(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void ChangeAllProperties()
@ -23,7 +31,7 @@ namespace Microsoft.IIS.Administration.Tests
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50310, Sites.TEST_SITE_PATH);
JObject feature = GetDirectoryBrowsingFeatrue(client, site.Value<string>("name"), null);
Assert.NotNull(feature);

Просмотреть файл

@ -18,6 +18,7 @@ namespace Microsoft.IIS.Administration.Tests
using System.Threading.Tasks;
using Web.Administration;
using Xunit;
using Xunit.Abstractions;
public class Files
{
@ -27,6 +28,13 @@ namespace Microsoft.IIS.Administration.Tests
private const string LOCATIONS_PATH = "/api/files/locations";
private const string WEBSERVER_FILES_PATH = "/api/webserver/files";
private ITestOutputHelper _output;
public Files(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void ResolveApplication()
{
@ -217,8 +225,8 @@ namespace Microsoft.IIS.Administration.Tests
[Fact]
public void CreateEditDeleteFile()
{
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(client))
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
@ -259,7 +267,7 @@ namespace Microsoft.IIS.Administration.Tests
var location = locationHeader.First();
// Download file
Assert.True(client.Get($"{Configuration.TEST_SERVER_URL}{location}", out result));
Assert.True(client.Get($"{Configuration.Instance().TEST_SERVER_URL}{location}", out result));
Assert.True(result == testContent);
// Update file with empty content
@ -284,8 +292,8 @@ namespace Microsoft.IIS.Administration.Tests
string testContent = "Test content for copying files.";
JObject copyInfo = null;
using (HttpClient client = ApiHttpClient.Create())
using(TestSiteContainer container = new TestSiteContainer(client))
using (HttpClient client = ApiHttpClient.Create())
using(TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
@ -295,7 +303,7 @@ namespace Microsoft.IIS.Administration.Tests
var physicalPath = Environment.ExpandEnvironmentVariables(webFile["file_info"].Value<string>("physical_path"));
File.WriteAllText(physicalPath, testContent);
try
try
{
var fileInfo = Utils.FollowLink(client, webFile.Value<JObject>("file_info"), "self");
var parent = fileInfo.Value<JObject>("parent");
@ -314,7 +322,7 @@ namespace Microsoft.IIS.Administration.Tests
//
// Wait for copy to finish
HttpResponseMessage res = null;
do
do
{
res = client.GetAsync(Utils.Self(copyInfo)).Result;
} while (res.StatusCode == HttpStatusCode.OK);
@ -328,13 +336,13 @@ namespace Microsoft.IIS.Administration.Tests
Assert.Equal(copyContent, testContent);
}
finally
finally
{
if (webFile != null && webFile["file_info"] != null)
if (webFile != null && webFile["file_info"] != null)
{
Assert.True(client.Delete(Utils.Self(webFile.Value<JObject>("file_info"))));
}
if (copyInfo != null)
if (copyInfo != null)
{
Assert.True(client.Delete(Utils.Self(copyInfo.Value<JObject>("file"))));
}
@ -347,15 +355,15 @@ namespace Microsoft.IIS.Administration.Tests
{
string startName = "move_dir_test";
string destName = "move_dir_dest";
var physicalPath = Path.Combine(Configuration.TEST_ROOT_PATH, startName);
var destPhysicalPath = Path.Combine(Configuration.TEST_ROOT_PATH, destName);
var physicalPath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, startName);
var destPhysicalPath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, destName);
CreateTestDirectory(physicalPath);
JObject site = null;
using (HttpClient client = ApiHttpClient.Create()) {
Sites.EnsureNoSite(client, FILE_TEST_SITE_NAME);
site = Sites.CreateSite(client, FILE_TEST_SITE_NAME, Utils.GetAvailablePort(), physicalPath);
site = Sites.CreateSite(_output, client, FILE_TEST_SITE_NAME, Utils.GetAvailablePort(), physicalPath);
try {
var rootDir = Utils.FollowLink(client, site, "files");
@ -396,15 +404,15 @@ namespace Microsoft.IIS.Administration.Tests
{
string startName = "copy_dir_test";
string destName = "copy_dir_dest";
var physicalPath = Path.Combine(Configuration.TEST_ROOT_PATH, startName);
var destPhysicalPath = Path.Combine(Configuration.TEST_ROOT_PATH, destName);
var physicalPath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, startName);
var destPhysicalPath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, destName);
CreateTestDirectory(physicalPath);
JObject site = null;
using (HttpClient client = ApiHttpClient.Create()) {
Sites.EnsureNoSite(client, FILE_TEST_SITE_NAME);
site = Sites.CreateSite(client, FILE_TEST_SITE_NAME, Utils.GetAvailablePort(), physicalPath);
site = Sites.CreateSite(_output, client, FILE_TEST_SITE_NAME, Utils.GetAvailablePort(), physicalPath);
try {
var rootDir = Utils.FollowLink(client, site, "files");
@ -448,8 +456,8 @@ namespace Microsoft.IIS.Administration.Tests
[Fact]
public void RangeUploadDownload()
{
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(client))
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
@ -529,8 +537,8 @@ namespace Microsoft.IIS.Administration.Tests
}
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(client))
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
@ -574,8 +582,8 @@ namespace Microsoft.IIS.Administration.Tests
var size = 1024 * 1024 * 5;
var truncateSize = size / 2;
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(client))
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
@ -606,8 +614,8 @@ namespace Microsoft.IIS.Administration.Tests
[Fact]
public void CreateRenameFile()
{
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(client))
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
JObject target = null;
@ -633,9 +641,9 @@ namespace Microsoft.IIS.Administration.Tests
[Fact]
public void CreateRenameDirectory()
{
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(client))
{
using (HttpClient client = ApiHttpClient.Create())
using (TestSiteContainer container = new TestSiteContainer(_output, client))
{
JObject site = Sites.GetSite(client, container.SiteName);
JObject target = null;
@ -660,7 +668,7 @@ namespace Microsoft.IIS.Administration.Tests
[Fact]
public void CoreFileRange()
{
var physicalPath = Path.Combine(Configuration.TEST_ROOT_PATH, "api_file_range_test");
var physicalPath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, "api_file_range_test");
if (Directory.Exists(physicalPath)) {
Directory.Delete(physicalPath, true);
}
@ -678,7 +686,7 @@ namespace Microsoft.IIS.Administration.Tests
File.Create(Path.Combine(physicalPath, file)).Dispose();
}
JObject folder = client.Get($"{Configuration.TEST_SERVER_URL}/api/files?physical_path={physicalPath}");
JObject folder = client.Get($"{Configuration.Instance().TEST_SERVER_URL}/api/files?physical_path={physicalPath}");
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, Utils.GetLink(folder, "files"));
req.Headers.Add("Range", "files=1-3");
@ -700,7 +708,7 @@ namespace Microsoft.IIS.Administration.Tests
[Fact]
public void WebFileRange()
{
var physicalPath = Path.Combine(Configuration.TEST_ROOT_PATH, "web_file_range_test");
var physicalPath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, "web_file_range_test");
if (Directory.Exists(physicalPath)) {
Directory.Delete(physicalPath, true);
Directory.CreateDirectory(physicalPath);
@ -713,7 +721,7 @@ namespace Microsoft.IIS.Administration.Tests
var files = new List<string>() { "file1.txt", "file2.txt", "file3.txt", "file4.txt" };
Sites.EnsureNoSite(client, FILE_TEST_SITE_NAME);
site = Sites.CreateSite(client, FILE_TEST_SITE_NAME, Utils.GetAvailablePort(), physicalPath);
site = Sites.CreateSite(_output, client, FILE_TEST_SITE_NAME, Utils.GetAvailablePort(), physicalPath);
Assert.NotNull(site);
@ -775,7 +783,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
try {
location = client.Post($"{Configuration.TEST_SERVER_URL}{LOCATIONS_PATH}", body);
location = client.Post($"{Configuration.Instance().TEST_SERVER_URL}{LOCATIONS_PATH}", body);
Assert.Equal(location.Value<string>("alias"), string.Empty);
Assert.Equal(location.Value<string>("path"), physicalPath);
@ -783,11 +791,12 @@ namespace Microsoft.IIS.Administration.Tests
var claims = location["claims"].ToObject<IEnumerable<string>>();
Assert.True(Enumerable.SequenceEqual<string>(claims, new string[] { "read", "write" }));
expanded = client.Get($"{Configuration.TEST_SERVER_URL}{FILES_PATH}")["files"]
expanded = client.Get($"{Configuration.Instance().TEST_SERVER_URL}{FILES_PATH}")["files"]
.ToObject<IEnumerable<JObject>>()
.First(o => o.Value<string>("name").Equals(Path.GetFileName(physicalPath)))
.Value<string>("physical_path");
// Sometime this is delayed
Task.Delay(100).Wait();
Assert.True(Directory.Exists(expanded));
body = JObject.FromObject(new {
@ -806,7 +815,7 @@ namespace Microsoft.IIS.Administration.Tests
claims = location["claims"].ToObject<IEnumerable<string>>();
Assert.True(Enumerable.SequenceEqual<string>(claims, new string[] { "read" }));
expanded2 = client.Get($"{Configuration.TEST_SERVER_URL}{FILES_PATH}")["files"]
expanded2 = client.Get($"{Configuration.Instance().TEST_SERVER_URL}{FILES_PATH}")["files"]
.ToObject<IEnumerable<JObject>>()
.First(o => o.Value<string>("name").Equals(Path.GetFileName(physicalPath2)))
.Value<string>("physical_path");
@ -815,7 +824,7 @@ namespace Microsoft.IIS.Administration.Tests
client.Delete(Utils.Self(location));
var locationsObj = client.Get($"{Configuration.TEST_SERVER_URL}{LOCATIONS_PATH}");
var locationsObj = client.Get($"{Configuration.Instance().TEST_SERVER_URL}{LOCATIONS_PATH}");
IEnumerable<JObject> locations = locationsObj["locations"].ToObject<IEnumerable<JObject>>();
@ -952,7 +961,7 @@ namespace Microsoft.IIS.Administration.Tests
};
// Create web file
var file = client.Post($"{Configuration.TEST_SERVER_URL}{FILES_PATH}", newFile);
var file = client.Post($"{Configuration.Instance().TEST_SERVER_URL}{FILES_PATH}", newFile);
Assert.True(file != null);
@ -1026,29 +1035,29 @@ namespace Microsoft.IIS.Administration.Tests
}
}
class TestSiteContainer : IDisposable
{
class TestSiteContainer : IDisposable
{
public const string TEST_SITE_NAME = "test_site";
public const int TEST_PORT = 50306;
public static readonly string TEST_SITE_PATH = Path.Combine(Configuration.TEST_ROOT_PATH, TEST_SITE_NAME);
public static readonly string SITE_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/websites";
public readonly string SiteName = TEST_SITE_NAME;
private readonly string testSiteUri;
private readonly HttpClient client;
public TestSiteContainer(HttpClient client)
{
this.client = client;
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
Assert.NotNull(site);
testSiteUri = $"{SITE_URL}/{site.Value<string>("id")}";
}
public void Dispose()
{
Sites.DeleteSite(client, testSiteUri);
}
}
}
public const int TEST_PORT = 50306;
public static readonly string TEST_SITE_PATH = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, TEST_SITE_NAME);
public static readonly string SITE_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/websites";
public readonly string SiteName = TEST_SITE_NAME;
private readonly string testSiteUri;
private readonly HttpClient client;
public TestSiteContainer(ITestOutputHelper output, HttpClient client)
{
this.client = client;
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(output, client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
Assert.NotNull(site);
testSiteUri = $"{SITE_URL}/{site.Value<string>("id")}";
}
public void Dispose()
{
Sites.DeleteSite(client, testSiteUri);
}
}
}

Просмотреть файл

@ -10,15 +10,23 @@ namespace Microsoft.IIS.Administration.Tests
using System.Linq;
using System.Net.Http;
using Xunit;
using Xunit.Abstractions;
public class Handlers
{
public const string TEST_SITE_NAME = "handlers_test_site";
public static readonly string HANDLERS_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/http-handlers";
public static readonly string HANDLERS_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/http-handlers";
private const string allowedAccessProperty = "allowed_access";
private const string removePreventionProperty = "remote_access_prevention";
private ITestOutputHelper _output;
public Handlers(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void ChangeAllFeatureProperties()
{
@ -31,7 +39,7 @@ namespace Microsoft.IIS.Administration.Tests
TestScopedFeature(client, webserverFeature);
Sites.EnsureNoSite(client, TEST_SITE_NAME);
var site = Sites.CreateSite(client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
var site = Sites.CreateSite(_output, client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
Assert.NotNull(site);
try {
var siteFeature = Utils.GetFeature(client, HANDLERS_URL, site.Value<string>("name"), "/");

Просмотреть файл

@ -10,7 +10,7 @@ namespace Microsoft.IIS.Administration.Tests
public class HttpRedirect
{
private static readonly string ENDPOINT = Configuration.TEST_SERVER_URL + "/api/webserver/http-redirect";
private static readonly string ENDPOINT = Configuration.Instance().TEST_SERVER_URL + "/api/webserver/http-redirect";
[Fact]
public void ChangeAllProperties()

Просмотреть файл

@ -46,12 +46,12 @@ namespace Microsoft.IIS.Administration.Tests
if (!installed) {
_logger.WriteLine("Installing " + feature);
Assert.True(client.Post(Configuration.TEST_SERVER_URL + feature, "", out result));
Assert.True(client.Post(Configuration.Instance().TEST_SERVER_URL + feature, "", out result));
Assert.True(IsInstalled(feature, client));
}
_logger.WriteLine("retrieving settings for " + feature);
var settings = client.Get(Configuration.TEST_SERVER_URL + feature + "?scope=");
var settings = client.Get(Configuration.Instance().TEST_SERVER_URL + feature + "?scope=");
_logger.WriteLine("Uninstalling " + feature);
Assert.True(client.Delete(Utils.Self(settings)));
@ -59,7 +59,7 @@ namespace Microsoft.IIS.Administration.Tests
if (installed) {
_logger.WriteLine("Reinstalling " + feature);
Assert.True(client.Post(Configuration.TEST_SERVER_URL + feature, "", out result));
Assert.True(client.Post(Configuration.Instance().TEST_SERVER_URL + feature, "", out result));
Assert.True(IsInstalled(feature, client));
}
}
@ -67,7 +67,7 @@ namespace Microsoft.IIS.Administration.Tests
private bool IsInstalled(string feature, HttpClient client)
{
var res = client.GetAsync(Configuration.TEST_SERVER_URL + feature + "?scope=").Result;
var res = client.GetAsync(Configuration.Instance().TEST_SERVER_URL + feature + "?scope=").Result;
return res.StatusCode != HttpStatusCode.NotFound;
}
}

Просмотреть файл

@ -11,7 +11,7 @@ namespace Microsoft.IIS.Administration.Tests
using Xunit;
public class IpRestrictions
{
public static readonly string IP_RESTRICTIONS_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/ip-restrictions";
public static readonly string IP_RESTRICTIONS_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/ip-restrictions";
[Fact]
public void ChangeAllProperties()

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft.IIS.Administration.Tests
public class Logging
{
public static readonly string LOGGING_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/logging";
public static readonly string LOGGING_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/logging";
[Fact]
public void TestCustomFields()

Просмотреть файл

@ -16,7 +16,7 @@ namespace Microsoft.IIS.Administration.Tests
{
using (HttpClient client = ApiHttpClient.Create()) {
var req = new HttpRequestMessage(new HttpMethod("GET"), $"{Configuration.TEST_SERVER_URL}{resourceEndpoint}");
var req = new HttpRequestMessage(new HttpMethod("GET"), $"{Configuration.Instance().TEST_SERVER_URL}{resourceEndpoint}");
var res = client.SendAsync(req).Result;
@ -24,7 +24,7 @@ namespace Microsoft.IIS.Administration.Tests
Assert.NotEqual(getContent, string.Empty);
req = new HttpRequestMessage(new HttpMethod("HEAD"), $"{Configuration.TEST_SERVER_URL}{resourceEndpoint}");
req = new HttpRequestMessage(new HttpMethod("HEAD"), $"{Configuration.Instance().TEST_SERVER_URL}{resourceEndpoint}");
res = client.SendAsync(req).Result;

Просмотреть файл

@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\build\version.props" />
<Import Project="..\..\build\version.props" />
<PropertyGroup>
<Description>Tests Class Library</Description>
@ -18,11 +18,11 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\src\Microsoft.IIS.Administration.Core\Microsoft.IIS.Administration.Core.csproj" />
<ProjectReference Include="$(SolutionDir)\src\Microsoft.IIS.Administration.Files.Core\Microsoft.IIS.Administration.Files.Core.csproj" />
<ProjectReference Include="$(SolutionDir)\src\Microsoft.IIS.Administration.Files\Microsoft.IIS.Administration.Files.csproj" />
<ProjectReference Include="$(SolutionDir)\src\Microsoft.IIS.Administration.WebServer.Files\Microsoft.IIS.Administration.WebServer.Files.csproj" />
<ProjectReference Include="$(SolutionDir)\src\Microsoft.IIS.Administration.WebServer\Microsoft.IIS.Administration.WebServer.csproj" />
<ProjectReference Include="..\..\src\Microsoft.IIS.Administration.Core\Microsoft.IIS.Administration.Core.csproj" />
<ProjectReference Include="..\..\src\Microsoft.IIS.Administration.Files.Core\Microsoft.IIS.Administration.Files.Core.csproj" />
<ProjectReference Include="..\..\src\Microsoft.IIS.Administration.Files\Microsoft.IIS.Administration.Files.csproj" />
<ProjectReference Include="..\..\src\Microsoft.IIS.Administration.WebServer.Files\Microsoft.IIS.Administration.WebServer.Files.csproj" />
<ProjectReference Include="..\..\src\Microsoft.IIS.Administration.WebServer\Microsoft.IIS.Administration.WebServer.csproj" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -14,8 +14,8 @@ namespace Microsoft.IIS.Administration.Tests
public class Modules
{
public static readonly string GLOBAL_MODULES_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/global-modules";
public static readonly string MODULES_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/http-modules";
public static readonly string GLOBAL_MODULES_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/global-modules";
public static readonly string MODULES_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/http-modules";
[Fact]
public void AddRemoveManagedModuleEntry()

Просмотреть файл

@ -19,7 +19,7 @@ namespace Microsoft.IIS.Administration.Tests
public class Monitoring
{
private const string SiteName = "ServerMonitorTestSite";
private static readonly string SitePath = Path.Combine(Configuration.TEST_ROOT_PATH, SiteName);
private static readonly string SitePath = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, SiteName);
private ITestOutputHelper _output;
@ -36,7 +36,7 @@ namespace Microsoft.IIS.Administration.Tests
int port = Utils.GetAvailablePort();
JObject site = Sites.CreateSite(client, SiteName, port, SitePath);
JObject site = Sites.CreateSite(_output, client, SiteName, port, SitePath);
try {
using (var stresser = new SiteStresser($"http://localhost:{port}"))
@ -95,7 +95,7 @@ namespace Microsoft.IIS.Administration.Tests
int port = Utils.GetAvailablePort();
JObject site = Sites.CreateSite(client, SiteName, port, SitePath);
JObject site = Sites.CreateSite(_output, client, SiteName, port, SitePath);
try {
using (var stresser = new SiteStresser($"http://localhost:{port}"))
@ -187,7 +187,7 @@ namespace Microsoft.IIS.Administration.Tests
if (site == null) {
site = Sites.CreateSite(client, name, Utils.GetAvailablePort(), SitePath, true, pools[i]);
site = Sites.CreateSite(_output, client, name, Utils.GetAvailablePort(), SitePath, true, pools[i]);
}
sites[i] = site;
@ -277,7 +277,7 @@ namespace Microsoft.IIS.Administration.Tests
JObject site = Sites.GetSite(client, name);
if (site == null) {
site = Sites.CreateSite(client, name, Utils.GetAvailablePort(), SitePath, true, pool);
site = Sites.CreateSite(_output, client, name, Utils.GetAvailablePort(), SitePath, true, pool);
}
int port = site["bindings"].ToObject<IEnumerable<JObject>>().First().Value<int>("port");
@ -333,7 +333,7 @@ namespace Microsoft.IIS.Administration.Tests
int port = Utils.GetAvailablePort();
JObject site = Sites.CreateSite(client, SiteName, port, SitePath);
JObject site = Sites.CreateSite(_output, client, SiteName, port, SitePath);
try {
JObject appPool = client.Get(Utils.Self((JObject)site["application_pool"]));
@ -388,7 +388,7 @@ namespace Microsoft.IIS.Administration.Tests
private bool _stop = false;
private Task _t;
private JObject _snapshot;
private string _url = $"{Configuration.TEST_SERVER_URL}/api/webserver/monitoring";
private string _url = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/monitoring";
public ServerMonitor(string url = null)
{

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft.IIS.Administration.Tests
public class RequestFiltering
{
public static readonly string REQUEST_FILTERING_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/http-request-filtering";
public static readonly string REQUEST_FILTERING_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/http-request-filtering";
[Fact]

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.IIS.Administration.Tests
public class RequestTracing
{
public static readonly string REQUEST_TRACING_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/http-request-tracing";
public static readonly string REQUEST_TRACING_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/http-request-tracing";
[Fact]
public void CreatePatchRemoveRule()

Просмотреть файл

@ -26,9 +26,10 @@ namespace Microsoft.IIS.Administration.Tests
private const int TEST_PORT = 50306;
private ITestOutputHelper _output;
public static readonly string TEST_SITE_PATH = Path.Combine(Configuration.TEST_ROOT_PATH, TEST_SITE_NAME);
public static readonly string SITE_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/websites";
public static readonly string CertificatesUrl = $"{Configuration.TEST_SERVER_URL}/api/certificates";
public static readonly string TEST_SITE_PATH = Path.Combine(Configuration.Instance().TEST_ROOT_PATH, TEST_SITE_NAME);
public static readonly string SITE_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/websites";
public static readonly string CertificatesUrl = $"{Configuration.Instance().TEST_SERVER_URL}/api/certificates";
public Sites(ITestOutputHelper output)
{
@ -42,7 +43,7 @@ namespace Microsoft.IIS.Administration.Tests
EnsureNoSite(client, TEST_SITE_NAME);
JObject site = CreateSite(client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
JObject site = CreateSite(_output, client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
Assert.NotNull(site);
_output.WriteLine("Create Site success.");
@ -63,7 +64,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
EnsureNoSite(client, TEST_SITE_NAME);
JObject site = CreateSite(client, TEST_SITE_NAME, TEST_PORT, Configuration.TEST_ROOT_PATH);
JObject site = CreateSite(_output, client, TEST_SITE_NAME, TEST_PORT, Configuration.Instance().TEST_ROOT_PATH);
JObject cachedSite = new JObject(site);
WaitForStatus(client, ref site);
@ -71,7 +72,7 @@ namespace Microsoft.IIS.Administration.Tests
Assert.True(site != null);
site["server_auto_start"] = !site.Value<bool>("server_auto_start");
site["physical_path"] = Configuration.TEST_ROOT_PATH;
site["physical_path"] = Configuration.Instance().TEST_ROOT_PATH;
site["enabled_protocols"] = site.Value<string>("enabled_protocols").Equals("http", StringComparison.OrdinalIgnoreCase) ? "https" : "http";
// If site status is unknown then we don't know if it will be started or stopped when it becomes available
@ -149,7 +150,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
EnsureNoSite(client, TEST_SITE_NAME);
JObject site = CreateSite(client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
JObject site = CreateSite(_output, client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
var bindings = site.Value<JArray>("bindings");
bindings.Clear();
@ -214,7 +215,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
EnsureNoSite(client, TEST_SITE_NAME);
JObject site = CreateSite(client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
JObject site = CreateSite(_output, client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
var bindings = site.Value<JArray>("bindings");
bindings.Clear();
@ -326,7 +327,7 @@ namespace Microsoft.IIS.Administration.Tests
using (HttpClient client = ApiHttpClient.Create()) {
EnsureNoSite(client, TEST_SITE_NAME);
JObject site = CreateSite(client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
JObject site = CreateSite(_output, client, TEST_SITE_NAME, TEST_PORT, TEST_SITE_PATH);
var bindings = site.Value<JArray>("bindings");
bindings.Clear();
@ -441,13 +442,16 @@ namespace Microsoft.IIS.Administration.Tests
}
}
private static bool CreateSite(HttpClient client, string testSite, out JObject site, bool createDirectoryIfNotExist = true)
private static bool CreateSite(ITestOutputHelper output, HttpClient client, string testSite, out JObject site, bool createDirectoryIfNotExist = true)
{
site = null;
HttpContent content = new StringContent(testSite, Encoding.UTF8, "application/json");
HttpResponseMessage response = client.PostAsync(SITE_URL, content).Result;
if (!Globals.Success(response)) {
if (!Globals.Success(response))
{
output.WriteLine("Non-Success response:");
output.WriteLine(response.Content.ReadAsStringAsync().Result);
return false;
}
@ -456,7 +460,7 @@ namespace Microsoft.IIS.Administration.Tests
return true;
}
public static JObject CreateSite(HttpClient client, string name, int port, string physicalPath, bool createDirectoryIfNotExist = true, JObject appPool = null)
public static JObject CreateSite(ITestOutputHelper output, HttpClient client, string name, int port, string physicalPath, bool createDirectoryIfNotExist = true, JObject appPool = null)
{
if (createDirectoryIfNotExist && !Directory.Exists(physicalPath)) {
Directory.CreateDirectory(physicalPath);
@ -492,7 +496,7 @@ namespace Microsoft.IIS.Administration.Tests
JObject result;
if(!CreateSite(client, siteStr, out result)) {
if(!CreateSite(output, client, siteStr, out result)) {
throw new Exception();
}

Просмотреть файл

@ -12,7 +12,7 @@ namespace Microsoft.IIS.Administration.Tests
public class StaticContent
{
public static readonly string STATIC_CONTENT_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/static-content";
public static readonly string STATIC_CONTENT_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/static-content";
[Fact]
public void ChangeAllProperties()

Просмотреть файл

@ -9,12 +9,20 @@ namespace Microsoft.IIS.Administration.Tests
using System.Net.Http;
using System.Text;
using Xunit;
using Xunit.Abstractions;
public class Transactions
{
private const string TRANSACTION_SITE_NAME = "trans_site";
public const string TRANSACTION_HEADER = "Transaction-Id";
public static readonly string TRANSACTIONS_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/transactions";
public static readonly string TRANSACTIONS_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/transactions";
private ITestOutputHelper _output;
public Transactions(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void UseTransactionManipulateSite()
@ -25,7 +33,7 @@ namespace Microsoft.IIS.Administration.Tests
Sites.EnsureNoSite(client, TRANSACTION_SITE_NAME);
// Create the site we will be manipulating to test transactions
JObject site = Sites.CreateSite(client, TRANSACTION_SITE_NAME, 50000, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TRANSACTION_SITE_NAME, 50000, Sites.TEST_SITE_PATH);
Assert.NotNull(site);
// Cache the value of the property we will be manipulating through a transaciton
@ -110,7 +118,7 @@ namespace Microsoft.IIS.Administration.Tests
Sites.EnsureNoSite(client, TRANSACTION_SITE_NAME);
// Create the site we will be manipulating to test transactions
JObject site = Sites.CreateSite(client, TRANSACTION_SITE_NAME, 50000, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TRANSACTION_SITE_NAME, 50000, Sites.TEST_SITE_PATH);
Assert.NotNull(site);
// Create a transaction

Просмотреть файл

@ -11,11 +11,19 @@ namespace Microsoft.IIS.Administration.Tests
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
public class UrlRewrite
{
private const string TEST_SITE_NAME = "Rewrite Test Site";
private static readonly string REWRITE_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/url-rewrite";
private static readonly string REWRITE_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/url-rewrite";
private ITestOutputHelper _output;
public UrlRewrite(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public async Task CreateAndUpdateInboundRule()
@ -25,7 +33,7 @@ namespace Microsoft.IIS.Administration.Tests
await EnsureEnabled(client);
Sites.EnsureNoSite(client, TEST_SITE_NAME);
var site = Sites.CreateSite(client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
var site = Sites.CreateSite(_output, client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
Assert.NotNull(site);
try {
@ -738,7 +746,7 @@ namespace Microsoft.IIS.Administration.Tests
await EnsureEnabled(client);
Sites.EnsureNoSite(client, TEST_SITE_NAME);
var site = Sites.CreateSite(client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
var site = Sites.CreateSite(_output, client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
Assert.NotNull(site);
try {
@ -869,7 +877,7 @@ namespace Microsoft.IIS.Administration.Tests
await EnsureEnabled(client);
Sites.EnsureNoSite(client, TEST_SITE_NAME);
var site = Sites.CreateSite(client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
var site = Sites.CreateSite(_output, client, TEST_SITE_NAME, Utils.GetAvailablePort(), Sites.TEST_SITE_PATH);
Assert.NotNull(site);
try {

Просмотреть файл

@ -83,7 +83,7 @@ namespace Microsoft.IIS.Administration.Tests
}
string content;
if (!client.Get($"{Configuration.TEST_SERVER_URL}{ href }", out content)) {
if (!client.Get($"{Configuration.Instance().TEST_SERVER_URL}{ href }", out content)) {
return null;
}
@ -97,7 +97,7 @@ namespace Microsoft.IIS.Administration.Tests
public static string GetLink(JObject obj, string linkName)
{
string link = $"{Configuration.TEST_SERVER_URL}{ obj["_links"][linkName].Value<string>("href") }";
string link = $"{Configuration.Instance().TEST_SERVER_URL}{ obj["_links"][linkName].Value<string>("href") }";
if (link == null) {
throw new Exception();

Просмотреть файл

@ -18,7 +18,7 @@ namespace Microsoft.IIS.Administration.Tests
private const string TEST_SITE_NAME = "test_vdir_site";
ITestOutputHelper _output;
public static readonly string VDIR_URL = $"{Configuration.TEST_SERVER_URL}/api/webserver/virtual-directories";
public static readonly string VDIR_URL = $"{Configuration.Instance().TEST_SERVER_URL}/api/webserver/virtual-directories";
public static readonly string TEST_VDIR_PATH = "/test_vdir";
public static readonly string TEST_VDIR_PHYSICAL_PATH = Path.Combine(Sites.TEST_SITE_PATH, "test_vdir");
@ -35,7 +35,7 @@ namespace Microsoft.IIS.Administration.Tests
Sites.EnsureNoSite(client, TEST_SITE_NAME);
JObject site = Sites.CreateSite(client, TEST_SITE_NAME, 50308, Sites.TEST_SITE_PATH);
JObject site = Sites.CreateSite(_output, client, TEST_SITE_NAME, 50308, Sites.TEST_SITE_PATH);
if (site != null) {