Skip to content

Commit 2920d8b

Browse files
committed
signer: add GPG signature data structure test
Assert that GPG Signature instances have the correct extra field, and test conversion to and from legacy format. Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
1 parent 2a22f9f commit 2920d8b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_signer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,18 @@ def test_gpg_sign_and_verify_object(self):
419419
self.assertTrue(verify_sig(signature_dict, key_data, self.test_data))
420420
self.assertFalse(verify_sig(signature_dict, key_data, self.wrong_data))
421421

422+
def test_gpg_signature_data_structure(self):
423+
"""Test custom fields and legacy data structure in gpg signatures."""
424+
signer = GPGSigner(homedir=self.gnupg_home)
425+
sig = signer.sign(self.test_data)
426+
self.assertIn("other_headers", sig.unrecognized_fields)
427+
428+
sig_dict = GPGSigner._to_gpg_sig(sig)
429+
self.assertIn("signature", sig_dict)
430+
self.assertNotIn("sig", sig_dict)
431+
sig2 = GPGSigner._from_gpg_sig(sig_dict)
432+
self.assertEqual(sig, sig2)
433+
422434

423435
# Run the unit tests.
424436
if __name__ == "__main__":

0 commit comments

Comments
 (0)