MAS-WP-0005-T02: SCP-1 quoted local-parts equivalent on receipt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 252470@bnt-lap001 Assistant-Session: ad628c8f-4be2-4979-94c9-76c7ed6f8241
This commit is contained in:
parent
5b57a9941e
commit
0a2d811444
9 changed files with 70 additions and 6 deletions
|
|
@ -130,8 +130,12 @@ def test_unconfirmed_namespace_is_not_acted_on(env):
|
|||
|
||||
def test_non_mas_recipient_still_forwarded(env):
|
||||
_, _, _, resolver = env
|
||||
ev = build_event(f'"quoted"@{D}', {}, resolver)
|
||||
assert ev["mas"]["valid"] is False and ev["recipient"] == f'"quoted"@{D}'
|
||||
ev = build_event(f'"not mas"@{D}', {}, resolver)
|
||||
assert ev["mas"]["valid"] is False and ev["recipient"] == f'"not mas"@{D}'
|
||||
# SCP-1: unnecessary quotes are equivalent to the unquoted form
|
||||
ev = build_event(f'"ticket=GS-1"@{D}', {}, resolver)
|
||||
assert ev["mas"]["valid"] is True and ev["mas"]["equivalence_key"] == "ticket=GS-1"
|
||||
assert ev["recipient"] == f'"ticket=GS-1"@{D}' # the event keeps what arrived
|
||||
|
||||
|
||||
def test_pipe_transport_subprocess(env):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from mas_core.parser import (
|
|||
MasSyntaxError,
|
||||
parse_address,
|
||||
parse_local_part,
|
||||
parse_received_address,
|
||||
validate_profile,
|
||||
)
|
||||
|
||||
|
|
@ -111,3 +112,23 @@ def test_generator_rules():
|
|||
p = parse_local_part(f["local_part"])
|
||||
with pytest.raises(MasSyntaxError):
|
||||
generate_local_part(str(p.target), facet=p.facet.value, interaction=p.interaction.mode)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("raw, expected", [
|
||||
('"ticket=PR42"@example.com', "ticket=PR42"), # SCP-1: unnecessary quotes
|
||||
('"ticket!callback"@example.com', "ticket!callback"),
|
||||
("ticket=PR42@example.com", "ticket=PR42"),
|
||||
])
|
||||
def test_received_quoted_local_part_is_equivalent(raw, expected):
|
||||
assert parse_received_address(raw).local.raw == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("raw", ['"a\\"b"@example.com', '"a b"@example.com', '"x@y"@example.com'])
|
||||
def test_received_quoted_non_mas_stays_invalid(raw):
|
||||
with pytest.raises(MasSyntaxError):
|
||||
parse_received_address(raw)
|
||||
|
||||
|
||||
def test_canonical_parser_still_rejects_quotes():
|
||||
with pytest.raises(MasSyntaxError):
|
||||
parse_address('"ticket=PR42"@example.com')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue