$repositoryRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path $policyPath = Join-Path $repositoryRoot 'scripts\Set-SguLaboratorioWallpaperPolicy.ps1' $policySource = Get-Content -LiteralPath $policyPath -Raw Describe 'Laboratorio wallpaper policy packaging and scope' { It 'parses in Windows PowerShell and supports a read-only preview' { $tokens = $null $parseErrors = $null [Management.Automation.Language.Parser]::ParseFile($policyPath, [ref]$tokens, [ref]$parseErrors) | Out-Null $parseErrors.Count | Should Be 0 $policySource | Should Match 'SupportsShouldProcess' $policySource | Should Match 'if \(-not \$PSCmdlet.ShouldProcess' } It 'scopes user settings through computer loopback Merge' { $policySource | Should Match "OU=Laboratorio,DC=lci,DC=lasalle,DC=mx" $policySource | Should Match "Name = 'UserPolicyMode'; Type = 'DWord'; Value = 1" $policySource | Should Match "Enforced = 'Yes'" $policySource | Should Match "LinkEnabled = 'Yes'" } It 'locks the generated per-user and per-computer wallpaper path' { $policySource | Should Match "Name = 'NoChangingWallPaper'; Type = 'DWord'; Value = 1" $policySource | Should Match ([regex]::Escape('%LOCALAPPDATA%\SGU\Wallpapers\welcome-%COMPUTERNAME%.jpg')) $policySource | Should Match "Name = 'Wallpaper'; Type = 'ExpandString'" } It 'reuses and backs up an existing GPO and verifies the result' { foreach ($command in @('Get-GPO', 'Backup-GPO', 'Set-GPLink', 'New-GPLink', 'Get-GPRegistryValue')) { $policySource | Should Match ([regex]::Escape($command)) } $policySource | Should Match 'Wallpaper policy verification failed' } It 'ships in the server package and runs in server initialization' { foreach ($path in @('scripts\New-SguBootstrapPackages.ps1', 'scripts\Initialize-SguDomainController.ps1')) { (Get-Content (Join-Path $repositoryRoot $path) -Raw) | Should Match 'Set-SguLaboratorioWallpaperPolicy.ps1' } } }