Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 65 additions & 2 deletions schemas/purl-test.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@
}
}
},
"purl_validation_message": {
"title": "PURL validation message",
"description": "Validation severity and message to use as a test expected output when validating a PURL.",
"type": "object",
"additionalProperties": false,
"properties": {
"severity": {
"title": "Validation severity",
"description": "Validation severity.",
"type": "string",
"enum": [
"info",
"warning",
"error"
],
"meta:enum": {
"info": "Informational validation message",
"warning": "Warning validation message",
"error": "Error validation message"
}
},
"message": {
"title": "Validation message",
"description": "Validation message.",
"type": "string"
}
}
},
"purl_test": {
"title": "PURL test",
"description": "A PURL test with input and expected output.",
Expand Down Expand Up @@ -104,12 +132,14 @@
"enum": [
"build",
"parse",
"roundtrip"
"roundtrip",
"validation"
],
"meta:enum": {
"build": "A PURL building test from decoded components to a canonical PURL string.",
"parse": "A PURL building test from decoded components to a canonical PURL string.",
"roundtrip": "A PURL roundtrip test, parsing then building back a PURL from a canonical string input."
"roundtrip": "A PURL roundtrip test, parsing then building back a PURL from a canonical string input.",
"validation": "A PURL validation test, checking if a PURL follows all the rules for a particular ecosystem."
}
},
"expected_failure": {
Expand Down Expand Up @@ -284,6 +314,39 @@
"expected_failure_reason"
]
}
},
{
"if": {
"properties": {
"test_type": {
"const": "validation"
}
},
"required": [
"test_type"
]
},
"then": {
"properties": {
"input": {
"title": "Input test PURL",
"description": "A PURL string to use as a test input (canonical or not).",
"type": "string"
},
"expected_output": {
"title": "Expected validation messages and severities",
"description": "List of validation objects with message and severity expected for this test. Can be an empty list.",
"type": "array",
"items": {
"$ref": "#/definitions/purl_validation_message"
}
}
},
"required": [
"input",
"expected_output"
]
}
}
]
}
Expand Down
52 changes: 52 additions & 0 deletions tests/types/alpm-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,58 @@
"expected_output": "pkg:alpm/arch/containers-common@1:0.47.4-4?arch=x86_64",
"expected_failure": false,
"expected_failure_reason": null
},
{
"description": "Valid alpm package with arch qualifier",
"test_group": "base",
"test_type": "validation",
"input": "pkg:alpm/arch/[email protected]?arch=x86_64",
"expected_output": []
},
{
"description": "alpm package with uppercase nmamespace",
"test_group": "base",
"test_type": "validation",
"input": "pkg:alpm/Arch/[email protected]?arch=x86_64",
"expected_output": [
{
"severity": "warning",
"message": "Namespace is not lowercased for purl type: 'alpm'"
}
]
},
{
"description": "alpm package with uppercase nmamespace (advanced)",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:alpm/Arch/[email protected]?arch=x86_64",
"expected_output": []
},
{
"description": "Valid alpm package with 'any' arch",
"test_group": "base",
"test_type": "validation",
"input": "pkg:alpm/arch/[email protected]?arch=any",
"expected_output": []
},
{
"description": "Valid alpm package with epoch in version",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:alpm/arch/containers-common@1:0.47.4-4?arch=x86_64",
"expected_output": []
},
{
"description": "alpm package missing namespace",
"test_group": "base",
"test_type": "validation",
"input": "pkg:alpm/[email protected]?arch=x86_64",
"expected_output": [
{
"severity": "error",
"message": "Namespace is required for purl type: 'alpm'"
}
]
}
]
}
56 changes: 56 additions & 0 deletions tests/types/apk-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,62 @@
"expected_output": "pkg:apk/alpine/[email protected]?arch=x86",
"expected_failure": false,
"expected_failure_reason": null
},
{
"description": "Valid apk package with arch qualifier",
"test_group": "base",
"test_type": "validation",
"input": "pkg:apk/alpine/[email protected]?arch=x86",
"expected_output": []
},
{
"description": "Valid apk package with higher version and arch qualifier",
"test_group": "base",
"test_type": "validation",
"input": "pkg:apk/alpine/[email protected]?arch=x86",
"expected_output": []
},
{
"description": "Valid apk package with openwrt vendor",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:apk/openwrt/[email protected]?arch=mips",
"expected_output": []
},
{
"description": "apk package missing namespace",
"test_group": "base",
"test_type": "validation",
"input": "pkg:apk/[email protected]?arch=x86",
"expected_output": [
{
"severity": "error",
"message": "Namespace is required for purl type: 'apk'"
}
]
},
{
"description": "apk package with uppercase namespace and name",
"test_group": "base",
"test_type": "validation",
"input": "pkg:apk/FOO/[email protected]?arch=x86",
"expected_output": [
{
"severity": "warning",
"message": "Namespace is not lowercased for purl type: 'apk'"
},
{
"severity": "warning",
"message": "Name is not lowercased for purl type: 'apk'"
}
]
},
{
"description": "apk package with uppercase namespace and name (advanced)",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:apk/FOO/[email protected]?arch=x86",
"expected_output": []
}
]
}
33 changes: 33 additions & 0 deletions tests/types/bitbucket-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,39 @@
"expected_output": "pkg:bitbucket/birkenfeld/pygments-main@244fd47e07d1014f0aed9c",
"expected_failure": false,
"expected_failure_reason": null
},
{
"description": "Valid Bitbucket package with commit hash as version",
"test_group": "base",
"test_type": "validation",
"input": "pkg:bitbucket/birkenfeld/pygments-main@244fd47e07d1014f0aed9c",
"expected_output": []
},
{
"description": "Valid Bitbucket package with subpath",
"test_group": "base",
"test_type": "validation",
"input": "pkg:bitbucket/teamname/[email protected]#src/main",
"expected_output": []
},
{
"description": "Valid Bitbucket package with qualifiers",
"test_group": "base",
"test_type": "validation",
"input": "pkg:bitbucket/company/service@release-2024?arch=x86_64&os=linux",
"expected_output": [
{
"severity": "info",
"message": "Invalid qualifiers found: arch, os. Allowed qualifiers are: repository_url"
}
]
},
{
"description": "Valid Bitbucket package with qualifiers",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:bitbucket/company/service@release-2024?arch=x86_64&os=linux",
"expected_output": []
}
]
}
28 changes: 28 additions & 0 deletions tests/types/bitnami-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,34 @@
"expected_output": "pkg:bitnami/[email protected]?arch=arm64&distro=photon-4",
"expected_failure": false,
"expected_failure_reason": null
},
{
"description": "Valid Bitnami package without version",
"test_group": "base",
"test_type": "validation",
"input": "pkg:bitnami/wordpress?distro=debian-12",
"expected_output": []
},
{
"description": "Valid Bitnami package with version and distro",
"test_group": "base",
"test_type": "validation",
"input": "pkg:bitnami/[email protected]?distro=debian-12",
"expected_output": []
},
{
"description": "Valid Bitnami package with arch and distro",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:bitnami/[email protected]?arch=arm64&distro=debian-12",
"expected_output": []
},
{
"description": "Valid Bitnami package with another distro",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:bitnami/[email protected]?arch=arm64&distro=photon-4",
"expected_output": []
}
]
}
33 changes: 33 additions & 0 deletions tests/types/cargo-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,39 @@
"expected_output": "pkg:cargo/[email protected]",
"expected_failure": false,
"expected_failure_reason": null
},
{
"description": "Valid Cargo package with name and version",
"test_group": "base",
"test_type": "validation",
"input": "pkg:cargo/[email protected]",
"expected_output": []
},
{
"description": "Valid Cargo package with another example",
"test_group": "base",
"test_type": "validation",
"input": "pkg:cargo/[email protected]",
"expected_output": []
},
{
"description": "Cargo package without version",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:cargo/structopt",
"expected_output": []
},
{
"description": "Cargo package with namespace (not allowed)",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:cargo/rustlang/[email protected]",
"expected_output": [
{
"severity": "error",
"message": "Namespace is prohibited for purl type: 'cargo'"
}
]
}
]
}
33 changes: 33 additions & 0 deletions tests/types/cocoapods-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,39 @@
"expected_output": "pkg:cocoapods/[email protected]#NSData%2Bzlib",
"expected_failure": false,
"expected_failure_reason": null
},
{
"description": "Valid CocoaPods package with name and version",
"test_group": "base",
"test_type": "validation",
"input": "pkg:cocoapods/[email protected]",
"expected_output": []
},
{
"description": "Valid CocoaPods package with subspec in subpath",
"test_group": "base",
"test_type": "validation",
"input": "pkg:cocoapods/[email protected]#NSData+zlib",
"expected_output": []
},
{
"description": "CocoaPods package without version",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:cocoapods/MapsIndoors",
"expected_output": []
},
{
"description": "CocoaPods package with namespace (not allowed)",
"test_group": "advanced",
"test_type": "validation",
"input": "pkg:cocoapods/apple/[email protected]#Twitter",
"expected_output": [
{
"severity": "error",
"message": "Namespace is prohibited for purl type: 'cocoapods'"
}
]
}
]
}
Loading