This commit is contained in:
2023-03-14 12:00:06 +00:00
parent 1a6a7e079b
commit 822855d584
7 changed files with 67 additions and 4 deletions

View File

@ -368,3 +368,19 @@ def test_send_email_from_non_canonical_matches_already_existing_user(flask_clien
assert len(email_logs) == 1
assert email_logs[0].alias_id == alias.id
assert email_logs[0].mailbox_id == user.default_mailbox_id
@mail_sender.store_emails_test_decorator
def test_break_loop_alias_as_mailbox(flask_client):
user = create_new_user()
alias = Alias.create_new_random(user)
user.default_mailbox.email = alias.email
Session.commit()
envelope = Envelope()
envelope.mail_from = random_email()
envelope.rcpt_tos = [alias.email]
msg = EmailMessage()
msg[headers.TO] = alias.email
msg[headers.SUBJECT] = random_string()
result = email_handler.handle(envelope, msg)
assert result == status.E525

View File

@ -66,7 +66,7 @@ def canonicalize_email_cases():
yield (f"a@{domain}", f"a@{domain}")
yield (f"a.b@{domain}", f"ab@{domain}")
yield (f"a.b+c@{domain}", f"ab@{domain}")
yield (f"a.b+c@other.com", f"a.b+c@other.com")
yield ("a.b+c@other.com", "a.b+c@other.com")
@pytest.mark.parametrize("dirty,clean", canonicalize_email_cases())

View File

@ -17,7 +17,7 @@ def create_new_user(email: Optional[str] = None, name: Optional[str] = None) ->
if not email:
email = f"user_{random_token(10)}@mailbox.test"
if not name:
name = f"Test User"
name = "Test User"
# new user has a different email address
user = User.create(
email=email,