Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #20916 - Added support for a `simple_login` test client method. #2570

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
2 participants
@jfilipe
Copy link

commented Apr 16, 2014

simple_login takes a user instance and logs you in as that user. You no longer have to manage user credentials in tests.

Ticket: 20916.

Todo:

  • Add docs
@@ -107,6 +109,9 @@ def setup_test_environment():
request._original_allowed_hosts = settings.ALLOWED_HOSTS
settings.ALLOWED_HOSTS = ['*']

auth._original_authentication_backends = settings.AUTHENTICATION_BACKENDS

This comment has been minimized.

Copy link
@timgraham

timgraham Aug 29, 2014

Member

Shouldn't this patching happen in the simple_login() method? Otherwise, login() is affected as well which means it wouldn't reject invalid credentials Am I missing something?

@@ -36,8 +37,7 @@ def check_user_model(**kwargs):

# Check that the username field is unique
if not cls._meta.get_field(cls.USERNAME_FIELD).unique:
if (settings.AUTHENTICATION_BACKENDS ==
('django.contrib.auth.backends.ModelBackend',)):
if (settings.AUTHENTICATION_BACKENDS == TEST_ENVIRON_AUTHENTICATION_BACKENDS):

This comment has been minimized.

Copy link
@timgraham

timgraham Aug 29, 2014

Member

This change isn't correct as it will disable the check unless testing. Maybe this would work: if 'django.contrib.auth.backends.ModelBackend' in settings.AUTHENTICATION_BACKENDS

@timgraham

This comment has been minimized.

Copy link
Member

commented Oct 8, 2014

Closing in absence of follow-up. Please send a new PR if you can update it, thanks.

@timgraham timgraham closed this Oct 8, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.