Fix credential provider startup policy command generation
This commit is contained in:
1 parent
db35d86df1
commit
21890047e2
2 files changed
+33
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
$repositoryRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||
$installerPath = Join-Path $repositoryRoot 'scripts\Install-SguCredentialProviderUpdatePolicy.ps1'
|
||||
|
||||
Describe 'Credential Provider startup policy' {
|
||||
It 'generates a complete LastLoggedOnProvider command' {
|
||||
$Version = '0.6.16'
|
||||
$ClientPackageUri = 'https://example.invalid/client.zip'
|
||||
$ClientPackageSha256 = 'A' * 64
|
||||
$source = Get-Content -LiteralPath $installerPath -Raw
|
||||
$template = [regex]::Match($source, '(?ms)^\$startupScript = @"\r?\n.*?^"@')
|
||||
$template.Success | Should Be $true
|
||||
Invoke-Expression $template.Value
|
||||
|
||||
$tokens = $null
|
||||
$errors = $null
|
||||
$ast = [Management.Automation.Language.Parser]::ParseInput(
|
||||
$startupScript, [ref]$tokens, [ref]$errors)
|
||||
$errors.Count | Should Be 0
|
||||
|
||||
$commands = @($ast.FindAll({
|
||||
param($node)
|
||||
$node -is [Management.Automation.Language.CommandAst] -and
|
||||
$node.GetCommandName() -eq 'Set-ItemProperty'
|
||||
}, $true))
|
||||
$commands.Count | Should Be 1
|
||||
@($commands[0].CommandElements | Where-Object {
|
||||
$_ -is [Management.Automation.Language.CommandParameterAst] -and
|
||||
$_.ParameterName -eq 'Value'
|
||||
}).Count | Should Be 1
|
||||
$startupScript | Should Not Match '(?m)^\s+-Value\s'
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user