-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flag to School model to allow use of subdomains; default True
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 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 |
---|---|---|
|
@@ -77,3 +77,43 @@ def test_force_ascii(self): | |
expected = "[email protected]" | ||
result = e.normalize_email(email) | ||
self.assertEqual(result, expected) | ||
|
||
def test_allow_subdomains(self): | ||
"""Test an email address with a subdomain.""" | ||
email = "[email protected]" | ||
expected = "[email protected]" | ||
domains = e.Domains("example.com", ()) | ||
result = e.normalize_email(email, domains=domains, allow_subdomains=True) | ||
self.assertEqual(result, expected) | ||
|
||
def test_allow_submdomains_invalid(self): | ||
"""Test an email address with a non-subdomain.""" | ||
email = "[email protected]" | ||
expected = "[email protected]" | ||
domains = e.Domains("example.com", ()) | ||
result = e.normalize_email(email, domains=domains, allow_subdomains=True) | ||
self.assertEqual(result, expected) | ||
|
||
def test_allow_subdomains_aliases(self): | ||
"""Test an email address with domain aliases and subdomains.""" | ||
email = "[email protected]" | ||
expected = "[email protected]" | ||
domains = e.Domains("example.com", ("example.edu",)) | ||
result = e.normalize_email(email, domains=domains, allow_subdomains=True) | ||
self.assertEqual(result, expected) | ||
|
||
def test_disallow_subdomains(self): | ||
"""Test an email address with a subdomain.""" | ||
email = "[email protected]" | ||
expected = "[email protected]" | ||
domains = e.Domains("example.com", ()) | ||
result = e.normalize_email(email, domains=domains, allow_subdomains=False) | ||
self.assertEqual(result, expected) | ||
|
||
def test_disallow_subdomains_aliases(self): | ||
"""Test an email address with domain aliases and subdomains.""" | ||
email = "[email protected]" | ||
expected = "[email protected]" | ||
domains = e.Domains("example.com", ("example.edu",)) | ||
result = e.normalize_email(email, domains=domains, allow_subdomains=False) | ||
self.assertEqual(result, expected) |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.3 on 2024-05-17 17:20 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('vb', '0012_add_percent_voted'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='school', | ||
name='allow_subdomains', | ||
field=models.BooleanField(default=True, help_text='Whether to allow arbitrary subdomains in school emails.'), | ||
), | ||
] |
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