Skip to content

Commit

Permalink
signer: add GPG signature data structure test
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lukpueh committed Jan 11, 2023
1 parent 2a22f9f commit 2920d8b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,18 @@ def test_gpg_sign_and_verify_object(self):
self.assertTrue(verify_sig(signature_dict, key_data, self.test_data))
self.assertFalse(verify_sig(signature_dict, key_data, self.wrong_data))

def test_gpg_signature_data_structure(self):
"""Test custom fields and legacy data structure in gpg signatures."""
signer = GPGSigner(homedir=self.gnupg_home)
sig = signer.sign(self.test_data)
self.assertIn("other_headers", sig.unrecognized_fields)

sig_dict = GPGSigner._to_gpg_sig(sig)
self.assertIn("signature", sig_dict)
self.assertNotIn("sig", sig_dict)
sig2 = GPGSigner._from_gpg_sig(sig_dict)
self.assertEqual(sig, sig2)


# Run the unit tests.
if __name__ == "__main__":
Expand Down

0 comments on commit 2920d8b

Please sign in to comment.