Skip to content

Added test to check email length in to_alias field #28

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
5 changes: 5 additions & 0 deletions drfpasswordless/models.py
Original file line number Diff line number Diff line change
@@ -60,3 +60,8 @@ class CallbackToken(AbstractBaseCallbackToken):

class Meta(AbstractBaseCallbackToken.Meta):
verbose_name = 'Callback Token'

def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
self.full_clean()
super().save(force_insert, force_update, using, update_fields)
9 changes: 8 additions & 1 deletion tests/test_authentication.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.core.exceptions import ValidationError
from rest_framework import status
from rest_framework.authtoken.models import Token
from rest_framework.test import APITestCase

from django.contrib.auth import get_user_model
from drfpasswordless.settings import api_settings, DEFAULTS
from drfpasswordless.utils import CallbackToken
from drfpasswordless.utils import CallbackToken, create_callback_token_for_user

User = get_user_model()

@@ -24,6 +25,12 @@ def test_email_signup_failed(self):
response = self.client.post(self.url, data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_email_callback_token_create(self):
email = '1234567890' * 23 + '@example.com'
user = User.objects.create(email=email)
with self.assertRaises(ValidationError):
create_callback_token_for_user(user, "EMAIL")

def test_email_signup_success(self):
email = 'aaron@example.com'
data = {'email': email}