Skip to content

Commit

Permalink
test: hostname format check fails on empty string
Browse files Browse the repository at this point in the history
Assert that hostname format validation fails gracefully on empty strings.

This is especially for Python `jsonschema` library that raises an unexpected
ValueError exception on `hostname` check (python-jsonschema/jsonschema#1121).

Adds similar test to:
 * draft3: host-name
 * draft4: hostname
 * draft6: hosntame
 * draft7: hostname, idn-hostname
 * draft2019-09: hostname, idn-hostname
 * draft2020-12: hostname, idn-hostname
 * draft-next: hostname, idn-hostname
  • Loading branch information
jvtm committed Jul 13, 2023
1 parent b069ac3 commit eb39ef2
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 0 deletions.
5 changes: 5 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,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 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,11 @@
"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": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 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,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 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,11 @@
"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": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 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,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 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,11 @@
"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": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions tests/draft3/optional/format/host-name.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions tests/draft4/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions tests/draft6/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions tests/draft7/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down
5 changes: 5 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,11 @@
"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": "empty string",
"data": "",
"valid": false
}
]
}
Expand Down

0 comments on commit eb39ef2

Please sign in to comment.