allow user to create alias with domain that has ownership verified (and might not have MX verified)

This commit is contained in:
Son 2021-12-29 10:23:29 +01:00
parent 335a89f912
commit 80b0af91e5
4 changed files with 20 additions and 10 deletions

View file

@ -694,7 +694,7 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
return sub return sub
def verified_custom_domains(self) -> List["CustomDomain"]: def verified_custom_domains(self) -> List["CustomDomain"]:
return CustomDomain.filter_by(user_id=self.id, verified=True).all() return CustomDomain.filter_by(user_id=self.id, ownership_verified=True).all()
def mailboxes(self) -> List["Mailbox"]: def mailboxes(self) -> List["Mailbox"]:
"""list of mailbox that user own""" """list of mailbox that user own"""

View file

@ -126,7 +126,9 @@ def test_custom_domain_alias(flask_client):
user = login(flask_client) user = login(flask_client)
# create a custom domain # create a custom domain
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True, commit=True) CustomDomain.create(
user_id=user.id, domain="ab.cd", ownership_verified=True, commit=True
)
signed_suffix = signer.sign("@ab.cd").decode() signed_suffix = signer.sign("@ab.cd").decode()
@ -210,7 +212,9 @@ def test_cannot_create_alias_in_trash(flask_client):
user = login(flask_client) user = login(flask_client)
# create a custom domain # create a custom domain
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True, commit=True) CustomDomain.create(
user_id=user.id, domain="ab.cd", ownership_verified=True, commit=True
)
signed_suffix = signer.sign("@ab.cd").decode() signed_suffix = signer.sign("@ab.cd").decode()

View file

@ -40,7 +40,9 @@ def test_with_hostname(flask_client):
def test_with_custom_domain(flask_client): def test_with_custom_domain(flask_client):
user = login(flask_client) user = login(flask_client)
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True, commit=True) CustomDomain.create(
user_id=user.id, domain="ab.cd", ownership_verified=True, commit=True
)
r = flask_client.post( r = flask_client.post(
url_for("api.new_random_alias", hostname="www.test.com"), url_for("api.new_random_alias", hostname="www.test.com"),

View file

@ -101,7 +101,7 @@ def test_verify_prefix_suffix(flask_client):
user = login(flask_client) user = login(flask_client)
Session.commit() Session.commit()
CustomDomain.create(user_id=user.id, domain="test.com", verified=True) CustomDomain.create(user_id=user.id, domain="test.com", ownership_verified=True)
assert verify_prefix_suffix(user, "prefix", "@test.com") assert verify_prefix_suffix(user, "prefix", "@test.com")
assert not verify_prefix_suffix(user, "prefix", "@abcd.com") assert not verify_prefix_suffix(user, "prefix", "@abcd.com")
@ -114,7 +114,7 @@ def test_verify_prefix_suffix(flask_client):
def test_available_suffixes(flask_client): def test_available_suffixes(flask_client):
user = login(flask_client) user = login(flask_client)
CustomDomain.create(user_id=user.id, domain="test.com", verified=True) CustomDomain.create(user_id=user.id, domain="test.com", ownership_verified=True)
assert len(get_available_suffixes(user)) > 0 assert len(get_available_suffixes(user)) > 0
@ -129,7 +129,9 @@ def test_available_suffixes_default_domain(flask_client):
user = login(flask_client) user = login(flask_client)
sl_domain = SLDomain.first() sl_domain = SLDomain.first()
CustomDomain.create(user_id=user.id, domain="test.com", verified=True, commit=True) CustomDomain.create(
user_id=user.id, domain="test.com", ownership_verified=True, commit=True
)
user.default_alias_public_domain_id = sl_domain.id user.default_alias_public_domain_id = sl_domain.id
@ -146,9 +148,11 @@ def test_available_suffixes_default_domain(flask_client):
def test_available_suffixes_random_prefix_generation(flask_client): def test_available_suffixes_random_prefix_generation(flask_client):
user = login(flask_client) user = login(flask_client)
CustomDomain.create(user_id=user.id, domain="test.com", verified=True, commit=True) CustomDomain.create(
user_id=user.id, domain="test.com", ownership_verified=True, commit=True
)
cd2 = CustomDomain.create( cd2 = CustomDomain.create(
user_id=user.id, domain="test2.com", verified=True, commit=True user_id=user.id, domain="test2.com", ownership_verified=True, commit=True
) )
user.default_alias_custom_domain_id = cd2.id user.default_alias_custom_domain_id = cd2.id
@ -255,7 +259,7 @@ def test_add_alias_in_custom_domain_trash(flask_client):
user = login(flask_client) user = login(flask_client)
custom_domain = CustomDomain.create( custom_domain = CustomDomain.create(
user_id=user.id, domain="ab.cd", verified=True, commit=True user_id=user.id, domain="ab.cd", ownership_verified=True, commit=True
) )
# delete a custom-domain alias: alias should go the DomainDeletedAlias # delete a custom-domain alias: alias should go the DomainDeletedAlias