Do not use static creds for certificate store test infrastructure

This commit is contained in:
Jimmy Campbell 2017-06-16 08:53:42 -07:00 коммит произвёл Drago Draganov
Родитель 312fd46022
Коммит b2b76557f5
3 изменённых файлов: 3 добавлений и 27 удалений

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

@ -60,10 +60,6 @@ try {
Write-Host "Setting environment variables."
SetEnvironmentVariables
# Setup machine to run Central Certificate Store Test scenarios.
Write-Host "Creating central certificate store test infrastructure."
.\tests\Create-CcsInfrastructure.ps1
}
finally {
Pop-Location

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

@ -5,8 +5,6 @@ if ($env:iis_admin_solution_dir -eq $null) {
$CCS_FOLDER_NAME = "CentralCertStore"
$CERTIFICATE_PASS = "abcdefg"
$CERTIFICATE_NAME = "IISAdminLocalTest"
$CERT_USER_NAME = "IisAdminCcsTestR"
$CERT_USER_PASS = "IisAdmin*12@"
function New-CcsSelfSignedCertificate($certName) {
$command = Get-Command "New-SelfSignedCertificate"
@ -33,31 +31,13 @@ Get-ChildItem Cert:\LocalMachine\My\ | Where-Object {$_.Subject -eq "CN=$CERTIFI
$bytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $CERTIFICATE_PASS)
[System.IO.File]::WriteAllBytes([System.IO.Path]::Combine($ccsPath, $CERTIFICATE_NAME + ".pfx"), $bytes)
# Find ccs test user
$localUsers = Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount = True"
$certUser = $localUsers | Where-Object {$_.Caption -match "$CERT_USER_NAME$"}
$userExists = $certUser -ne $null
# Create ccs test user if it doesn't exist
if (-not($userExists)) {
$Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer"
$ccsUser = $Computer.Create("User", $CERT_USER_NAME)
$ccsUser.SetPassword($CERT_USER_PASS)
$ccsUser.SetInfo()
$ccsUser.FullName = "Test account for IIS Administration Central Certificate Store"
$ccsUser.SetInfo()
$ccsUser.UserFlags = 64 + 65536 # ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD
$ccsUser.SetInfo()
}
# Check for ccs entry in hosts file to allow local testing of ccs binding
$hostFile = "C:\Windows\System32\drivers\etc\hosts"
$lines = [System.IO.File]::ReadAllLines($hostFile)
$containsCertHostName = $false
$lines | ForEach-Object {
if ($_ -match $CERTIFICATE_NAME) {
$containsTestEntry = $true
$containsCertHostName = $true
}
}

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

@ -23,8 +23,8 @@ namespace Microsoft.IIS.Administration.Tests
private static readonly string FOLDER_PATH = Path.Combine(Environment.ExpandEnvironmentVariables("%iis_admin_solution_dir%"), "test", FOLDER_NAME);
private const string NAME = "IIS Central Certificate Store";
private const string FOLDER_NAME = "CentralCertStore";
private const string USER_NAME = "IisAdminCcsTestR";
private const string USER_PASS = "IisAdmin*12@";
private const string USER_NAME = "";
private const string USER_PASS = "";
private const string CERT_NAME = "IISAdminLocalTest";
private const string PVK_PASS = "abcdefg";
private ITestOutputHelper _output;