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

Allow superuser to not be verified #145

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for custom flag field
  • Loading branch information
Neraste committed May 26, 2021
commit a45882dca0467e8362add876c8b6f5fb17fd91c2
24 changes: 24 additions & 0 deletions tests/api/views/register_email/test_verify_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ def test_with_username_as_verification_id_ok(self):
self.user.refresh_from_db()
self.assertEqual(self.user.email, self.new_email)

@override_rest_registration_settings({
"REGISTER_VERIFICATION_ENABLED": True,
"REGISTER_EMAIL_VERIFICATION_ENABLED": True,
'USER_VERIFICATION_FLAG_FIELD': 'is_staff',
})
def test_with_custom_flag_field_ok(self):
# a superuser is created with command createsuperuser
# the flag field (here is_staff) is not set
self.setup_user()
self.user.is_superuser = True
self.user.is_staff = False
self.user.save()

signer = RegisterEmailSigner({
'user_id': self.user.id,
'email': self.new_email,
})
data = signer.get_signed_data()
request = self.create_post_request(data)
response = self.view_func(request)
self.assert_valid_response(response, status.HTTP_200_OK)
self.user.refresh_from_db()
self.assertEqual(self.user.email, self.new_email)

@override_settings(
REST_REGISTRATION={
'REGISTER_EMAIL_VERIFICATION_URL': REGISTER_EMAIL_VERIFICATION_URL,
Expand Down