diff options
author | Julian Berman <Julian@GrayVines.com> | 2020-07-25 16:11:56 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2020-07-25 16:11:56 -0400 |
commit | fc5a4a1a28e93f942fe3bf91fea24bfb1a0eaa98 (patch) | |
tree | 512426d6fa20480cf5a82abdb5ecd14751205666 /json/tests | |
parent | dd31840bc29329534fc6a2eee23137893aa068d8 (diff) | |
parent | 95874db4df84775af2429ddea7afd006523cef08 (diff) | |
download | jsonschema-fc5a4a1a28e93f942fe3bf91fea24bfb1a0eaa98.tar.gz |
Merge commit '95874db4df84775af2429ddea7afd006523cef08'
* commit '95874db4df84775af2429ddea7afd006523cef08':
Squashed 'json/' changes from 40601f6..ea41553
Diffstat (limited to 'json/tests')
-rw-r--r-- | json/tests/draft2019-09/format.json | 36 | ||||
-rw-r--r-- | json/tests/draft2019-09/optional/format/duration.json | 75 | ||||
-rw-r--r-- | json/tests/draft2019-09/optional/format/email.json | 35 | ||||
-rw-r--r-- | json/tests/draft2019-09/optional/format/ipv6.json | 50 | ||||
-rw-r--r-- | json/tests/draft2019-09/patternProperties.json | 5 | ||||
-rw-r--r-- | json/tests/draft2019-09/unevaluatedProperties.json | 196 | ||||
-rw-r--r-- | json/tests/draft3/optional/format/email.json | 35 | ||||
-rw-r--r-- | json/tests/draft4/optional/format/email.json | 35 | ||||
-rw-r--r-- | json/tests/draft4/optional/format/ipv6.json | 52 | ||||
-rw-r--r-- | json/tests/draft6/optional/format/email.json | 35 | ||||
-rw-r--r-- | json/tests/draft6/optional/format/ipv6.json | 52 | ||||
-rw-r--r-- | json/tests/draft6/patternProperties.json | 5 | ||||
-rw-r--r-- | json/tests/draft7/optional/format/email.json | 35 | ||||
-rw-r--r-- | json/tests/draft7/optional/format/ipv6.json | 52 | ||||
-rw-r--r-- | json/tests/draft7/patternProperties.json | 5 |
15 files changed, 700 insertions, 3 deletions
diff --git a/json/tests/draft2019-09/format.json b/json/tests/draft2019-09/format.json index bb725e2..dddea86 100644 --- a/json/tests/draft2019-09/format.json +++ b/json/tests/draft2019-09/format.json @@ -646,5 +646,41 @@ "valid": true } ] + }, + { + "description": "validation of durations", + "schema": { "format": "duration" }, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] } ] diff --git a/json/tests/draft2019-09/optional/format/duration.json b/json/tests/draft2019-09/optional/format/duration.json index 24f8fcc..4514738 100644 --- a/json/tests/draft2019-09/optional/format/duration.json +++ b/json/tests/draft2019-09/optional/format/duration.json @@ -12,6 +12,81 @@ "description": "an invalid duration string", "data": "PT1D", "valid": false + }, + { + "description": "no elements present", + "data": "P", + "valid": false + }, + { + "description": "no time elements present", + "data": "P1YT", + "valid": false + }, + { + "description": "no date or time elements present", + "data": "PT", + "valid": false + }, + { + "description": "elements out of order", + "data": "P2D1Y", + "valid": false + }, + { + "description": "missing time separator", + "data": "P1D2H", + "valid": false + }, + { + "description": "time element in the date position", + "data": "P2S", + "valid": false + }, + { + "description": "four years duration", + "data": "P4Y", + "valid": true + }, + { + "description": "zero time, in seconds", + "data": "PT0S", + "valid": true + }, + { + "description": "zero time, in days", + "data": "P0D", + "valid": true + }, + { + "description": "one month duration", + "data": "P1M", + "valid": true + }, + { + "description": "one minute duration", + "data": "PT1M", + "valid": true + }, + { + "description": "one and a half days, in hours", + "data": "PT36H", + "valid": true + }, + { + "description": "one and a half days, in days and hours", + "data": "P1DT12H", + "valid": true + }, + { + "description": "two weeks", + "data": "P2W", + "valid": true + }, + { + "description": "weeks cannot be combined with other units", + "data": "P1Y2W", + "valid": false } ] } diff --git a/json/tests/draft2019-09/optional/format/email.json b/json/tests/draft2019-09/optional/format/email.json index c837c84..02396d2 100644 --- a/json/tests/draft2019-09/optional/format/email.json +++ b/json/tests/draft2019-09/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/json/tests/draft2019-09/optional/format/ipv6.json b/json/tests/draft2019-09/optional/format/ipv6.json index 4b44dad..9b0881e 100644 --- a/json/tests/draft2019-09/optional/format/ipv6.json +++ b/json/tests/draft2019-09/optional/format/ipv6.json @@ -39,6 +39,21 @@ "valid": true }, { + "description": "missing leading octet is invalid", + "data": ":2:3:4:5:6:7:8", + "valid": false + }, + { + "description": "missing trailing octet is invalid", + "data": "1:2:3:4:5:6:7:", + "valid": false + }, + { + "description": "missing leading octet with omitted octets later", + "data": ":2:3:4::8", + "valid": false + }, + { "description": "two sets of double colons is invalid", "data": "1::d6::42", "valid": false @@ -62,6 +77,41 @@ "description": "mixed format with ipv4 section with a hex octet", "data": "1::2:192.168.ff.1", "valid": false + }, + { + "description": "mixed format with leading double colons (ipv4-mapped ipv6 address)", + "data": "::ffff:192.168.0.1", + "valid": true + }, + { + "description": "triple colons is invalid", + "data": "1:2:3:4:5:::8", + "valid": false + }, + { + "description": "8 octets", + "data": "1:2:3:4:5:6:7:8", + "valid": true + }, + { + "description": "insufficient octets without double colons", + "data": "1:2:3:4:5:6:7", + "valid": false + }, + { + "description": "no colons is invalid", + "data": "1", + "valid": false + }, + { + "description": "ipv4 is not ipv6", + "data": "127.0.0.1", + "valid": false + }, + { + "description": "ipv4 segment must have 4 octets", + "data": "1:2:3:4:1.2.3", + "valid": false } ] } diff --git a/json/tests/draft2019-09/patternProperties.json b/json/tests/draft2019-09/patternProperties.json index 1d04a16..c10ffcc 100644 --- a/json/tests/draft2019-09/patternProperties.json +++ b/json/tests/draft2019-09/patternProperties.json @@ -142,6 +142,11 @@ "valid": false }, { + "description": "object with a property matching both true and false is invalid", + "data": {"foobar":1}, + "valid": false + }, + { "description": "empty object is valid", "data": {}, "valid": true diff --git a/json/tests/draft2019-09/unevaluatedProperties.json b/json/tests/draft2019-09/unevaluatedProperties.json index e315b4f..b634be5 100644 --- a/json/tests/draft2019-09/unevaluatedProperties.json +++ b/json/tests/draft2019-09/unevaluatedProperties.json @@ -613,5 +613,201 @@ "valid": false } ] + }, + { + "description": "nested unevaluatedProperties, outer false, inner true, properties outside", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "allOf": [ + { + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, + { + "description": "nested unevaluatedProperties, outer false, inner true, properties inside", + "schema": { + "type": "object", + "allOf": [ + { + "properties": { + "foo": { "type": "string" } + }, + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, + { + "description": "nested unevaluatedProperties, outer true, inner false, properties outside", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "allOf": [ + { + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": true + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": false + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] + }, + { + "description": "nested unevaluatedProperties, outer true, inner false, properties inside", + "schema": { + "type": "object", + "allOf": [ + { + "properties": { + "foo": { "type": "string" } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": true + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] + }, + { + "description": "cousin unevaluatedProperties, true and false, true with properties", + "schema": { + "type": "object", + "allOf": [ + { + "properties": { + "foo": { "type": "string" } + }, + "unevaluatedProperties": true + }, + { + "unevaluatedProperties": false + } + ] + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": false + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] + }, + { + "description": "cousin unevaluatedProperties, true and false, false with properties", + "schema": { + "type": "object", + "allOf": [ + { + "unevaluatedProperties": true + }, + { + "properties": { + "foo": { "type": "string" } + }, + "unevaluatedProperties": false + } + ] + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] } ] diff --git a/json/tests/draft3/optional/format/email.json b/json/tests/draft3/optional/format/email.json index c837c84..02396d2 100644 --- a/json/tests/draft3/optional/format/email.json +++ b/json/tests/draft3/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/json/tests/draft4/optional/format/email.json b/json/tests/draft4/optional/format/email.json index c837c84..02396d2 100644 --- a/json/tests/draft4/optional/format/email.json +++ b/json/tests/draft4/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/json/tests/draft4/optional/format/ipv6.json b/json/tests/draft4/optional/format/ipv6.json index 131edb8..9b0881e 100644 --- a/json/tests/draft4/optional/format/ipv6.json +++ b/json/tests/draft4/optional/format/ipv6.json @@ -30,7 +30,7 @@ }, { "description": "leading colons is valid", - "data": "::1", + "data": "::42:ff:1", "valid": true }, { @@ -39,6 +39,21 @@ "valid": true }, { + "description": "missing leading octet is invalid", + "data": ":2:3:4:5:6:7:8", + "valid": false + }, + { + "description": "missing trailing octet is invalid", + "data": "1:2:3:4:5:6:7:", + "valid": false + }, + { + "description": "missing leading octet with omitted octets later", + "data": ":2:3:4::8", + "valid": false + }, + { "description": "two sets of double colons is invalid", "data": "1::d6::42", "valid": false @@ -62,6 +77,41 @@ "description": "mixed format with ipv4 section with a hex octet", "data": "1::2:192.168.ff.1", "valid": false + }, + { + "description": "mixed format with leading double colons (ipv4-mapped ipv6 address)", + "data": "::ffff:192.168.0.1", + "valid": true + }, + { + "description": "triple colons is invalid", + "data": "1:2:3:4:5:::8", + "valid": false + }, + { + "description": "8 octets", + "data": "1:2:3:4:5:6:7:8", + "valid": true + }, + { + "description": "insufficient octets without double colons", + "data": "1:2:3:4:5:6:7", + "valid": false + }, + { + "description": "no colons is invalid", + "data": "1", + "valid": false + }, + { + "description": "ipv4 is not ipv6", + "data": "127.0.0.1", + "valid": false + }, + { + "description": "ipv4 segment must have 4 octets", + "data": "1:2:3:4:1.2.3", + "valid": false } ] } diff --git a/json/tests/draft6/optional/format/email.json b/json/tests/draft6/optional/format/email.json index c837c84..02396d2 100644 --- a/json/tests/draft6/optional/format/email.json +++ b/json/tests/draft6/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/json/tests/draft6/optional/format/ipv6.json b/json/tests/draft6/optional/format/ipv6.json index 131edb8..9b0881e 100644 --- a/json/tests/draft6/optional/format/ipv6.json +++ b/json/tests/draft6/optional/format/ipv6.json @@ -30,7 +30,7 @@ }, { "description": "leading colons is valid", - "data": "::1", + "data": "::42:ff:1", "valid": true }, { @@ -39,6 +39,21 @@ "valid": true }, { + "description": "missing leading octet is invalid", + "data": ":2:3:4:5:6:7:8", + "valid": false + }, + { + "description": "missing trailing octet is invalid", + "data": "1:2:3:4:5:6:7:", + "valid": false + }, + { + "description": "missing leading octet with omitted octets later", + "data": ":2:3:4::8", + "valid": false + }, + { "description": "two sets of double colons is invalid", "data": "1::d6::42", "valid": false @@ -62,6 +77,41 @@ "description": "mixed format with ipv4 section with a hex octet", "data": "1::2:192.168.ff.1", "valid": false + }, + { + "description": "mixed format with leading double colons (ipv4-mapped ipv6 address)", + "data": "::ffff:192.168.0.1", + "valid": true + }, + { + "description": "triple colons is invalid", + "data": "1:2:3:4:5:::8", + "valid": false + }, + { + "description": "8 octets", + "data": "1:2:3:4:5:6:7:8", + "valid": true + }, + { + "description": "insufficient octets without double colons", + "data": "1:2:3:4:5:6:7", + "valid": false + }, + { + "description": "no colons is invalid", + "data": "1", + "valid": false + }, + { + "description": "ipv4 is not ipv6", + "data": "127.0.0.1", + "valid": false + }, + { + "description": "ipv4 segment must have 4 octets", + "data": "1:2:3:4:1.2.3", + "valid": false } ] } diff --git a/json/tests/draft6/patternProperties.json b/json/tests/draft6/patternProperties.json index 1d04a16..c10ffcc 100644 --- a/json/tests/draft6/patternProperties.json +++ b/json/tests/draft6/patternProperties.json @@ -142,6 +142,11 @@ "valid": false }, { + "description": "object with a property matching both true and false is invalid", + "data": {"foobar":1}, + "valid": false + }, + { "description": "empty object is valid", "data": {}, "valid": true diff --git a/json/tests/draft7/optional/format/email.json b/json/tests/draft7/optional/format/email.json index c837c84..02396d2 100644 --- a/json/tests/draft7/optional/format/email.json +++ b/json/tests/draft7/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/json/tests/draft7/optional/format/ipv6.json b/json/tests/draft7/optional/format/ipv6.json index 131edb8..9b0881e 100644 --- a/json/tests/draft7/optional/format/ipv6.json +++ b/json/tests/draft7/optional/format/ipv6.json @@ -30,7 +30,7 @@ }, { "description": "leading colons is valid", - "data": "::1", + "data": "::42:ff:1", "valid": true }, { @@ -39,6 +39,21 @@ "valid": true }, { + "description": "missing leading octet is invalid", + "data": ":2:3:4:5:6:7:8", + "valid": false + }, + { + "description": "missing trailing octet is invalid", + "data": "1:2:3:4:5:6:7:", + "valid": false + }, + { + "description": "missing leading octet with omitted octets later", + "data": ":2:3:4::8", + "valid": false + }, + { "description": "two sets of double colons is invalid", "data": "1::d6::42", "valid": false @@ -62,6 +77,41 @@ "description": "mixed format with ipv4 section with a hex octet", "data": "1::2:192.168.ff.1", "valid": false + }, + { + "description": "mixed format with leading double colons (ipv4-mapped ipv6 address)", + "data": "::ffff:192.168.0.1", + "valid": true + }, + { + "description": "triple colons is invalid", + "data": "1:2:3:4:5:::8", + "valid": false + }, + { + "description": "8 octets", + "data": "1:2:3:4:5:6:7:8", + "valid": true + }, + { + "description": "insufficient octets without double colons", + "data": "1:2:3:4:5:6:7", + "valid": false + }, + { + "description": "no colons is invalid", + "data": "1", + "valid": false + }, + { + "description": "ipv4 is not ipv6", + "data": "127.0.0.1", + "valid": false + }, + { + "description": "ipv4 segment must have 4 octets", + "data": "1:2:3:4:1.2.3", + "valid": false } ] } diff --git a/json/tests/draft7/patternProperties.json b/json/tests/draft7/patternProperties.json index 1d04a16..c10ffcc 100644 --- a/json/tests/draft7/patternProperties.json +++ b/json/tests/draft7/patternProperties.json @@ -142,6 +142,11 @@ "valid": false }, { + "description": "object with a property matching both true and false is invalid", + "data": {"foobar":1}, + "valid": false + }, + { "description": "empty object is valid", "data": {}, "valid": true |