commit:     4440f381775faae99fd6bd63b03ef0f725dd8895
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 24 10:56:39 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Oct 24 18:45:30 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gemato.git/commit/?id=4440f381

Generate modified signed test Manifest programmatically

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 tests/data/Manifest.asc-modified | 20 --------------------
 tests/test_openpgp.py            | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/tests/data/Manifest.asc-modified b/tests/data/Manifest.asc-modified
deleted file mode 100644
index c7e2c2e..0000000
--- a/tests/data/Manifest.asc-modified
+++ /dev/null
@@ -1,20 +0,0 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA256
-
-TIMESTAMP 2017-10-22T18:06:41Z
-MANIFEST eclass/Manifest 0 MD5 d41d8cd98f00b204e9800998ecf8427e SHA1 
da39a3ee5e6b4b0d3255bfef95601890afd80709
-IGNORE local
-DATA myebuild-0.ebuild 32
-MISC metadata.xml 0 MD5 d41d8cd98f00b204e9800998ecf8427e SHA1 
da39a3ee5e6b4b0d3255bfef95601890afd80709
-DIST mydistfile.tar.gz 0 MD5 d41d8cd98f00b204e9800998ecf8427e SHA1 
da39a3ee5e6b4b0d3255bfef95601890afd80709
------BEGIN PGP SIGNATURE-----
-
-iQEzBAEBCAAdFiEEgeEsFr2NzWC+GAhFE2iA5yp7E4QFAloCx+YACgkQE2iA5yp7
-E4TYrwf+JxjkVDNtvSN3HjQmdtcayLsaliw/2kqjoaQKs0lZD8+NRe7xPmwSm4bP
-XKfoouJ0+/s87vuYJpBBCjtUDA9C9yZIeRTo8+eW6XsZbRRUmUD5ylTS+FpSsUrS
-bEyYk4yZQMYrat+GQ1QBv+625nqnSDv5LZHBBZ/rG36GGlwHPbIKIishnDfdG2QQ
-zuxkqepNq4Inzp//ES7Bv4qbTzyBI//HzfY31vOgdhhs5N5Ytez3Xxv/KNOTYdi1
-ZIfqeaQ4NoefmxQunyEjT+8X2DMaEeHQni7dwjQc+FiN4ReV9aWbLo2O2cArqEHR
-mkkhTd2Auao4D2K74BePBuiZ9+eDQA==
-=khff
------END PGP SIGNATURE-----

diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py
index d9cd76f..c5bcc50 100644
--- a/tests/test_openpgp.py
+++ b/tests/test_openpgp.py
@@ -67,6 +67,18 @@ def dash_escape(data: str) -> str:
     )
 
 
+def modify_manifest(data: str) -> str:
+    """Return the "modified" Manifest variation"""
+    return "".join(
+        [
+            x.split(" 0 ", 1)[0] + " 32\n"
+            if x.startswith("DATA")
+            else f"{x}\n"
+            for x in data.splitlines()
+        ]
+    )
+
+
 def _(path: str) -> bytes:
     return data_dir.joinpath(path).read_bytes()
 
@@ -170,7 +182,7 @@ POST_EXPIRATION_SIGNED_MANIFEST = 
T("Manifest.asc-post-expiration")
 # valid Manifest with dash-escaped content
 DASH_ESCAPED_SIGNED_MANIFEST = dash_escape(SIGNED_MANIFEST)
 # Manifest with modified text (should fail)
-MODIFIED_SIGNED_MANIFEST = T("Manifest.asc-modified")
+MODIFIED_SIGNED_MANIFEST = modify_manifest(SIGNED_MANIFEST)
 # Manifest with expired signature itself
 EXPIRED_SIGNED_MANIFEST = T("Manifest.asc-expired")
 # Manifest signed using the subkey

Reply via email to