Opened 15 years ago

Closed 14 years ago

Last modified 12 years ago

#5938 closed (wontfix)


Reported by: Thomas Güttler <hv@…> Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords:
Cc: hv@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I don't want to use a password in the unittests. This patch adds the method login_user() to

The patch contains updates for the documentation and for the regression tests.

Attachments (1)

testclient_login_without_password.diff (2.5 KB) - added by Thomas Güttler <hv@…> 15 years ago.

Download all attachments as: .zip

Change History (6)

Changed 15 years ago by Thomas Güttler <hv@…>

comment:1 Changed 15 years ago by MichaelBishop

Triage Stage: UnreviewedDesign decision needed

The patch appears complete with documentation. Decision needs to be made if this should be included.

comment:2 Changed 14 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

If you have a test user, you can set up the test password to be whatever you want, so the problem isn't putting passwords in plain text. The login() interface isn't that difficult to use, so you can't make a 'shortcut/ease of use argument' either.

Unless someone can provide a particularly compelling reason for adding this method, I'm marking it wontfix.

comment:3 Changed 14 years ago by Thomas Güttler

Cc: hv@… removed

comment:4 Changed 14 years ago by Thomas Güttler

Cc: hv@… added

I still think this patch is useful. I have a bunch of read only tests which I run against the production system.
And I don't want to store the password in my code.

Since I try to not modify django code I found this dirty solution:

def fake_authenticate(user):
    assert isinstance(user, User), user
    if not hasattr(user, "backend"): 
        user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__) 
    return user

def client_login_user(client, user):
    # Change to django code base was rejected ( 
    # Dirty hack to login user-object without knowing his password.
    # Not threadsafe.
    assert isinstance(user, User), user
    assert isinstance(client, Client), client
    from django.test import client as client_module
    return user

comment:5 Changed 12 years ago by Thomas Güttler

New ticket #14350

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