move the test email address to an environment variable

This commit is contained in:
Changaco 2025-03-18 23:45:25 +01:00
parent ca69b7ea22
commit 275eeb4111
5 changed files with 13 additions and 4 deletions

View File

@ -49,7 +49,13 @@ jobs:
- name: Install tox
run: pip install tox
- name: Write liberapay environment file for tests
run: echo 'DATABASE_URL="port=5432 dbname=liberapay_tests"' >tests/local.env
run: |
cat >tests/local.env <<EOF
DATABASE_URL="port=5432 dbname=liberapay_tests"
# As of March 2025, GitHub Actions runners still don't have IPv6,
# so we override the default IPv6-only test email address here.
TEST_EMAIL_ADDRESS=test@changaco.net
EOF
- name: Run the tests
run: tox
- name: Upload coverage reports to Codecov

View File

@ -52,3 +52,4 @@ INSTANCE_TYPE=development
SECRET_FERNET_KEYS="2019-01-19 This_is_a_fake_key_of_32_bytes_in_Base64URL="
HOSTNAME=
TEST_EMAIL_ADDRESS=test@ipv6.changaco.net

View File

@ -167,7 +167,7 @@ def check_email_address(email: NormalizedEmailAddress) -> None:
if port_25_is_open is None:
try:
test_email_address(normalize_email_address(
'support@liberapay.com'
website.env.test_email_address
))
except BrokenEmailDomain:
port_25_is_open = False

View File

@ -89,6 +89,7 @@ env = Environment(
COMPRESS_ASSETS=is_yesish,
CSP_EXTRA=str,
HOSTNAME=str,
TEST_EMAIL_ADDRESS=str,
SENTRY_DEBUG=is_yesish,
SENTRY_DSN=str,
SENTRY_RERAISE=is_yesish,

View File

@ -66,9 +66,10 @@ class TestEmail(EmailHarness):
msg = json.loads(response.body)['msg']
assert msg == "A verification email has been sent to alice@example.com."
with patch.object(self.website.app_conf, 'check_email_domains', True):
response = self.hit_email_spt('add-email', 'test@ipv6.changaco.net')
email = self.website.env.test_email_address
response = self.hit_email_spt('add-email', email)
msg = json.loads(response.body)['msg']
assert msg == "A verification email has been sent to test@ipv6.changaco.net."
assert msg == f"A verification email has been sent to {email}."
def test_participant_can_add_email_with_unicode_domain_name(self):
punycode_email = 'alice@' + 'accentué.com'.encode('idna').decode()