Skip to content

Commit

Permalink
Decode the captcha key so it is a string.
Browse files Browse the repository at this point in the history
fixes #2786

Signed-off-by: Randy Barlow <randy@electronsweatshop.com>
(cherry picked from commit 577f47d)

# Conflicts:
#	docs/user/release_notes.rst
  • Loading branch information
bowlofeggs authored and mergify[bot] committed Nov 27, 2018
1 parent c19ea9b commit a6f9302
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bodhi/server/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def generate_captcha(context, request):
"""
settings = request.registry.settings
plainkey, value = math_generator(plainkey=None, settings=settings)
cipherkey = encrypt(plainkey, settings)
cipherkey = encrypt(plainkey, settings).decode('utf8')
url = request.route_url('captcha_image', cipherkey=cipherkey)
request.session['captcha'] = cipherkey # Remember this to stop replay.
return cipherkey, url
Expand Down
1 change: 1 addition & 0 deletions bodhi/tests/server/test_captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def test_captcha_can_be_solved(self):
cipherkey, url = captcha.generate_captcha(None, request)

self.assertEqual(request.session['captcha'], cipherkey)
self.assertTrue(isinstance(cipherkey, six.text_type))
request.route_url.assert_called_once_with('captcha_image', cipherkey=cipherkey)
self.assertEqual(url, request.route_url.return_value)
# Let's cheat and find out what the correct value for this cipherkey is and make sure it is
Expand Down
1 change: 1 addition & 0 deletions docs/user/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Bug fixes
* Catch ``http.client.IncompleteRead`` while Composing and retry (:issue:`2758`).
* Correctly handle timestamps from Koji (:issue:`2768`).
* Do not reverse the logout/reboot options in the web UI on Python 3 (:issue:`2778`).
* The captcha now works under Python 3 (:issue:`2786`).


Contributors
Expand Down

0 comments on commit a6f9302

Please sign in to comment.