Some checks failed
Build-Release-Image / Build-Image (linux/arm64) (push) Failing after 12m22s
Build-Release-Image / Build-Image (linux/amd64) (push) Has been cancelled
Build-Release-Image / Merge-Images (push) Has been cancelled
Build-Release-Image / Create-Release (push) Has been cancelled
Build-Release-Image / Notify (push) Has been cancelled
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from app import config
|
|
from app.dns_utils import set_global_dns_client, InMemoryDNSClient
|
|
from app.email_utils import get_email_local_part
|
|
from app.models import Mailbox
|
|
from tests.utils import create_new_user, random_email
|
|
|
|
dns_client = InMemoryDNSClient()
|
|
|
|
|
|
def setup_module():
|
|
set_global_dns_client(dns_client)
|
|
|
|
|
|
def teardown_module():
|
|
set_global_dns_client(None)
|
|
|
|
|
|
def test_is_proton_with_email_domain():
|
|
user = create_new_user()
|
|
mailbox = Mailbox.create(
|
|
user_id=user.id, email=f"test@{config.PROTON_EMAIL_DOMAINS[0]}"
|
|
)
|
|
assert mailbox.is_proton()
|
|
mailbox = Mailbox.create(user_id=user.id, email="a@b.c")
|
|
assert not mailbox.is_proton()
|
|
|
|
|
|
def test_is_proton_with_mx_domain():
|
|
email = random_email()
|
|
dns_client.set_mx_records(
|
|
get_email_local_part(email), {10: config.PROTON_MX_SERVERS}
|
|
)
|
|
user = create_new_user()
|
|
mailbox = Mailbox.create(user_id=user.id, email=email)
|
|
assert mailbox.is_proton()
|
|
dns_client.set_mx_records(get_email_local_part(email), {10: ["nowhere.net"]})
|
|
assert not mailbox.is_proton()
|