Update test config.
This commit is contained in:
Родитель
bc7e261b5b
Коммит
08f9ac2eab
15
appveyor.yml
15
appveyor.yml
|
@ -1,12 +1,15 @@
|
|||
version: 1.0.{build}
|
||||
clone_folder: '%iis_admin_solution_dir%'
|
||||
init:
|
||||
- cmd: >
|
||||
npm install -g bower
|
||||
- ps: >
|
||||
git config --global core.autocrlf true;
|
||||
setx iis_admin_solution_dir $env:iis_admin_solution_dir /m;
|
||||
npm install -g bower;
|
||||
setx iis_admin_test_dir $env:iis_admin_test_dir /m;
|
||||
environment:
|
||||
iis_admin_solution_dir: c:\src\repos\IIS.Administration
|
||||
iis_admin_test_dir: c:\tests\iisadmin
|
||||
publish_out_dir: '%iis_admin_solution_dir%\bin\publish_out'
|
||||
services: iis
|
||||
before_build:
|
||||
|
@ -15,8 +18,8 @@ build:
|
|||
verbosity: minimal
|
||||
after_build:
|
||||
- ps: >
|
||||
& "$env:iis_admin_solution_dir\scripts\Configure-DevEnvironment.ps1";
|
||||
& "$env:iis_admin_solution_dir\scripts\publish\publish.ps1" -OutputPath $env:publish_out_dir -SkipRestore -SkipPrompt;
|
||||
& "$env:iis_admin_solution_dir\scripts\Configure-DevEnvironment.ps1" -ConfigureTestEnvironment;
|
||||
& "$env:iis_admin_solution_dir\scripts\publish\publish.ps1" -OutputPath $env:publish_out_dir -SkipPrompt;
|
||||
Get-WindowsOptionalFeature -Online | where {$_.FeatureName -match "IIS-" -and $_.State -eq [Microsoft.Dism.Commands.FeatureState]::Disabled} | % {Enable-WindowsOptionalFeature -Online -FeatureName $_.FeatureName};
|
||||
& "$env:publish_out_dir\setup\setup.ps1" Install -Verbose -Port 44326;
|
||||
$appsettings = Get-ChildItem -Recurse 'C:\Program Files\IIS Administration\' appsettings.json;
|
||||
|
@ -24,11 +27,11 @@ after_build:
|
|||
Push-Location $securityScript.Directory;
|
||||
.\security.ps1 Add-SelfRights -Path $appsettings.FullName;
|
||||
Pop-Location;
|
||||
Copy-Item "$env:iis_admin_solution_dir\src\Microsoft.IIS.Administration\config\appsettings.json" $appsettings.FullName -force;
|
||||
[System.IO.File]::ReadAllText("$env:iis_admin_solution_dir\test\appsettings.test.json").replace("IIS Administrators", [System.Security.Principal.WindowsIdentity]::GetCurrent().Name.Replace('\', '\\')) | Out-File $appsettings.FullName;
|
||||
Restart-Service "Microsoft IIS Administration";
|
||||
test_script:
|
||||
- ps: dotnet test "$env:iis_admin_solution_dir\test\Microsoft.IIS.Administration.Tests"
|
||||
- ps: dotnet test "$env:iis_admin_solution_dir\test\Microsoft.IIS.Administration.Tests\Microsoft.IIS.Administration.Tests.csproj"
|
||||
artifacts:
|
||||
- path: bin\publish_out
|
||||
name: IIS Administration
|
||||
type: zip
|
||||
type: zip
|
|
@ -127,7 +127,7 @@ function Write-AppSettings($_appSettingsPath, $_port) {
|
|||
$settings.security.users.owners += $(.\security.ps1 CurrentAdUser)
|
||||
|
||||
if ($_port -ne $null -and $_port -ne $(.\globals.ps1 DEFAULT_PORT)) {
|
||||
$settings.urls = "https://*:$_port"
|
||||
.\json.ps1 Add-Property -JsonObject $settings -Name "urls" -Value "https://*:$_port"
|
||||
}
|
||||
|
||||
.\json.ps1 Set-JsonContent -Path $AppSettingsPath -JsonObject $settings
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
Param(
|
||||
[string]
|
||||
$Name,
|
||||
|
||||
[string]
|
||||
$Password
|
||||
)
|
||||
|
||||
# Find ccs test user
|
||||
$localUsers = Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount = True"
|
||||
$certUser = $localUsers | Where-Object {$_.Caption -match "$Name"}
|
||||
$userExists = $certUser -ne $null
|
||||
$Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer"
|
||||
|
||||
if ($userExists) {
|
||||
$Computer.Delete("User", $Name)
|
||||
}
|
||||
|
||||
$ccsUser = $Computer.Create("User", $Name)
|
||||
$ccsUser.SetPassword($Password)
|
||||
$ccsUser.SetInfo()
|
||||
$ccsUser.FullName = "Test account for IIS Administration API"
|
||||
$ccsUser.SetInfo()
|
||||
$ccsUser.UserFlags = 64 + 65536 # ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD
|
||||
$ccsUser.SetInfo()
|
|
@ -60,9 +60,11 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
|
||||
CcsUser user = await CcsUser.Get();
|
||||
|
||||
dynamic ccsInfo = new {
|
||||
dynamic ccsInfo = new
|
||||
{
|
||||
path = path,
|
||||
identity = new {
|
||||
identity = new
|
||||
{
|
||||
username = user.Username,
|
||||
password = user.Password
|
||||
},
|
||||
|
@ -73,7 +75,7 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
JObject webserver = client.Get($"{Configuration.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);
|
||||
Assert.True((int)res.StatusCode == 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +85,11 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
RequireCcsTestInfrastructure();
|
||||
Assert.True(Disable());
|
||||
|
||||
dynamic ccsInfo = new {
|
||||
dynamic ccsInfo = new
|
||||
{
|
||||
path = FOLDER_PATH,
|
||||
identity = new {
|
||||
identity = new
|
||||
{
|
||||
username = CcsTestUsername,
|
||||
password = "fgsfds"
|
||||
},
|
||||
|
@ -191,9 +195,11 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
|
||||
private bool Enable(string physicalPath, string username, string password, string privateKeyPassword)
|
||||
{
|
||||
dynamic ccsInfo = new {
|
||||
dynamic ccsInfo = new
|
||||
{
|
||||
path = physicalPath,
|
||||
identity = new {
|
||||
identity = new
|
||||
{
|
||||
username = username,
|
||||
password = password
|
||||
},
|
||||
|
@ -203,7 +209,7 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
using (var client = ApiHttpClient.Create()) {
|
||||
JObject webserver = client.Get($"{Configuration.TEST_SERVER_URL}/api/webserver/");
|
||||
string ccsLink = Utils.GetLink(webserver, "central_certificates");
|
||||
return client.Post(ccsLink, (object) ccsInfo) != null;
|
||||
return client.Post(ccsLink, (object)ccsInfo) != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +292,7 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
return loggedOn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -326,35 +332,15 @@ namespace Microsoft.IIS.Administration.Tests
|
|||
user.Username = CentralCertificates.CcsTestUsername;
|
||||
user.Password = Guid.NewGuid().ToString();
|
||||
|
||||
try {
|
||||
await GetLocalUser(user.Username);
|
||||
await RemoveLocalUser(user.Username);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
|
||||
await CreateLocalUser(user.Username, user.Password);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public void GetAccess(string path)
|
||||
{
|
||||
}
|
||||
|
||||
private static Task GetLocalUser(string username)
|
||||
{
|
||||
return RunProcess("PowerShell.exe", $"Get-LocalUser -Name {username}");
|
||||
}
|
||||
|
||||
private static Task CreateLocalUser(string username, string password)
|
||||
{
|
||||
return RunProcess("PowerShell.exe", $"New-LocalUser -Name {username} -Password $(ConvertTo-SecureString -AsPlainText -Force '{password}')");
|
||||
}
|
||||
|
||||
private static Task RemoveLocalUser(string username)
|
||||
{
|
||||
return RunProcess("PowerShell.exe", $"Remove-LocalUser -Name {username}");
|
||||
// User creation already implemented in powershell install scripts, vs many interop calls
|
||||
return RunProcess("PowerShell.exe", $@"""c:\\src\\repos\\iis.administration\\scripts\tests\\Create-User.ps1"" -Name '{username}' -Password '{password}'");
|
||||
}
|
||||
|
||||
private static Task RunProcess(string tool, string arguments)
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"host_id": "",
|
||||
"host_name": "IIS Administration API",
|
||||
"urls": "https://*:44326",
|
||||
"security": {
|
||||
"require_windows_authentication": true,
|
||||
"users": {
|
||||
"administrators": [
|
||||
"IIS Administrators",
|
||||
"Administrator"
|
||||
],
|
||||
"owners": [
|
||||
"Administrator"
|
||||
]
|
||||
},
|
||||
"access_policy": {
|
||||
"api": {
|
||||
"users": "administrators",
|
||||
"access_key": true
|
||||
},
|
||||
"api_keys": {
|
||||
"users": "administrators",
|
||||
"access_key": false
|
||||
},
|
||||
"system": {
|
||||
"users": "owners",
|
||||
"access_key": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"logging": {
|
||||
"enabled": true,
|
||||
"file_name": "log-{Date}.txt",
|
||||
"min_level": "Error",
|
||||
"path": null
|
||||
},
|
||||
"auditing": {
|
||||
"enabled": true,
|
||||
"file_name": "audit-{Date}.txt",
|
||||
"path": null
|
||||
},
|
||||
"cors": {
|
||||
"rules": [
|
||||
{
|
||||
"origin": "https://manage.iis.net",
|
||||
"allow": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"locations": [
|
||||
{
|
||||
"alias": "inetpub",
|
||||
"path": "%systemdrive%\\inetpub",
|
||||
"claims": [
|
||||
"read",
|
||||
"write"
|
||||
]
|
||||
},
|
||||
{
|
||||
"alias": "tests",
|
||||
"path": "%iis_admin_test_dir%",
|
||||
"claims": [
|
||||
"read",
|
||||
"write"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче