diff --git a/schemas/machine.schema.json b/schemas/machine.schema.json index 3cac1d6..c0b9dfa 100644 --- a/schemas/machine.schema.json +++ b/schemas/machine.schema.json @@ -6,6 +6,7 @@ "additionalProperties": false, "required": ["schemaVersion", "name", "profiles"], "properties": { + "$schema": { "type": "string" }, "schemaVersion": { "const": 1 }, "name": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" }, "profiles": { diff --git a/schemas/profile.schema.json b/schemas/profile.schema.json index 52a3b70..6e2fee1 100644 --- a/schemas/profile.schema.json +++ b/schemas/profile.schema.json @@ -9,6 +9,7 @@ "name" ], "properties": { + "$schema": { "type": "string" }, "schemaVersion": { "const": 1 }, diff --git a/tests/Schema.Tests.ps1 b/tests/Schema.Tests.ps1 new file mode 100644 index 0000000..22c7e1b --- /dev/null +++ b/tests/Schema.Tests.ps1 @@ -0,0 +1,18 @@ +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 + } +}