Skip to content

Commit 7f72e87

Browse files
test(signing): assert the reject code, not just the refusal
The reject branch asserted a bare ValueError -- but urlsplit raises exactly that for `https://[::1/p`, so `malformed-ipv6-missing-closing-bracket` passed on someone else's exception while five sibling cases sat in the xfail ledger. Six reject cases ship in the data; only five were recorded as gaps. No case asserted `expected_error_code` at all, so the vector set could not detect its own incompleteness -- the defect this PR exists to close. Capture the exception and assert the code the vector ships. All six reject cases now xfail together under #978 and retire together when the typed error lands.
1 parent 0b9477d commit 7f72e87

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

tests/conformance/signing/test_canonicalization.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
"malformed-empty-authority": "#978: empty authority is accepted",
4646
"malformed-bare-ipv6": "#978: unbracketed IPv6 literal is accepted",
4747
"malformed-ipv6-zone-identifier": "#978: RFC 6874 zone identifier is accepted",
48+
# This one is refused today, but by urlsplit() rather than by us: a bare
49+
# ValueError carrying no code. It belongs in the ledger with its five
50+
# siblings so all six reject cases retire together under #978.
51+
"malformed-ipv6-missing-closing-bracket": (
52+
"#978: refused by urlsplit with a bare ValueError that carries no error code"
53+
),
4854
}
4955

5056

@@ -104,11 +110,18 @@ def test_canonicalization_case(name: str, case: dict[str, Any]) -> None:
104110
url = case["input_url"]
105111

106112
if case.get("reject"):
107-
# The spec's expected_error_code here is request_target_uri_malformed,
108-
# which the SDK does not define. Assert the refusal, which is the
109-
# behavioral obligation; the code mapping follows once it exists.
110-
with pytest.raises(ValueError):
113+
# Assert the code the vector ships, not merely that something raised.
114+
# `https://[::1/p` is refused inside urlsplit() with a bare ValueError
115+
# carrying no code, so a bare `pytest.raises(ValueError)` passes for the
116+
# wrong reason and grades nothing -- the refusal has to be ours, and it
117+
# has to name which rule fired.
118+
with pytest.raises(ValueError) as excinfo:
111119
canonicalize_target_uri(url)
120+
actual_code = getattr(excinfo.value, "code", None)
121+
assert actual_code == case["expected_error_code"], (
122+
f"{name}: expected error code {case['expected_error_code']!r}, got "
123+
f"{actual_code!r} from {type(excinfo.value).__name__} ({case['rule']})"
124+
)
112125
return
113126

114127
assert (

0 commit comments

Comments
 (0)