From e75db08b3d8aceb73469f1f5dfa702e78453276d Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Oct 19 2017 17:41:51 +0000 Subject: 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. --- diff --git a/plugins/hub/protonmsg.py b/plugins/hub/protonmsg.py index f1b9864..417c2f4 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 5709a36..a223bd6 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'},