config-central/tests/Schema.Tests.ps1

19 lines
1.2 KiB
PowerShell

Describe 'Published manifest schemas' {
It 'accepts schema annotations in checked-in profiles' {
foreach ($profile in Get-ChildItem "$PSScriptRoot/../profiles/*.json") {
Get-Content $profile.FullName -Raw | Test-Json -SchemaFile "$PSScriptRoot/../schemas/profile.schema.json" | Should -BeTrue
}
}
It 'requires the portable checksum and forbids portable machine scope' {
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @(
[ordered]@{ id = 'app'; provider = 'portable'; source = 'example'; version = '1.0'; update = 'pinned'; url = 'https://example.org/app.zip'; executable = 'app.exe' }
) }
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
$profile.packages[0].sha256 = 'a' * 64
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
$profile.packages[0].scope = 'machine'
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
}
}