Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21248 closed Bug (fixed)

Password tests failure on Django 1.5 (bcrypt related)

Reported by: Anssi Kääriäinen Owned by: nobody
Component: contrib.auth Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I get this failure when running Django's test suite on stable/1.5.x (at commit f8393edb52e3dc73185f2496bfa08463fa4ffa09):

======================================================================
ERROR: test_bcrypt (django.contrib.auth.tests.hashers.TestUtilsHashPass)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/akaariai/Programming/py27_venv/local/lib/python2.7/site-packages/django/contrib/auth/tests/hashers.py", line 100, in test_bcrypt
    self.assertTrue(check_password('lètmein', encoded))
  File "/home/akaariai/Programming/py27_venv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 55, in check_password
    is_correct = hasher.verify(password, encoded)
  File "/home/akaariai/Programming/py27_venv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 293, in verify
    return constant_time_compare(data, bcrypt.hashpw(force_bytes(password), data))
  File "/home/akaariai/Programming/py27_venv/local/lib/python2.7/site-packages/bcrypt/__init__.py", line 91, in hashpw
    raise TypeError("Unicode-objects must be encoded before hashing")
TypeError: Unicode-objects must be encoded before hashing

The failure happens only when bcrypt is installed. Tested bcrypt 1.0.0-1.0.2. The failure happens both on Python 2.7 and 3.2. It seems the error is there in first 1.5 release, too. The error isn't present in 1.6.x.

Change History (3)

comment:1 by Anssi Kääriäinen, 11 years ago

Django 1.5.x doesn't work with bcrypt, only with py-bcrypt (confirmed by dstufft). Skipping the test_bcrypt test for bcrypt library (but not py-bcrypt) seems good enough for now.

This commit seems to skip the test for bcrypt, but not for py-bcrypt.

comment:2 by Anssi Kääriäinen <akaariai@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 9f8a36eb20895d9e542820d5190bfa77ad1b85d9:

[1.5.x] Fixed #21248 -- Skipped test_bcrypt if no py-bcrypt found

Pre 1.6 Django worked only with py-bcrypt, not with bcrypt. Skipped
test_bcrypt when using bcrypt to avoid false positives.

comment:3 by Anssi Kääriäinen <akaariai@…>, 11 years ago

In 037ec1054ca8c08e65307f53e5851fe50ac5e8bf:

[1.4.x] Fixed #21248 -- Skipped test_bcrypt if no py-bcrypt found

Pre 1.6 Django worked only with py-bcrypt, not with bcrypt. Skipped
test_bcrypt when using bcrypt to avoid false positives.

Backpatch of 9f8a36eb20895d9e542820d5190bfa77ad1b85d9 from stable/1.5.x.

Note: See TracTickets for help on using tickets.
Back to Top