Verified Commit ad1d5a12 authored by Kevin Morris's avatar Kevin Morris
Browse files

fix: don't check email deliverability when verifying input



For tests, we only care about emails having a valid syntax.
I don't think we should verify this at all, as aurweb.scripts.notify
will timeout if it cant deliver via sendmail/smtp.

Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 16bdbee5
......@@ -13,7 +13,7 @@ from urllib.parse import urlparse
import fastapi
import pygit2
from email_validator import EmailNotValidError, EmailUndeliverableError, validate_email
from email_validator import EmailSyntaxError, validate_email
from fastapi.responses import JSONResponse
import aurweb.config
......@@ -51,10 +51,8 @@ def valid_username(username):
def valid_email(email):
try:
validate_email(email)
except EmailUndeliverableError:
return False
except EmailNotValidError:
validate_email(email, check_deliverability=False)
except EmailSyntaxError:
return False
return True
......
......@@ -446,18 +446,6 @@ def test_post_register_error_invalid_email(client: TestClient):
assert "The email address is invalid." in content
def test_post_register_error_undeliverable_email(client: TestClient):
with client as request:
# At the time of writing, webchat.freenode.net does not contain
# mx records; if it ever does, it'll break this test.
response = post_register(request, E="email@bad.c")
assert response.status_code == int(HTTPStatus.BAD_REQUEST)
content = response.content.decode()
assert "The email address is invalid." in content
def test_post_register_invalid_backup_email(client: TestClient):
with client as request:
response = post_register(request, BE="bad@email")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment