Files
SGU-CredentialProvider/tests/AuthBrokerPasswordAuthority.Tests.ps1
T

48 lines
2.9 KiB
PowerShell

$repositoryRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$synchronizerPath = Join-Path $repositoryRoot 'src\SGU.AuthBroker\Services\ActiveDirectorySynchronizer.cs'
$deployPath = Join-Path $repositoryRoot 'scripts\Deploy-AuthBroker.ps1'
$userPolicyPath = Join-Path $repositoryRoot 'scripts\Set-SguDomainUserPolicies.ps1'
$passwordPolicyPath = Join-Path $repositoryRoot 'scripts\Set-SguInstitutionalPasswordPolicy.ps1'
$bootstrapPath = Join-Path $repositoryRoot 'scripts\Initialize-SguDomainController.ps1'
$packagePath = Join-Path $repositoryRoot 'scripts\New-SguBootstrapPackages.ps1'
$synchronizer = Get-Content -LiteralPath $synchronizerPath -Raw
$deploy = Get-Content -LiteralPath $deployPath -Raw
$userPolicy = Get-Content -LiteralPath $userPolicyPath -Raw
$passwordPolicy = Get-Content -LiteralPath $passwordPolicyPath -Raw
$bootstrap = Get-Content -LiteralPath $bootstrapPath -Raw
$package = Get-Content -LiteralPath $packagePath -Raw
Describe 'SGU Auth Broker password authority' {
It 'denies the Change Password extended right to SELF and Everyone before SetPassword' {
$synchronizer | Should Match 'AB721A53-1E2F-11D0-9819-00AA0040529B'
$synchronizer | Should Match 'WellKnownSidType\.WorldSid'
$synchronizer | Should Match 'WellKnownSidType\.SelfSid'
$synchronizer | Should Match 'AccessControlType\.Deny'
$synchronizer.IndexOf('EnsureCannotChangePassword(user', [StringComparison]::Ordinal) |
Should BeLessThan $synchronizer.IndexOf('user.Invoke("SetPassword"', [StringComparison]::Ordinal)
}
It 'repairs every existing account below Usuarios-SGU during broker deployment' {
$deploy | Should Match 'Get-ADUser.*-SearchBase \$usersOuDn.*-SearchScope Subtree'
$deploy | Should Match '(?s)Set-ADAccountControl.*-CannotChangePassword \$true'
}
It 'removes Change Password from the Windows security screen for managed users' {
$userPolicy | Should Match "disableChangePasswordValueName = 'DisableChangePassword'"
$userPolicy | Should Match '(?s)-ValueName \$disableChangePasswordValueName.*-Type DWord.*-Value 1'
}
It 'scopes exact SGO passwords to all three SGU role groups without changing the domain default' {
foreach ($role in @('Alumnos', 'Administrativos', 'Docentes')) {
$passwordPolicy | Should Match "CN=SGU-$role,OU=$role,OU=Usuarios-SGU"
}
$passwordPolicy | Should Match 'ComplexityEnabled = \$false'
$passwordPolicy | Should Match 'MinPasswordLength = 1'
$passwordPolicy | Should Match 'PasswordHistoryCount = 0'
$passwordPolicy | Should Match 'MaxPasswordAge = \[TimeSpan\]::Zero'
$passwordPolicy | Should Not Match 'Set-ADDefaultDomainPasswordPolicy'
$bootstrap | Should Match 'Set-SguInstitutionalPasswordPolicy\.ps1'
$package | Should Match "'Set-SguInstitutionalPasswordPolicy.ps1'"
}
}