Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion testsuite/mailhog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def url(self) -> str:
"""Url of the mailhog app"""
return self._url

@backoff.on_exception(backoff.expo, requests.exceptions.RequestException, max_tries=3)
Comment thread
cathal-bailey marked this conversation as resolved.
Resolved
def request(self, method: str = "GET", params: dict = None, endpoint: str = None):
"""Requests the mailhog API"""
"""Requests the mailhog API with automatic retry on connection errors"""
params = params or {}

full_url = f"{self._url}/{endpoint}"
Expand Down
31 changes: 31 additions & 0 deletions testsuite/tests/system/messages/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Conftest for messages tests.

These tests require email notifications to be enabled.
"""

import pytest

NOTIFICATIONS = [
"account_created",
"application_created",
"service_contract_created",
"account_deleted",
"service_deleted",
]


@pytest.fixture(scope="session", autouse=True)
Comment thread
cathal-bailey marked this conversation as resolved.
Resolved
def enable_notifications(threescale):
"""
Enable notification preferences for the current provider's admin user.

After porta PR #4039, notifications use a per-user NotificationPreferences model
instead of account-level settings. In fresh deployments, notifications default to disabled.
"""
params = {f"notification_preferences[{n}]": "true" for n in NOTIFICATIONS}
threescale.rest.patch(path="/admin/api/personal/notification_preferences", data=params)
# Enable service_plans_ui_visible which defaults to false, gating service_contract_created
threescale.rest.put(path="/admin/api/settings", data={"service_plans_ui_visible": "true"})
Comment thread
cathal-bailey marked this conversation as resolved.
Resolved

yield
4 changes: 2 additions & 2 deletions testsuite/tests/system/messages/mail_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ subject_templates:
Headers: '{"unique_args":{"event_name":"Accounts::AccountCreatedEvent","event_id":".*","user_id":[0-9]+,"account_id":[0-9]+},"category":\["notification","accounts/account_created_event"\]}'
Body: '----==_mimepart_.+Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding:
7bitDear <username>,<test_account> from <test_group> has signed-up for: .+New
user details: Username: <test_account> Email: <test_account>@<account_email_domain>New
user details: Username: <test_account> Email: <test_account>@<account_email_domain>.*New
account details: Organization/Group Name: <test_group> To view new signup
in your 3scale Admin Portal, follow this link: https://3scale-admin.<threescale_superdomain>/buyers/accounts/[0-9]+You
are receiving this because you subscribed to this notification.View notification
Expand All @@ -13,7 +13,7 @@ subject_templates:
html><html lang=3D"en"><head><meta charset=3D"utf-8" /></head><body style=3D"font-family:
&#39;Lucida Grande&#39;, verdana, sans-serif;"><p>Dear <username>,</p><p><test_account>
from <test_group> has signed-up for: .+</p><p><b>New user details:</b></p><ul><li><b>Username:</b>
<test_account></li><li><b>Email:</b> <test_account>@<account_email_domain></li></ul><p><b>New
<test_account></li><li><b>Email:</b> <test_account>@<account_email_domain></li>.*</ul><p><b>New
account details:</b></p><ul><li><b>Organization/Group Name:</b> <test_group></li></ul><p><a
href=3D"https://3scale-admin.<threescale_superdomain>/buyers/accounts/[0-9]+">View
new signup in your 3scale Admin Portal</a></p><p>=E2=80=94<br />You are receiving
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/system/messages/test_email_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_emails_content_after_account_creation(mailhog_client, mail_template):
for m in mailhog_client.all_messages()
if message_match(tpl, "Headers", headers(m).get("X-SMTPAPI", "DO NOT MATCH"))
]
assert messages, f"Didn't find assumed X-SMTPAPI: {tpl['Headers']}"
assert messages, "Didn't find any messages with expected X-SMTPAPI headers"

messages = [
m
Expand Down
Loading