From c6a1e0952aa9e9ce215a8d46661551ecdf535515 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Thu, 19 Oct 2017 13:41:47 -0400 Subject: [PATCH] protonmsg: don't send rpm.sign messages when the sigkey is empty When a build completes, we store the original, unsigned rpm headers to disk. This results in the postRPMSign callback being called, and a rpm.sign message being sent with an empty sigkey. The intended sematics of the rpm.sign message is to notify a service when an rpm has been signed. Therefore, we should not be sending a message when the sigkey is empty. --- plugins/hub/protonmsg.py | 2 ++ tests/test_plugins/test_protonmsg.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/plugins/hub/protonmsg.py b/plugins/hub/protonmsg.py index f1b9864c..417c2f4e 100644 --- a/plugins/hub/protonmsg.py +++ b/plugins/hub/protonmsg.py @@ -196,6 +196,8 @@ def prep_import(cbtype, *args, **kws): @convert_datetime @callback('postRPMSign') def prep_rpm_sign(cbtype, *args, **kws): + if not kws['sigkey']: + return address = 'sign.rpm' props = {'type': cbtype[4:], 'sigkey': kws['sigkey'], diff --git a/tests/test_plugins/test_protonmsg.py b/tests/test_plugins/test_protonmsg.py index 5709a36d..a223bd61 100644 --- a/tests/test_plugins/test_protonmsg.py +++ b/tests/test_plugins/test_protonmsg.py @@ -123,6 +123,18 @@ class TestProtonMsg(unittest.TestCase): rpm_version=rpm['version'], rpm_release=rpm['release'], **build) + def test_prep_rpm_sign_no_sigkey(self): + build = {'name': 'test-pkg', + 'version': '1.0', + 'release': '1'} + rpm = {'name': 'test-pkg-subpkg', + 'version': '2.0', + 'release': '2'} + sigkey = '' + protonmsg.prep_rpm_sign('postRPMSign', sigkey=sigkey, sighash='fedcba9876543210', + build=build, rpm=rpm) + self.assertFalse(hasattr(context, 'protonmsg_msgs')) + def test_prep_tag(self): build = {'name': 'test-pkg', 'version': '1.0', 'release': '1'} protonmsg.prep_tag('postTag', tag={'name': 'test-tag'},