Skip to content

Commit

Permalink
Expect the correct schema for buildsys.tag
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bowlofeggs committed May 23, 2019
1 parent c869c36 commit ca37184
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 37 deletions.
28 changes: 10 additions & 18 deletions bodhi/server/consumers/signed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
}
Expand All @@ -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']

Expand Down
30 changes: 11 additions & 19 deletions bodhi/tests/server/consumers/test_signed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ca37184

Please sign in to comment.