From b2b76557f5af47c3580f0b3b9d7ee604a3a0f1ca Mon Sep 17 00:00:00 2001 From: Jimmy Campbell Date: Fri, 16 Jun 2017 08:53:42 -0700 Subject: [PATCH] Do not use static creds for certificate store test infrastructure --- scripts/Configure-DevEnvironment.ps1 | 4 ---- scripts/tests/Create-CcsInfrastructure.ps1 | 22 +------------------ .../CentralCertificates.cs | 4 ++-- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/scripts/Configure-DevEnvironment.ps1 b/scripts/Configure-DevEnvironment.ps1 index 274d042..c643600 100644 --- a/scripts/Configure-DevEnvironment.ps1 +++ b/scripts/Configure-DevEnvironment.ps1 @@ -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 diff --git a/scripts/tests/Create-CcsInfrastructure.ps1 b/scripts/tests/Create-CcsInfrastructure.ps1 index a9ebb0b..1718c7b 100644 --- a/scripts/tests/Create-CcsInfrastructure.ps1 +++ b/scripts/tests/Create-CcsInfrastructure.ps1 @@ -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 } } diff --git a/test/Microsoft.IIS.Administration.Tests/CentralCertificates.cs b/test/Microsoft.IIS.Administration.Tests/CentralCertificates.cs index d32e137..b5764d2 100644 --- a/test/Microsoft.IIS.Administration.Tests/CentralCertificates.cs +++ b/test/Microsoft.IIS.Administration.Tests/CentralCertificates.cs @@ -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;