From ca3718486eebbf27c07a600bc4670f4f942ed2ad Mon Sep 17 00:00:00 2001 From: Randy Barlow Date: Mon, 20 May 2019 16:53:33 -0400 Subject: [PATCH] Expect the correct schema for buildsys.tag We had been expecting messages with topic buildsys.tag to have a msg key in them, but they do not. This was how fedmsg worked, but now that we are receiving fedora messages that key is no longer there (it was silly, after all). fixes #3240 Signed-off-by: Randy Barlow --- bodhi/server/consumers/signed.py | 28 +++++++------------ bodhi/tests/server/consumers/test_signed.py | 30 ++++++++------------- 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/bodhi/server/consumers/signed.py b/bodhi/server/consumers/signed.py index fac64e0c7d..31f4f29f7e 100644 --- a/bodhi/server/consumers/signed.py +++ b/bodhi/server/consumers/signed.py @@ -52,23 +52,15 @@ def __call__(self, message: fedora_messaging.api.Message): Example message format:: { 'body': { - 'i': 628, - 'timestamp': 1484692585, - 'msg_id': '2017-821031da-be3a-4f4b-91df-0baa834ca8a4', - 'crypto': 'x509', - 'topic': 'org.fedoraproject.prod.buildsys.tag', - 'signature': '100% real please trust me', - 'msg': { - 'build_id': 442562, - 'name': 'colord', - 'tag_id': 214, - 'instance': 's390', - 'tag': 'f26-updates-testing-pending', - 'user': 'sharkcz', - 'version': '1.3.4', - 'owner': 'sharkcz', - 'release': '1.fc26' - }, + 'build_id': 442562, + 'name': 'colord', + 'tag_id': 214, + 'instance': 's390', + 'tag': 'f26-updates-testing-pending', + 'user': 'sharkcz', + 'version': '1.3.4', + 'owner': 'sharkcz', + 'release': '1.fc26' }, } @@ -79,7 +71,7 @@ def __call__(self, message: fedora_messaging.api.Message): Args: message: The incoming message in the format described above. """ - message = message.body['msg'] + message = message.body build_nvr = '%(name)s-%(version)s-%(release)s' % message tag = message['tag'] diff --git a/bodhi/tests/server/consumers/test_signed.py b/bodhi/tests/server/consumers/test_signed.py index aafca2478b..8147d47255 100644 --- a/bodhi/tests/server/consumers/test_signed.py +++ b/bodhi/tests/server/consumers/test_signed.py @@ -32,23 +32,15 @@ def setUp(self): self.sample_message = Message( topic='', body={ - 'i': 628, - 'timestamp': 1484692585, - 'msg_id': '2017-821031da-be3a-4f4b-91df-0baa834ca8a4', - 'crypto': 'x509', - 'topic': 'org.fedoraproject.prod.buildsys.tag', - 'signature': '100% real please trust me', - 'msg': { - 'build_id': 442562, - 'name': 'colord', - 'tag_id': 214, - 'instance': 's390', - 'tag': 'f26-updates-testing-pending', - 'user': 'sharkcz', - 'version': '1.3.4', - 'owner': 'sharkcz', - 'release': '1.fc26' - }, + 'build_id': 442562, + 'name': 'colord', + 'tag_id': 214, + 'instance': 's390', + 'tag': 'f26-updates-testing-pending', + 'user': 'sharkcz', + 'version': '1.3.4', + 'owner': 'sharkcz', + 'release': '1.fc26' }, ) self.handler = signed.SignedHandler() @@ -58,7 +50,7 @@ def test_consume(self, mock_build_model): """Assert that messages marking the build as signed updates the database""" build = mock_build_model.get.return_value build.signed = False - build.release.pending_testing_tag = self.sample_message.body["msg"]["tag"] + build.release.pending_testing_tag = self.sample_message.body["tag"] self.handler(self.sample_message) self.assertTrue(build.signed is True) @@ -101,7 +93,7 @@ def test_consume_no_build(self, mock_build_model, mock_log): def test_consume_duplicate(self, mock_build_model, mock_log): """Assert that the handler is idempotent.""" build = mock_build_model.get.return_value - build.release.pending_testing_tag = self.sample_message.body["msg"]["tag"] + build.release.pending_testing_tag = self.sample_message.body["tag"] build.signed = True self.handler(self.sample_message)