Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Describe "Set/New/Remove-Service cmdlet tests" -Tags "Feature", "RequireAdminOnW
}
if ($IsWindows) {
$userName = "testuserservices"
$Password = ([char[]]([char]33..[char]95) + ([char[]]([char]97..[char]126)) + 0..9 | Sort-Object {Get-Random})[0..12] -join ''
$testPass = (New-Object -TypeName Net.NetworkCredential("", $Password)).SecurePassword
$testPass = [Net.NetworkCredential]::new("", (New-ComplexPassword)).SecurePassword
$creds = [pscredential]::new(".\$userName", $testPass)
$SecurityDescriptorSddl = 'D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;SU)'
$WrongSecurityDescriptorSddl = 'D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BB)(A;;CCLCSWLOCRRC;;;SU)'
Expand Down
1 change: 1 addition & 0 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ FunctionsToExport = @(
'Enable-Testhook'
'Get-RandomFileName'
'New-RandomHexString'
'New-ComplexPassword'
'Send-VstsLogFile'
'Set-TesthookResult'
'Start-NativeExecution'
Expand Down
19 changes: 19 additions & 0 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,22 @@ function Test-CanWriteToPsHome

$script:CanWriteToPsHome
}

# Creates a password meeting Windows complexity rules
function New-ComplexPassword
{
$numbers = "0123456789"
$lowercase = "abcdefghijklmnopqrstuvwxyz"
$uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
$symbols = "~!@#$%^&*_-+=``|\(){}[]:;`"'<>,.?/"
$password = [string]::Empty
# Windows password complexity rule requires minimum 8 characters and using at least 3 of the
# buckets above, so we just pick one from each bucket twice.
# https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements
1..2 | ForEach-Object {
$Password += $numbers[(Get-Random $numbers.Length)] + $lowercase[(Get-Random $lowercase.Length)] +
$uppercase[(Get-Random $uppercase.Length)] + $symbols[(Get-Random $symbols.Length)]
}

$password
}