Unverified Commit e3de9228 authored by Damian Johnson's avatar Damian Johnson Committed by Philipp Winter
Browse files

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!
parent 28b3fb3d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -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."""