Skip to content

Commit

Permalink
Squashed 'json/' changes from 5cc9214e8..4ecd01f30
Browse files Browse the repository at this point in the history
4ecd01f30 Merge pull request #687 from swaeberle/check-single-label-idn-hostnames
732e7275a test single label IDN hostnames
ab3924a66 Merge pull request #685 from swaeberle/check-single-label-hostnames
9265a4fa9 do not test hostname with leading digit for older drafts
261b52db1 do not allow starting digits in hostnames for older drafts
9fc231ea4 test digits in hostnames
e9b20158e test plain single label hostnames
c8b57093d test valid single label hostnames
299aa7fe5 Merge pull request #682 from json-schema-org/useless-branch
fbb3cac60 Bump the sanity check to use a released version of jsonschema

git-subtree-dir: json
git-subtree-split: 4ecd01f30bce36a61224fa0f46c2c3f0cf7481dc
  • Loading branch information
Julian committed Sep 20, 2023
1 parent eb56578 commit 64b8c57
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 6 deletions.
9 changes: 4 additions & 5 deletions bin/jsonschema_suite
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import warnings
try:
import jsonschema.validators
except ImportError:
jsonschema = None
jsonschema = Unresolvable = None
VALIDATORS = {}
else:
from referencing.exceptions import Unresolvable

VALIDATORS = {
"draft3": jsonschema.validators.Draft3Validator,
"draft4": jsonschema.validators.Draft4Validator,
Expand Down Expand Up @@ -587,7 +589,7 @@ class SanityTests(unittest.TestCase):
with self.subTest(case=case, version=version.name):
try:
Validator(case["schema"]).is_valid(12)
except jsonschema.exceptions.RefResolutionError:
except Unresolvable:
pass

@unittest.skipIf(jsonschema is None, "Validation library not present!")
Expand Down Expand Up @@ -615,9 +617,6 @@ class SanityTests(unittest.TestCase):
with self.subTest(path=path):
try:
validator.validate(cases)
except jsonschema.exceptions.RefResolutionError:
# python-jsonschema/jsonschema#884
pass
except jsonschema.ValidationError as error:
self.fail(str(error))

Expand Down
25 changes: 25 additions & 0 deletions tests/draft-next/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
25 changes: 25 additions & 0 deletions tests/draft-next/optional/format/idn-hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,31 @@
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement",
"data": "\u0628\u064a\u200c\u0628\u064a",
"valid": true
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
25 changes: 25 additions & 0 deletions tests/draft2019-09/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
25 changes: 25 additions & 0 deletions tests/draft2019-09/optional/format/idn-hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,31 @@
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement",
"data": "\u0628\u064a\u200c\u0628\u064a",
"valid": true
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
25 changes: 25 additions & 0 deletions tests/draft2020-12/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
25 changes: 25 additions & 0 deletions tests/draft2020-12/optional/format/idn-hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,31 @@
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement",
"data": "\u0628\u064a\u200c\u0628\u064a",
"valid": true
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
20 changes: 20 additions & 0 deletions tests/draft4/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
20 changes: 20 additions & 0 deletions tests/draft6/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
20 changes: 20 additions & 0 deletions tests/draft7/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
20 changes: 20 additions & 0 deletions tests/draft7/optional/format/idn-hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,26 @@
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement",
"data": "\u0628\u064a\u200c\u0628\u064a",
"valid": true
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ skipsdist = True

[testenv:sanity]
# used just for validating the structure of the test case files themselves
deps = jsonschema==4.18.0a4
deps = jsonschema==4.19.0
commands = {envpython} bin/jsonschema_suite check

0 comments on commit 64b8c57

Please sign in to comment.