-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup tests that interact with django-allauth ACCOUNT_PREVENT_ENUMERA…
…TION ACCOUNT_PREVENT_ENUMERATION was introduced in django-allauth 0.52.0, and interferes with our expectations. This should probably be turned on! But for now disable it by default to keep the changeset minimal. Allauth _used_ to iterate over users to check for email uniquenss but stopped at some point, so we have to create an EmailAdress object for the user in the relevant test-case for duplicate emails
- Loading branch information
Showing
3 changed files
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase, RequestFactory | ||
from django.test import TestCase | ||
|
||
from allauth.account.forms import SignupForm | ||
from allauth.account.models import EmailAddress | ||
|
||
from users.forms import UserProfileForm, MembershipForm | ||
|
||
|
@@ -50,8 +51,8 @@ def test_duplicate_username(self): | |
self.assertIn('username', form.errors) | ||
|
||
def test_duplicate_email(self): | ||
User.objects.create_user('test1', '[email protected]', 'testpass') | ||
request = RequestFactory().get('/') | ||
user = User.objects.create_user('test1', '[email protected]', 'testpass') | ||
EmailAddress.objects.create(user=user, email="[email protected]") | ||
|
||
form = SignupForm(data={ | ||
'username': 'username2', | ||
|
@@ -60,11 +61,8 @@ def test_duplicate_email(self): | |
'password2': 'password', | ||
}) | ||
|
||
self.assertTrue(form.is_valid()) | ||
with self.assertRaises(ValueError) as e: | ||
form.save(request) | ||
|
||
self.assertEqual(str(e.exception), '[email protected]') | ||
self.assertFalse(form.is_valid()) | ||
self.assertIn('email', form.errors) | ||
|
||
def test_newline_in_username(self): | ||
# Note that since Django 1.9, forms.CharField().strip is True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters