[Django] #20796: AUTHENTICATION_BACKENDS RemoteUserBackend breaks tests

9 views
Skip to first unread message

Django

unread,
Jul 24, 2013, 4:18:31 AM7/24/13
to django-...@googlegroups.com
#20796: AUTHENTICATION_BACKENDS RemoteUserBackend breaks tests
--------------------------------+--------------------
Reporter: python_monster | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------
After creating a new django (1, 5, 1, 'final', 0) project, configuring
RemoteUser functionality breaks tests:

== settings.py ==

{{{
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
DATABASES['default']['NAME'] = 'proj.db'
MIDDLEWARE_CLASSES += (
'django.contrib.auth.middleware.RemoteUserMiddleware',)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
'django.contrib.auth.backends.ModelBackend',
)
}}}

== python manage.py test auth.RemoteUserCustomTest ==

{{{
Creating test database for alias 'default'...
FFF.F
======================================================================
FAIL: test_header_disappears
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/virtualenv/proj/lib/python2.7/site-
packages/django/contrib/auth/tests/remote_user.py", line 109, in
test_header_disappears
self.assertEqual(response.context['user'].username, 'knownuser')
AssertionError: 'know...@example.com' != 'knownuser'

======================================================================
FAIL: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/virtualenv/proj/lib/python2.7/site-
packages/django/contrib/auth/tests/remote_user.py", line 188, in
test_known_user
super(RemoteUserCustomTest, self).test_known_user()
File "/opt/virtualenv/proj/lib/python2.7/site-
packages/django/contrib/auth/tests/remote_user.py", line 71, in
test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
AssertionError: 'know...@example.com' != 'knownuser'

======================================================================
FAIL: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/virtualenv/proj/lib/python2.7/site-
packages/django/contrib/auth/tests/remote_user.py", line 99, in
test_last_login
self.assertEqual(default_login, response.context['user'].last_login)
AssertionError: datetime.datetime(2000, 1, 1, 0, 0, tzinfo=<UTC>) !=
datetime.datetime(2013, 7, 24, 8, 2, 15, 485797, tzinfo=<UTC>)

======================================================================
FAIL: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/virtualenv/proj/lib/python2.7/site-
packages/django/contrib/auth/tests/remote_user.py", line 198, in
test_unknown_user
self.assertEqual(newuser.email, 'us...@example.com')
AssertionError: u'' != 'us...@example.com'

----------------------------------------------------------------------
Ran 5 tests in 0.071s

FAILED (failures=4)
Destroying test database for alias 'default'...

}}}

== python manage.py test auth.RemoteUserNoCreateTest ==

{{{
Creating test database for alias 'default'...
....F
======================================================================
FAIL: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/virtualenv/proj/lib/python2.7/site-
packages/django/contrib/auth/tests/remote_user.py", line 145, in
test_unknown_user
self.assertTrue(response.context['user'].is_anonymous())
AssertionError: False is not true

----------------------------------------------------------------------
Ran 5 tests in 0.440s

FAILED (failures=1)
Destroying test database for alias 'default'...
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20796>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 25, 2013, 9:39:00 AM7/25/13
to django-...@googlegroups.com
#20796: AUTHENTICATION_BACKENDS RemoteUserBackend breaks tests
--------------------------------+--------------------------------------

Reporter: python_monster | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by timo):

* cc: timograham@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

By listing `'django.contrib.auth.backends.RemoteUserBackend'` in your
settings, it's causing the failing tests to use that backend rather than
`'django.contrib.auth.tests.test_remote_user.CustomRemoteUserBackend'`. We
could fix this by prepending (rather than appending) `self.backend` in the
`setUp` method - that would fix the first set of failures.

However, the failing test in `RemoteUserCustomTest` actually requires
`'django.contrib.auth.backends.RemoteUserBackend'` not to be in
`AUTHENTICATION_BACKENDS` since the user does authenticate against that
backend. I suppose the tests need to be rewritten not to depend on the
values of `settings.AUTHENTICATION_BACKENDS`?

--
Ticket URL: <https://code.djangoproject.com/ticket/20796#comment:1>

Django

unread,
Jul 28, 2013, 7:31:53 PM7/28/13
to django-...@googlegroups.com
#20796: AUTHENTICATION_BACKENDS RemoteUserBackend breaks tests
--------------------------------+--------------------------------------
Reporter: python_monster | Owner: nobody
Type: Bug | Status: closed
Component: contrib.auth | Version: 1.5
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #13394

--
Ticket URL: <https://code.djangoproject.com/ticket/20796#comment:2>

Reply all
Reply to author
Forward
0 new messages