63 lines
4.5 KiB
PowerShell
63 lines
4.5 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
|
|
}
|
|
It 'requires a display name and safe extensions for portable file handlers' {
|
|
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
|
|
$package = [ordered]@{ id = 'app'; provider = 'portable'; source = 'example'; version = '1.0'; update = 'pinned'; url = 'https://example.org/app.zip'; executable = 'app.exe'; sha256 = 'a' * 64; fileAssociations = @('.pdf') }
|
|
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
$package.displayName = 'Example App'
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
|
|
$package.fileAssociations = @('pdf')
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
$package.fileAssociations = @('.pdf')
|
|
$package.fileAssociationIcon = '../outside.ico'
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
$package.fileAssociationIcon = 'assets/example.ico'
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
|
|
}
|
|
It 'accepts only safe portable replacement declarations' {
|
|
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
|
|
$package = [ordered]@{
|
|
id = 'deckstride'; provider = 'portable'; source = 'idle-org'; version = '1.0'; update = 'pinned'
|
|
url = 'https://example.org/deckstride.zip'; executable = 'deckstride.exe'; sha256 = 'a' * 64
|
|
replaces = @([ordered]@{
|
|
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
|
|
legacyRegistration = [ordered]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
|
|
})
|
|
}
|
|
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
|
|
$package.replaces[0].fileAssociations = @('pdf')
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
$package.replaces[0].fileAssociations = @('.pdf')
|
|
$package.replaces[0].legacyRegistration.progIds = @('bad progid')
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
$package.replaces[0].legacyRegistration.progIds = @('PDFPresenter.Document')
|
|
$package.replaces[0].unknown = 'value'
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
}
|
|
It 'allows absent WinGet packages but not absent portable packages' {
|
|
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
|
|
$package = [ordered]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
|
|
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
|
|
$package.provider = 'portable'
|
|
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
|
}
|
|
}
|