views:

67

answers:

2

In Django, when I run "manage.py test", I get a lot of authentication related failures. Some examples:

FAIL: test_password_change_succeeds -- AssertionError 200 != 302
FAIL: Logout without next_page option renders the default template -- AssertionError 200 != 302

And:

Failed example:
    form.non_field_errors()
Expected:
    [u'This account is inactive.']
Got:
    [u'Please enter correct username and password....']

I've configured settings.py so that Django will accept authentication from Apache2. In settings, MIDDLEWARE_CLASSES includes 'AuthenticationMiddleware' and 'RemoteUserMiddleware', and AUTHENTICATION_BACKENDS includes 'RemoteUserBackend'.

How do I figure out the problem here?

UPDATE 2 I cleared the test errors by commenting out the setting of AUTHENTICATION_BACKENDS. Now I have to think about the authentication state I need in my test environment, but at least I've cleared this issue.

The first update had a reference to a question I've since deleted.

A: 

If your authentication only works via Apache, I wouldn't expect it to work in tests - the test runner doesn't use Apache. You will need to set up a dummy account in the normal database authentication framework.

Daniel Roseman
I have such a user, created with User.objects.create_user() -- still no go. My code is brought down from a SVN repository, and I've run ./manage.py syncdb, but is it possible that Django is expecting some state in the database that isn't present b/c I haven't gone through some step like 'django-admin.py startproject'?
chernevik
A: 

As noted above, commenting out the setting of AUTHENTICATION_BACKENDS made the test errors go away.

chernevik