[Git][reproducible-builds/diffoscope][master] Compare .asc PGP signatures as text, not as a hexdump. (Closes: #908991,...

Chris Lamb gitlab at salsa.debian.org
Tue Feb 19 15:50:11 CET 2019


Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
a53cee10 by Chris Lamb at 2019-02-19T14:49:56Z
Compare .asc PGP signatures as text, not as a hexdump. (Closes: #908991, reproducible-builds/diffoscope#7)

- - - - -


5 changed files:

- diffoscope/comparators/text.py
- tests/comparators/test_text.py
- + tests/data/test1.asc
- + tests/data/test2.asc
- + tests/data/text_asc_expected_diff


Changes:

=====================================
diffoscope/comparators/text.py
=====================================
@@ -37,7 +37,7 @@ def order_only_difference(unified_diff):
 
 class TextFile(File):
     DESCRIPTION = "text files"
-    FILE_TYPE_RE = re.compile(r'\btext\b')
+    FILE_TYPE_RE = re.compile(r'(?:\btext\b|^PGP signature Signature)')
 
     @property
     def encoding(self):


=====================================
tests/comparators/test_text.py
=====================================
@@ -19,6 +19,7 @@
 
 import codecs
 
+from diffoscope.comparators.text import TextFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
@@ -89,3 +90,17 @@ def test_ordering_differences(text_order1, text_order2):
     difference = text_order1.compare(text_order2)
     assert difference.comments == ['ordering differences only']
     assert difference.unified_diff == get_data('text_order_expected_diff')
+
+
+signature1 = load_fixture('test1.asc')
+signature2 = load_fixture('test2.asc')
+
+
+def test_gpg_signature_identification(signature1, signature2):
+    assert isinstance(signature1, TextFile)
+    assert isinstance(signature2, TextFile)
+
+
+def test_gpg_signature(signature1, signature2):
+    difference = signature1.compare(signature2)
+    assert difference.unified_diff == get_data('text_asc_expected_diff')


=====================================
tests/data/test1.asc
=====================================
@@ -0,0 +1,16 @@
+-----BEGIN PGP SIGNATURE-----
+
+iQIzBAABCgAdFiEEK9jU45eVX3dG2zuJrWkWlnOTmCsFAlhEVnIACgkQrWkWlnOT
+mCvZew/+Nz4404NtdXBSXK9JfhLC8nxzwTLQBFWxT8FSwOPTHyS5Y40oWcIzuD1j
+zGcqNgGyGPDJZ14bbe6qmoIAf6W+KMZB0PDl2C7hSiQR+yuK69mE0XXVONPH5U8H
+/tvwZ/rBvOSp3qI0iBXwDPDEMHzg/r5rlTg2D+YvrU26kIyKlhw40cpPOC70gTAp
+llE+QJKjDCYi39WD8ZgLVJ/xSdkF05IC0qBhrCFeccpSpsrOpMbRGRb/h5dlmSNb
+krqH/0Nwq3uFMiwhT8WY0dGK8NTSsVExcw4u25TPeeyVh47zO4/urGmM7bX/XDhP
+DLoh4EpNT2z9AEnhbHgvkEyRhMVuj2oMb6w6JNjf8fYgAWre+eRUWjcbFw3Uya09
+e/FEp+RvFBhwEzkE9YkePL4d4zUCVjwl4jvuT8GJkNAsM4XJU7MWkeYcb/zZz/ep
+rwgm6DT1FIlwVVTrVYP+Qcmy5Dl8ptn9rvga5wYNkiwBIVjQFZvMjcdMDjeuQI7s
+HqNOIxSH5jWpTxt9ksi2mOqwok/vSYm5izNxSxUeMDRQJIaTtYCGDwl7ucaVwKR5
++gVO5cguBhfhj/DnOPxEQaKgBOet0ifOM1NZQ4YpLcgTEz6Jvq2zKTm190hyEoKi
+yQhIjNX4mjy/Qky1v9IUjZYs8yk8AARt/cby81qf7u1MjwhI4WA=
+=QW4q
+-----END PGP SIGNATURE-----


=====================================
tests/data/test2.asc
=====================================
@@ -0,0 +1,16 @@
+-----BEGIN PGP SIGNATURE-----
+
+iQIzBAABCgAdFiEEK9jU45eVX3dG2zuJrWkWlnOTmCsFAlhmhA0ACgkQrWkWlnOT
+mCuZfhAAjAkmAQ0VhweOM8DFIPSfKdPC67Z/twb54hfR6ZQCZk9ANK4MWPgvQxw3
+gDi0dGfkAeMfqZMprRF3frdsbekASL3l3bFpx2ttcrZU5jrS5Nf3NS0u5XvGdyl2
+o16/+AATv//QNbBVmcrWfbphsr+8M9FdLLvRn9l21p7Ldrc8E49F2mrjr6lWj9Qn
+asOK8gkkFs2xxJI39PaGqXu2OkZmdFXlZuqqGRiSxIpLXNbjSs0tfe8pOeWzwNlK
+3s1uhcACrdPmolfUuNpehDKt9FddmS0tvck0GVJyjD1+Vs1emEIt1aCq1cgnomcT
+uu6g+w3xLnTqN2UIRIMbNrunjLfjzmD/RTtdw853n0e2LdgZ1Esh6eZMyCXMs/lv
+FVuZuJm5TUl1Z+YBFtYZS6kCYPSbXXSILKeInAtigdJJ/djKY3bkV0H9F0xVwbaW
+N/mSgfj7e5bbKTjjX98+gq4M6QRL4Fp9YQriLVG/e0ERJPj4qitVRTAcXzeXZg0T
+oyxyGtAjW3qxazVdTj+RWUaFQsgWc2jQ9F1N+rnuNZ9dbb4U9X7zjdW0Y+WWIKZk
+ci2YC09nl3yMguZdtfUiDUS5/LxaXbnI8Ao0EbpgCbyxvTRDU0CmCc/gZ+664wZ9
+YwkUKB4Gf0w3Jlx3we4Myyo2sRCZT+1EEB8qtbDoe/ylMFFWa0A=
+=JLnP
+-----END PGP SIGNATURE-----


=====================================
tests/data/text_asc_expected_diff
=====================================
@@ -0,0 +1,30 @@
+@@ -1,16 +1,16 @@
+ -----BEGIN PGP SIGNATURE-----
+ 
+-iQIzBAABCgAdFiEEK9jU45eVX3dG2zuJrWkWlnOTmCsFAlhEVnIACgkQrWkWlnOT
+-mCvZew/+Nz4404NtdXBSXK9JfhLC8nxzwTLQBFWxT8FSwOPTHyS5Y40oWcIzuD1j
+-zGcqNgGyGPDJZ14bbe6qmoIAf6W+KMZB0PDl2C7hSiQR+yuK69mE0XXVONPH5U8H
+-/tvwZ/rBvOSp3qI0iBXwDPDEMHzg/r5rlTg2D+YvrU26kIyKlhw40cpPOC70gTAp
+-llE+QJKjDCYi39WD8ZgLVJ/xSdkF05IC0qBhrCFeccpSpsrOpMbRGRb/h5dlmSNb
+-krqH/0Nwq3uFMiwhT8WY0dGK8NTSsVExcw4u25TPeeyVh47zO4/urGmM7bX/XDhP
+-DLoh4EpNT2z9AEnhbHgvkEyRhMVuj2oMb6w6JNjf8fYgAWre+eRUWjc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c/gZ+664wZ9
++YwkUKB4Gf0w3Jlx3we4Myyo2sRCZT+1EEB8qtbDoe/ylMFFWa0A=
++=JLnP
+ -----END PGP SIGNATURE-----



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/a53cee10b0f6d0738d91ab211e4e49bad77b7d71

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/a53cee10b0f6d0738d91ab211e4e49bad77b7d71
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190219/7da73add/attachment.html>


More information about the rb-commits mailing list