4.66.0
Some checks failed
Build-Release-Image / Build-Image (linux/arm64) (push) Failing after 7m18s
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
Some checks failed
Build-Release-Image / Build-Image (linux/arm64) (push) Failing after 7m18s
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
This commit is contained in:
@ -647,8 +647,8 @@ def test_get_alias(flask_client):
|
||||
|
||||
|
||||
def test_is_reverse_alias(flask_client):
|
||||
assert is_reverse_alias("ra+abcd@sl.local")
|
||||
assert is_reverse_alias("reply+abcd@sl.local")
|
||||
assert is_reverse_alias("ra+abcd@sl.lan")
|
||||
assert is_reverse_alias("reply+abcd@sl.lan")
|
||||
|
||||
assert not is_reverse_alias("ra+abcd@test.org")
|
||||
assert not is_reverse_alias("reply+abcd@test.org")
|
||||
|
@ -17,7 +17,7 @@ def test_with_hostname(flask_client):
|
||||
)
|
||||
|
||||
assert r.status_code == 201
|
||||
assert r.json["alias"].endswith("d1.test")
|
||||
assert r.json["alias"].endswith("d1.lan")
|
||||
|
||||
# make sure alias starts with the suggested prefix
|
||||
assert r.json["alias"].startswith("test")
|
||||
|
@ -112,14 +112,14 @@ def test_get_alias_infos_with_pagination_v3_no_duplicate_when_empty_contact(
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
)
|
||||
|
||||
Contact.create(
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact2@example.com",
|
||||
reply_email="rep2@sl.local",
|
||||
reply_email="rep2@sl.lan",
|
||||
)
|
||||
|
||||
alias_infos = get_alias_infos_with_pagination_v3(user)
|
||||
|
@ -15,7 +15,7 @@ def test_get_setting(flask_client):
|
||||
assert r.json == {
|
||||
"alias_generator": "word",
|
||||
"notification": True,
|
||||
"random_alias_default_domain": "sl.local",
|
||||
"random_alias_default_domain": "sl.lan",
|
||||
"sender_format": "AT",
|
||||
"random_alias_suffix": "word",
|
||||
}
|
||||
@ -47,7 +47,7 @@ def test_update_settings_random_alias_default_domain(flask_client):
|
||||
custom_domain = CustomDomain.create(
|
||||
domain=random_domain(), verified=True, user_id=user.id, flush=True
|
||||
)
|
||||
assert user.default_random_alias_domain() == "sl.local"
|
||||
assert user.default_random_alias_domain() == "sl.lan"
|
||||
|
||||
r = flask_client.patch(
|
||||
"/api/setting", json={"random_alias_default_domain": "invalid"}
|
||||
@ -55,10 +55,10 @@ def test_update_settings_random_alias_default_domain(flask_client):
|
||||
assert r.status_code == 400
|
||||
|
||||
r = flask_client.patch(
|
||||
"/api/setting", json={"random_alias_default_domain": "d1.test"}
|
||||
"/api/setting", json={"random_alias_default_domain": "d1.lan"}
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert user.default_random_alias_domain() == "d1.test"
|
||||
assert user.default_random_alias_domain() == "d1.lan"
|
||||
|
||||
r = flask_client.patch(
|
||||
"/api/setting", json={"random_alias_default_domain": custom_domain.domain}
|
||||
|
@ -2,7 +2,7 @@ from random import random
|
||||
|
||||
from flask import url_for
|
||||
|
||||
from app import config
|
||||
from app.constants import JobType
|
||||
from app.db import Session
|
||||
from app.models import Job, ApiToCookieToken
|
||||
from tests.api.utils import get_new_user_and_api_key
|
||||
@ -48,7 +48,7 @@ def test_delete_with_sudo(flask_client):
|
||||
jobs = Job.all()
|
||||
assert len(jobs) == 1
|
||||
job = jobs[0]
|
||||
assert job.name == config.JOB_DELETE_ACCOUNT
|
||||
assert job.name == JobType.DELETE_ACCOUNT.value
|
||||
assert job.payload == {"user_id": user.id}
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ from init_app import add_sl_domains, add_proton_partner
|
||||
app = create_app()
|
||||
app.config["TESTING"] = True
|
||||
app.config["WTF_CSRF_ENABLED"] = False
|
||||
app.config["SERVER_NAME"] = "sl.test"
|
||||
app.config["SERVER_NAME"] = "sl.lan"
|
||||
|
||||
# enable pg_trgm extension
|
||||
with engine.connect() as conn:
|
||||
|
@ -28,7 +28,7 @@ def test_rate_limited_forward_phase_for_alias(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
)
|
||||
Session.commit()
|
||||
for _ in range(MAX_ACTIVITY_DURING_MINUTE_PER_ALIAS + 1):
|
||||
@ -52,7 +52,7 @@ def test_rate_limited_forward_phase_for_mailbox(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
)
|
||||
Session.commit()
|
||||
for _ in range(MAX_ACTIVITY_DURING_MINUTE_PER_MAILBOX + 1):
|
||||
@ -90,7 +90,7 @@ def test_rate_limited_reply_phase(flask_client):
|
||||
alias = Alias.create_new_random(user)
|
||||
Session.commit()
|
||||
|
||||
reply_email = f"reply-{random.random()}@sl.local"
|
||||
reply_email = f"reply-{random.random()}@sl.lan"
|
||||
contact = Contact.create(
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
|
@ -37,7 +37,7 @@ def prepare_complaint(
|
||||
contact = Contact.create(
|
||||
user_id=alias.user.id,
|
||||
alias_id=alias.id,
|
||||
website_email=f"contact{random.random()}@mailbox.test",
|
||||
website_email=f"contact{random.random()}@mailbox.lan",
|
||||
reply_email="d@e.f",
|
||||
commit=True,
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ def generate_unsub_block_contact_data() -> Iterable:
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
|
||||
@ -86,7 +86,7 @@ def generate_unsub_disable_alias_data() -> Iterable:
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
|
||||
@ -145,7 +145,7 @@ def generate_unsub_preserve_original_data() -> Iterable:
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
|
||||
@ -215,7 +215,7 @@ def test_unsub_preserves_sl_unsubscriber():
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
message = Message()
|
||||
|
@ -49,7 +49,7 @@ def test_old_subject_block_contact():
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email=f"{random()}@sl.local",
|
||||
reply_email=f"{random()}@sl.lan",
|
||||
block_forward=False,
|
||||
commit=True,
|
||||
)
|
||||
@ -92,7 +92,7 @@ def test_new_subject_block_contact():
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email=f"{random()}@sl.local",
|
||||
reply_email=f"{random()}@sl.lan",
|
||||
block_forward=False,
|
||||
commit=True,
|
||||
)
|
||||
@ -172,7 +172,7 @@ def test_request_disable_contact(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email=f"{random()}@sl.local",
|
||||
reply_email=f"{random()}@sl.lan",
|
||||
block_forward=False,
|
||||
commit=True,
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from sqlalchemy_utils.types.arrow import arrow
|
||||
|
||||
from app.config import JOB_DELETE_MAILBOX
|
||||
from app.constants import JobType
|
||||
from app.db import Session
|
||||
from app.mail_sender import mail_sender
|
||||
from app.models import Alias, Mailbox, Job, AliasMailbox
|
||||
@ -21,7 +21,7 @@ def test_delete_mailbox_transfer_mailbox_primary(flask_client):
|
||||
alias_id = Alias.create_new(user, "prefix", mailbox_id=m1.id).id
|
||||
AliasMailbox.create(alias_id=alias_id, mailbox_id=m2.id)
|
||||
job = Job.create(
|
||||
name=JOB_DELETE_MAILBOX,
|
||||
name=JobType.DELETE_MAILBOX.value,
|
||||
payload={"mailbox_id": m1.id, "transfer_mailbox_id": m2.id},
|
||||
run_at=arrow.now(),
|
||||
commit=True,
|
||||
@ -43,7 +43,7 @@ def test_delete_mailbox_no_email(flask_client):
|
||||
user_id=user.id, email=random_email(), verified=True, flush=True
|
||||
)
|
||||
job = Job.create(
|
||||
name=JOB_DELETE_MAILBOX,
|
||||
name=JobType.DELETE_MAILBOX.value,
|
||||
payload={"mailbox_id": m1.id, "transfer_mailbox_id": None, "send_mail": False},
|
||||
run_at=arrow.now(),
|
||||
commit=True,
|
||||
@ -70,7 +70,7 @@ def test_delete_mailbox_transfer_mailbox_in_list(flask_client):
|
||||
alias_id = Alias.create_new(user, "prefix", mailbox_id=m1.id).id
|
||||
AliasMailbox.create(alias_id=alias_id, mailbox_id=m2.id)
|
||||
job = Job.create(
|
||||
name=JOB_DELETE_MAILBOX,
|
||||
name=JobType.DELETE_MAILBOX.value,
|
||||
payload={"mailbox_id": m2.id, "transfer_mailbox_id": m3.id},
|
||||
run_at=arrow.now(),
|
||||
commit=True,
|
||||
@ -95,7 +95,7 @@ def test_delete_mailbox_no_transfer(flask_client):
|
||||
|
||||
alias_id = Alias.create_new(user, "prefix", mailbox_id=m1.id).id
|
||||
job = Job.create(
|
||||
name=JOB_DELETE_MAILBOX,
|
||||
name=JobType.DELETE_MAILBOX.value,
|
||||
payload={"mailbox_id": m1.id},
|
||||
run_at=arrow.now(),
|
||||
commit=True,
|
||||
|
@ -1,7 +1,7 @@
|
||||
from app import config
|
||||
from app.db import Session
|
||||
from job_runner import get_jobs_to_run
|
||||
from app.models import Job, JobState
|
||||
from app.models import Job, JobPriority, JobState
|
||||
import arrow
|
||||
|
||||
|
||||
@ -56,18 +56,65 @@ def test_get_jobs_to_run(flask_client):
|
||||
run_at=now.shift(hours=3),
|
||||
)
|
||||
# Job out of attempts
|
||||
(
|
||||
Job.create(
|
||||
name="",
|
||||
payload="",
|
||||
state=JobState.taken.value,
|
||||
taken_at=now.shift(minutes=-(config.JOB_TAKEN_RETRY_WAIT_MINS + 10)),
|
||||
attempts=config.JOB_MAX_ATTEMPTS + 1,
|
||||
),
|
||||
Job.create(
|
||||
name="",
|
||||
payload="",
|
||||
state=JobState.taken.value,
|
||||
taken_at=now.shift(minutes=-(config.JOB_TAKEN_RETRY_WAIT_MINS + 10)),
|
||||
attempts=config.JOB_MAX_ATTEMPTS + 1,
|
||||
)
|
||||
# Job marked as error
|
||||
Job.create(
|
||||
name="",
|
||||
payload="",
|
||||
state=JobState.error.value,
|
||||
taken_at=now.shift(minutes=-(config.JOB_TAKEN_RETRY_WAIT_MINS + 10)),
|
||||
attempts=config.JOB_MAX_ATTEMPTS + 1,
|
||||
)
|
||||
|
||||
Session.commit()
|
||||
jobs = get_jobs_to_run()
|
||||
taken_before_time = arrow.now().shift(minutes=-config.JOB_TAKEN_RETRY_WAIT_MINS)
|
||||
jobs = get_jobs_to_run(taken_before_time)
|
||||
assert len(jobs) == len(expected_jobs_to_run)
|
||||
job_ids = [job.id for job in jobs]
|
||||
for job in expected_jobs_to_run:
|
||||
assert job.id in job_ids
|
||||
|
||||
|
||||
def test_get_jobs_to_run_respects_priority(flask_client):
|
||||
now = arrow.now()
|
||||
for job in Job.all():
|
||||
Job.delete(job.id)
|
||||
|
||||
j1 = Job.create(
|
||||
name="", payload="", run_at=now.shift(minutes=-1), priority=JobPriority.High
|
||||
)
|
||||
j2 = Job.create(
|
||||
name="", payload="", run_at=now.shift(minutes=-2), priority=JobPriority.Default
|
||||
)
|
||||
j3 = Job.create(
|
||||
name="", payload="", run_at=now.shift(minutes=-3), priority=JobPriority.Default
|
||||
)
|
||||
j4 = Job.create(
|
||||
name="", payload="", run_at=now.shift(minutes=-4), priority=JobPriority.Low
|
||||
)
|
||||
j5 = Job.create(
|
||||
name="", payload="", run_at=now.shift(minutes=-2), priority=JobPriority.High
|
||||
)
|
||||
|
||||
Session.commit()
|
||||
taken_before_time = arrow.now().shift(minutes=-config.JOB_TAKEN_RETRY_WAIT_MINS)
|
||||
jobs = get_jobs_to_run(taken_before_time)
|
||||
assert len(jobs) == 5
|
||||
|
||||
job_ids = [job.id for job in jobs]
|
||||
|
||||
# The expected outcome is:
|
||||
# 1. j5 -> 2 mins ago and High
|
||||
# 2. j1 -> 1 min ago and High
|
||||
# --- The 2 above are high, so they should be the first ones. j5 is first as it's been pending for a longer time
|
||||
# 3. j3 -> 3 mins ago and Default
|
||||
# 4. j2 -> 2 mins ago and Default
|
||||
# --- The 2 above are both default, and again, are sorted by run_at ascendingly
|
||||
# 5. j4 -> 3 mins ago and Low. Even if it is the one that has been waiting the most, as it's Low, it's the last one
|
||||
assert job_ids == [j5.id, j1.id, j3.id, j2.id, j4.id]
|
||||
|
@ -1,6 +1,6 @@
|
||||
import arrow
|
||||
|
||||
from app import config
|
||||
from app.constants import JobType
|
||||
from app.events.generated.event_pb2 import EventContent, AliasDeleted
|
||||
from app.jobs.send_event_job import SendEventToWebhookJob
|
||||
from app.models import PartnerUser
|
||||
@ -17,7 +17,7 @@ def test_serialize_and_deserialize_job():
|
||||
run_at = arrow.now().shift(hours=10)
|
||||
db_job = SendEventToWebhookJob(user, event).store_job_in_db(run_at=run_at)
|
||||
assert db_job.run_at == run_at
|
||||
assert db_job.name == config.JOB_SEND_EVENT_TO_WEBHOOK
|
||||
assert db_job.name == JobType.SEND_EVENT_TO_WEBHOOK.value
|
||||
job = SendEventToWebhookJob.create_from_job(db_job)
|
||||
assert job._user.id == user.id
|
||||
assert job._event.alias_deleted.id == alias_id
|
||||
|
@ -1,5 +1,6 @@
|
||||
import arrow
|
||||
from app import config
|
||||
|
||||
from app.constants import JobType
|
||||
from app.db import Session
|
||||
from app.models import User, Job, PartnerSubscription, PartnerUser, ManualSubscription
|
||||
from app.proton.proton_partner import get_proton_partner
|
||||
@ -16,7 +17,7 @@ def test_create_from_partner(flask_client):
|
||||
assert user.newsletter_alias_id is None
|
||||
job = Session.query(Job).order_by(Job.id.desc()).first()
|
||||
assert job is not None
|
||||
assert job.name == config.JOB_SEND_PROTON_WELCOME_1
|
||||
assert job.name == JobType.SEND_PROTON_WELCOME_1.value
|
||||
assert job.payload.get("user_id") == user.id
|
||||
|
||||
|
||||
|
@ -140,13 +140,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:12:00Z",
|
||||
value=3.275132296130991,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:12:00Z",
|
||||
value=4.196249043309251,
|
||||
),
|
||||
@ -157,13 +157,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=5.654416415900109,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=5.58959125727556,
|
||||
),
|
||||
@ -174,13 +174,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=0,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=0,
|
||||
),
|
||||
@ -191,13 +191,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=4,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=3,
|
||||
),
|
||||
@ -208,13 +208,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=0.14,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=0.09,
|
||||
),
|
||||
@ -225,13 +225,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=11.488581675749048,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=12.272260458006759,
|
||||
),
|
||||
@ -242,13 +242,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=466,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=458,
|
||||
),
|
||||
@ -259,13 +259,13 @@ def test_get_metrics():
|
||||
records=[
|
||||
UpcloudRecord(
|
||||
db_role="master",
|
||||
label="test-1 " "(master)",
|
||||
label="test-1 (master)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=694,
|
||||
),
|
||||
UpcloudRecord(
|
||||
db_role="standby",
|
||||
label="test-2 " "(standby)",
|
||||
label="test-2 (standby)",
|
||||
time="2022-01-21T13:11:30Z",
|
||||
value=573,
|
||||
),
|
||||
|
@ -1,10 +1,10 @@
|
||||
from arrow import Arrow
|
||||
|
||||
from app import config
|
||||
from app.account_linking import (
|
||||
SLPlan,
|
||||
SLPlanType,
|
||||
)
|
||||
from app.constants import JobType
|
||||
from app.proton.proton_client import ProtonClient, UserInformation
|
||||
from app.proton.proton_callback_handler import (
|
||||
ProtonCallbackHandler,
|
||||
@ -28,7 +28,7 @@ class MockProtonClient(ProtonClient):
|
||||
def check_initial_sync_job(user: User, expected: bool):
|
||||
found = False
|
||||
for job in Job.yield_per_query(10).filter_by(
|
||||
name=config.JOB_SEND_ALIAS_CREATION_EVENTS,
|
||||
name=JobType.SEND_ALIAS_CREATION_EVENTS.value,
|
||||
state=JobState.ready.value,
|
||||
):
|
||||
if job.payload.get("user_id") == user.id:
|
||||
|
@ -5,9 +5,9 @@ LOCAL_FILE_UPLOAD=1
|
||||
# Email related settings
|
||||
# Only print email content, not sending it
|
||||
NOT_SEND_EMAIL=true
|
||||
EMAIL_DOMAIN=sl.local
|
||||
OTHER_ALIAS_DOMAINS=["d1.test", "d2.test", "sl.local"]
|
||||
SUPPORT_EMAIL=support@sl.local
|
||||
EMAIL_DOMAIN=sl.lan
|
||||
OTHER_ALIAS_DOMAINS=["d1.lan", "d2.lan", "sl.lan"]
|
||||
SUPPORT_EMAIL=support@sl.lan
|
||||
ADMIN_EMAIL=to_fill
|
||||
# Max number emails user can generate for free plan
|
||||
MAX_NB_EMAIL_FREE_PLAN=3
|
||||
|
@ -214,7 +214,7 @@ def test_avoid_add_to_header_already_present_in_cc():
|
||||
def test_email_sent_to_noreply(flask_client):
|
||||
msg = EmailMessage()
|
||||
envelope = Envelope()
|
||||
envelope.mail_from = "from@domain.test"
|
||||
envelope.mail_from = "from@domain.lan"
|
||||
envelope.rcpt_tos = [config.NOREPLY]
|
||||
result = email_handler.handle(envelope, msg)
|
||||
assert result == status.E200
|
||||
@ -223,10 +223,10 @@ def test_email_sent_to_noreply(flask_client):
|
||||
def test_email_sent_to_noreplies(flask_client):
|
||||
msg = EmailMessage()
|
||||
envelope = Envelope()
|
||||
envelope.mail_from = "from@domain.test"
|
||||
config.NOREPLIES = ["other-no-reply@sl.test"]
|
||||
envelope.mail_from = "from@domain.lan"
|
||||
config.NOREPLIES = ["other-no-reply@sl.lan"]
|
||||
|
||||
envelope.rcpt_tos = ["other-no-reply@sl.test"]
|
||||
envelope.rcpt_tos = ["other-no-reply@sl.lan"]
|
||||
result = email_handler.handle(envelope, msg)
|
||||
assert result == status.E200
|
||||
|
||||
|
@ -78,17 +78,17 @@ def test_get_email_domain_part():
|
||||
|
||||
def test_email_belongs_to_alias_domains():
|
||||
# default alias domain
|
||||
assert can_create_directory_for_address("ab@sl.local")
|
||||
assert not can_create_directory_for_address("ab@not-exist.local")
|
||||
assert can_create_directory_for_address("ab@sl.lan")
|
||||
assert not can_create_directory_for_address("ab@not-exist.lan")
|
||||
|
||||
assert can_create_directory_for_address("hey@d1.test")
|
||||
assert not can_create_directory_for_address("hey@d3.test")
|
||||
assert can_create_directory_for_address("hey@d1.lan")
|
||||
assert not can_create_directory_for_address("hey@d3.lan")
|
||||
|
||||
|
||||
def test_can_be_used_as_personal_email(flask_client):
|
||||
# default alias domain
|
||||
assert not email_can_be_used_as_mailbox("ab@sl.local")
|
||||
assert not email_can_be_used_as_mailbox("hey@d1.test")
|
||||
assert not email_can_be_used_as_mailbox("ab@sl.lan")
|
||||
assert not email_can_be_used_as_mailbox("hey@d1.lan")
|
||||
|
||||
# custom domain as SL domain
|
||||
domain = random_domain()
|
||||
@ -115,7 +115,7 @@ def test_can_be_used_as_personal_email(flask_client):
|
||||
|
||||
|
||||
def test_disabled_user_prevents_email_from_being_used_as_mailbox():
|
||||
email = f"user_{random_token(10)}@mailbox.test"
|
||||
email = f"user_{random_token(10)}@mailbox.lan"
|
||||
assert email_can_be_used_as_mailbox(email)
|
||||
user = create_new_user(email)
|
||||
user.disabled = True
|
||||
@ -124,7 +124,7 @@ def test_disabled_user_prevents_email_from_being_used_as_mailbox():
|
||||
|
||||
|
||||
def test_disabled_user_with_secondary_mailbox_prevents_email_from_being_used_as_mailbox():
|
||||
email = f"user_{random_token(10)}@mailbox.test"
|
||||
email = f"user_{random_token(10)}@mailbox.lan"
|
||||
assert email_can_be_used_as_mailbox(email)
|
||||
user = create_new_user()
|
||||
Mailbox.create(user_id=user.id, email=email)
|
||||
@ -592,8 +592,8 @@ def test_generate_reply_email_include_sender_in_reverse_alias(flask_client):
|
||||
|
||||
|
||||
def test_normalize_reply_email(flask_client):
|
||||
assert normalize_reply_email("re+abcd@sl.local") == "re+abcd@sl.local"
|
||||
assert normalize_reply_email('re+"ab cd"@sl.local') == "re+_ab_cd_@sl.local"
|
||||
assert normalize_reply_email("re+abcd@sl.lan") == "re+abcd@sl.lan"
|
||||
assert normalize_reply_email('re+"ab cd"@sl.lan') == "re+_ab_cd_@sl.lan"
|
||||
|
||||
|
||||
def test_get_encoding():
|
||||
@ -669,7 +669,7 @@ def test_should_disable(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
for _ in range(20):
|
||||
@ -702,7 +702,7 @@ def test_should_disable_bounces_every_day(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
for i in range(9):
|
||||
@ -730,7 +730,7 @@ def test_should_disable_bounces_account(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
|
||||
@ -758,7 +758,7 @@ def test_should_disable_bounce_consecutive_days(flask_client):
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="contact@example.com",
|
||||
reply_email="rep@sl.local",
|
||||
reply_email="rep@sl.lan",
|
||||
commit=True,
|
||||
)
|
||||
|
||||
|
@ -5,6 +5,7 @@ import arrow
|
||||
import pytest
|
||||
|
||||
from app import mailbox_utils, config
|
||||
from app.constants import JobType
|
||||
from app.db import Session
|
||||
from app.mail_sender import mail_sender
|
||||
from app.mailbox_utils import (
|
||||
@ -231,7 +232,7 @@ def test_delete_with_no_transfer():
|
||||
mailbox_utils.delete_mailbox(user, mailbox.id, transfer_mailbox_id=None)
|
||||
job = Session.query(Job).order_by(Job.id.desc()).first()
|
||||
assert job is not None
|
||||
assert job.name == config.JOB_DELETE_MAILBOX
|
||||
assert job.name == JobType.DELETE_MAILBOX.value
|
||||
assert job.payload["mailbox_id"] == mailbox.id
|
||||
assert job.payload["transfer_mailbox_id"] is None
|
||||
|
||||
@ -252,13 +253,13 @@ def test_delete_with_transfer():
|
||||
)
|
||||
job = Session.query(Job).order_by(Job.id.desc()).first()
|
||||
assert job is not None
|
||||
assert job.name == config.JOB_DELETE_MAILBOX
|
||||
assert job.name == JobType.DELETE_MAILBOX.value
|
||||
assert job.payload["mailbox_id"] == mailbox.id
|
||||
assert job.payload["transfer_mailbox_id"] == transfer_mailbox.id
|
||||
mailbox_utils.delete_mailbox(user, mailbox.id, transfer_mailbox_id=None)
|
||||
job = Session.query(Job).order_by(Job.id.desc()).first()
|
||||
assert job is not None
|
||||
assert job.name == config.JOB_DELETE_MAILBOX
|
||||
assert job.name == JobType.DELETE_MAILBOX.value
|
||||
assert job.payload["mailbox_id"] == mailbox.id
|
||||
assert job.payload["transfer_mailbox_id"] is None
|
||||
|
||||
|
@ -36,7 +36,9 @@ def test_generate_email(flask_client):
|
||||
def test_profile_picture_url(flask_client):
|
||||
user = create_new_user()
|
||||
|
||||
assert user.profile_picture_url() == "http://sl.test/static/default-avatar.png"
|
||||
assert (
|
||||
user.profile_picture_url() == f"http://{EMAIL_DOMAIN}/static/default-avatar.png"
|
||||
)
|
||||
|
||||
|
||||
def test_suggested_emails_for_user_who_cannot_create_new_alias(flask_client):
|
||||
@ -303,7 +305,7 @@ def test_create_contact_for_noreply(flask_client):
|
||||
Contact.create(
|
||||
user_id=user.id,
|
||||
alias_id=alias.id,
|
||||
website_email=f"{random.random()}@contact.test",
|
||||
website_email=f"{random.random()}@contact.lan",
|
||||
reply_email=NOREPLY,
|
||||
commit=True,
|
||||
)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import arrow
|
||||
|
||||
from app.config import EMAIL_DOMAIN
|
||||
from app.db import Session
|
||||
from app.models import CoinbaseSubscription
|
||||
from app.payments.coinbase import handle_coinbase_event
|
||||
@ -11,7 +12,7 @@ def test_redirect_login_page(flask_client):
|
||||
|
||||
rv = flask_client.get("/")
|
||||
assert rv.status_code == 302
|
||||
assert rv.location == "http://sl.test/auth/login"
|
||||
assert rv.location == f"http://{EMAIL_DOMAIN}/auth/login"
|
||||
|
||||
|
||||
def test_coinbase_webhook(flask_client):
|
||||
|
@ -16,7 +16,7 @@ from app.utils import random_string
|
||||
|
||||
def create_new_user(email: Optional[str] = None, name: Optional[str] = None) -> User:
|
||||
if not email:
|
||||
email = f"user_{random_token(10)}@mailbox.test"
|
||||
email = f"user_{random_token(10)}@mailbox.lan"
|
||||
if not name:
|
||||
name = "Test User"
|
||||
# new user has a different email address
|
||||
@ -60,7 +60,7 @@ def login(flask_client, user: Optional[User] = None) -> User:
|
||||
|
||||
|
||||
def random_domain() -> str:
|
||||
return random_token() + ".test"
|
||||
return random_token() + ".lan"
|
||||
|
||||
|
||||
def random_token(length: int = 10) -> str:
|
||||
|
Reference in New Issue
Block a user