summaryrefslogtreecommitdiff
path: root/tests/draft6
diff options
context:
space:
mode:
Diffstat (limited to 'tests/draft6')
-rw-r--r--tests/draft6/definitions.json10
-rw-r--r--tests/draft6/id.json53
-rw-r--r--tests/draft6/optional/format/ipv4.json11
-rw-r--r--tests/draft6/optional/format/uri.json2
-rw-r--r--tests/draft6/ref.json6
5 files changed, 70 insertions, 12 deletions
diff --git a/tests/draft6/definitions.json b/tests/draft6/definitions.json
index 7f3b899..d772fde 100644
--- a/tests/draft6/definitions.json
+++ b/tests/draft6/definitions.json
@@ -1,6 +1,6 @@
[
{
- "description": "valid definition",
+ "description": "validate definition against metaschema",
"schema": {"$ref": "http://json-schema.org/draft-06/schema#"},
"tests": [
{
@@ -11,13 +11,7 @@
}
},
"valid": true
- }
- ]
- },
- {
- "description": "invalid definition",
- "schema": {"$ref": "http://json-schema.org/draft-06/schema#"},
- "tests": [
+ },
{
"description": "invalid definition schema",
"data": {
diff --git a/tests/draft6/id.json b/tests/draft6/id.json
new file mode 100644
index 0000000..1c91d33
--- /dev/null
+++ b/tests/draft6/id.json
@@ -0,0 +1,53 @@
+[
+ {
+ "description": "id inside an enum is not a real identifier",
+ "comment": "the implementation must not be confused by an id buried in the enum",
+ "schema": {
+ "definitions": {
+ "id_in_enum": {
+ "enum": [
+ {
+ "id": "https://localhost:1234/my_identifier.json",
+ "type": "null"
+ }
+ ]
+ },
+ "real_id_in_schema": {
+ "id": "https://localhost:1234/my_identifier.json",
+ "type": "string"
+ },
+ "zzz_id_in_const": {
+ "const": {
+ "id": "https://localhost:1234/my_identifier.json",
+ "type": "null"
+ }
+ }
+ },
+ "anyOf": [
+ { "$ref": "#/definitions/id_in_enum" },
+ { "$ref": "https://localhost:1234/my_identifier.json" }
+ ]
+ },
+ "tests": [
+ {
+ "description": "exact match to enum, and type matches",
+ "data": {
+ "id": "https://localhost:1234/my_identifier.json",
+ "type": "null"
+ },
+ "valid": true
+ },
+ {
+ "description": "match $ref to id",
+ "data": "a string to match #/definitions/id_in_enum",
+ "valid": true
+ },
+ {
+ "description": "no match on enum or $ref to id",
+ "data": 1,
+ "valid": false
+ }
+ ]
+ }
+
+]
diff --git a/tests/draft6/optional/format/ipv4.json b/tests/draft6/optional/format/ipv4.json
index 8b99b9f..e36a381 100644
--- a/tests/draft6/optional/format/ipv4.json
+++ b/tests/draft6/optional/format/ipv4.json
@@ -32,6 +32,17 @@
"description": "an IP address as an integer (decimal)",
"data": "2130706433",
"valid": false
+ },
+ {
+ "description": "leading zeroes should be rejected, as they are treated as octals",
+ "comment": "see https://sick.codes/universal-netmask-npm-package-used-by-270000-projects-vulnerable-to-octal-input-data-server-side-request-forgery-remote-file-inclusion-local-file-inclusion-and-more-cve-2021-28918/",
+ "data": "087.10.0.1",
+ "valid": false
+ },
+ {
+ "description": "value without leading zero is valid",
+ "data": "87.10.0.1",
+ "valid": true
}
]
}
diff --git a/tests/draft6/optional/format/uri.json b/tests/draft6/optional/format/uri.json
index 4306a68..58d3085 100644
--- a/tests/draft6/optional/format/uri.json
+++ b/tests/draft6/optional/format/uri.json
@@ -9,7 +9,7 @@
"valid": true
},
{
- "description": "a valid URL with anchor tag and parantheses",
+ "description": "a valid URL with anchor tag and parentheses",
"data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
"valid": true
},
diff --git a/tests/draft6/ref.json b/tests/draft6/ref.json
index 3bb0efc..676d6a0 100644
--- a/tests/draft6/ref.json
+++ b/tests/draft6/ref.json
@@ -127,7 +127,7 @@
"b": {"$ref": "#/definitions/a"},
"c": {"$ref": "#/definitions/b"}
},
- "$ref": "#/definitions/c"
+ "allOf": [{ "$ref": "#/definitions/c" }]
},
"tests": [
{
@@ -239,7 +239,7 @@
{
"description": "$ref to boolean schema true",
"schema": {
- "$ref": "#/definitions/bool",
+ "allOf": [{ "$ref": "#/definitions/bool" }],
"definitions": {
"bool": true
}
@@ -255,7 +255,7 @@
{
"description": "$ref to boolean schema false",
"schema": {
- "$ref": "#/definitions/bool",
+ "allOf": [{ "$ref": "#/definitions/bool" }],
"definitions": {
"bool": false
}