mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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 <kevr@0cost.org>
This commit is contained in:
parent
16bdbee520
commit
ad1d5a1217
2 changed files with 3 additions and 17 deletions
|
@ -13,7 +13,7 @@ from urllib.parse import urlparse
|
||||||
import fastapi
|
import fastapi
|
||||||
import pygit2
|
import pygit2
|
||||||
|
|
||||||
from email_validator import EmailNotValidError, EmailUndeliverableError, validate_email
|
from email_validator import EmailSyntaxError, validate_email
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
import aurweb.config
|
import aurweb.config
|
||||||
|
@ -51,10 +51,8 @@ def valid_username(username):
|
||||||
|
|
||||||
def valid_email(email):
|
def valid_email(email):
|
||||||
try:
|
try:
|
||||||
validate_email(email)
|
validate_email(email, check_deliverability=False)
|
||||||
except EmailUndeliverableError:
|
except EmailSyntaxError:
|
||||||
return False
|
|
||||||
except EmailNotValidError:
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -446,18 +446,6 @@ def test_post_register_error_invalid_email(client: TestClient):
|
||||||
assert "The email address is invalid." in content
|
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):
|
def test_post_register_invalid_backup_email(client: TestClient):
|
||||||
with client as request:
|
with client as request:
|
||||||
response = post_register(request, BE="bad@email")
|
response = post_register(request, BE="bad@email")
|
||||||
|
|
Loading…
Add table
Reference in a new issue