From 91bde048b6f1a90f74e0d90f567346057372586e Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Fri, 25 Sep 2026 10:43:39 -0400 Subject: [PATCH] test: reword PcapngUnescapedKeyTests' claims that #784 falsified #784 added an escape_key helper to pcapkit/dumpkit/common.py that XML-escapes mapping keys, so the plist half of this class's docstring is no longer true: the plist report of test.pcapng now parses as well-formed XML. Only the json writer's quoting defect (dictdumper/json.py:224, unescaped quotes in a bytes-repr key) still stands, still open upstream as JarryShaw/DictDumper#121. - Class docstring: drop the claim that both json and plist reports come out unparseable; note that plist parses since #784. - Method docstring: replace the stale "line 915"/"line 1376" numbers with what this run actually measured on current main -- json fails at line 1019 column 12, and plist no longer fails at all -- and flag the json number as fixture-dependent rather than a fixed fact, since a drifted instance of exactly this number is what #785 was filed over. Measured on ef859f776: json.load raises "Expecting ':' delimiter: line 1019 column 12" on the regenerated test.pcapng; xml.etree.ElementTree.parse now succeeds on the same fixture's plist report. Verified 1517/1958 was the correct pre-#784 plist failure line (0419c1c97, matching #785's own measurement), so 1376 had already drifted before #784 landed. The skip reason itself named no false claim and needed no change. Build/tests: 6 passed, 1 skipped (unchanged) in tests/integration/test_pcapng_end_to_end.py. --- tests/integration/test_pcapng_end_to_end.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/integration/test_pcapng_end_to_end.py b/tests/integration/test_pcapng_end_to_end.py index 48035754cf..49ce475f85 100644 --- a/tests/integration/test_pcapng_end_to_end.py +++ b/tests/integration/test_pcapng_end_to_end.py @@ -151,9 +151,10 @@ def test_all_three_layouts_yield_the_same_protocol_chains(self) -> None: class PcapngUnescapedKeyTests(EndToEndTestCase): """The report of :file:`test.pcapng`, which carries a decryption secrets block. - Its tree report is fine -- :class:`PcapngTreeReportTests` covers it -- but - the ``json`` and ``plist`` reports come out unparseable, so the round trip - lives here behind a skip rather than being asserted either way. + Its tree report is fine -- :class:`PcapngTreeReportTests` covers it -- and + since #784 its ``plist`` report parses too. Its ``json`` report still comes + out unparseable, so that round trip lives here behind a skip rather than + being asserted either way. """ @@ -165,7 +166,7 @@ def test_json_report_of_a_decryption_secrets_block_parses(self) -> None: For this fixture it is not, and two things stack up to make it so: - 1. ``pcapkit/protocols/schema/misc/pcapng.py:1450`` keys the TLS key log + 1. ``pcapkit/protocols/schema/misc/pcapng.py:1982`` keys the TLS key log entries by ``bytes.fromhex(random)``, i.e. by a raw :class:`bytes` client random rather than by its hex text, so the report's key is a Python ``bytes`` repr: ``b' !"#$%&\\'()*+,-./0123456789:;<=>?'``. @@ -180,9 +181,15 @@ def test_json_report_of_a_decryption_secrets_block_parses(self) -> None: >>> json.load(open('probe.json')) json.decoder.JSONDecodeError: Expecting ':' delimiter ... - Measured on this fixture: ``json.load`` fails with ``Expecting ':' - delimiter: line 915 column 12``. The same key makes the ``plist`` report - invalid XML at line 1376, where its ``&`` is unescaped. + Measured on this fixture at ``ef859f776``: ``json.load`` fails with + ``Expecting ':' delimiter: line 1019 column 12`` -- quoted as what that + commit measured, not as a promise the fixture will keep producing it, + since a stale instance of exactly this number is what #785 was filed + over. The same key used to make the ``plist`` report invalid XML too; + #784 fixed that half by adding an ``escape_key`` helper in + ``pcapkit/dumpkit/common.py:250`` that XML-escapes mapping keys, leaving + only this ``json`` quoting defect, still open upstream as + JarryShaw/DictDumper#121. """ extractor = self.extract(fin=sample_path('test.pcapng'), fout=self.out('report'),