[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Normalize captcha's solution input
commit e3de9228f7f1969c2f8569f35f57603e2c2d8641
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon Jan 20 18:29:23 2020 -0800
Normalize captcha's solution input
Honestly I don't know why BridgeDB has these tests at all, but these pass byte
input as the solution so accounting for this.
Traceback (most recent call last):
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_captcha.py", line 287, in test_check_encoding_ascii
True)
File "/usr/local/lib/python3.5/dist-packages/twisted/trial/_synctest.py", line 432, in assertEqual
super(_Assertions, self).assertEqual(first, second, msg)
File "/usr/lib/python3.5/unittest/case.py", line 820, in assertEqual
assertion_func(first, second, msg=msg)
File "/usr/lib/python3.5/unittest/case.py", line 813, in _baseAssertEqual
raise self.failureException(msg)
twisted.trial.unittest.FailTest: False != True
With this the tests finally pass!
---
bridgedb/captcha.py | 4 ++++
bridgedb/test/test_captcha.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/bridgedb/captcha.py b/bridgedb/captcha.py
index 6d8e8f7..23bb333 100644
--- a/bridgedb/captcha.py
+++ b/bridgedb/captcha.py
@@ -270,6 +270,10 @@ class GimpCaptcha(Captcha):
:returns: ``True`` if the CAPTCHA solution was correct and not
stale. ``False`` otherwise.
"""
+
+ if isinstance(solution, bytes):
+ solution = solution.decode('utf-8')
+
hmacIsValid = False
if not solution:
diff --git a/bridgedb/test/test_captcha.py b/bridgedb/test/test_captcha.py
index d504761..d52440d 100644
--- a/bridgedb/test/test_captcha.py
+++ b/bridgedb/test/test_captcha.py
@@ -182,7 +182,7 @@ class GimpCaptchaTests(unittest.TestCase):
timestamp = int(decrypted[:12].lstrip(b'0'))
# The timestamp should be within 30 seconds of right now.
self.assertApproximates(timestamp, int(time.time()), 30)
- self.assertEqual('ThisAnswerShouldDecryptToThis', decrypted[12:])
+ self.assertEqual(b'ThisAnswerShouldDecryptToThis', decrypted[12:])
def test_get(self):
"""GimpCaptcha.get() should return image and challenge strings."""
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits