Skip to content

Commit

Permalink
fixup! fix(api): variable rendering in activate-account email template
Browse files Browse the repository at this point in the history
  • Loading branch information
peterthomassen committed Dec 17, 2024
1 parent 29b2ebe commit 8712c26
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions api/desecapi/tests/test_user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ def assertUserDoesNotExist(self, email):
with self.assertRaises(User.DoesNotExist):
User.objects.get(email=email)

def assertRegistrationEmail(self, recipient, reset=True):
def assertRegistrationEmail(self, recipient, domain=None, reset=True):
return self.assertEmailSent(
subject_contains="deSEC",
body_contains="Thank you for registering with deSEC!",
body_contains=(
"You are about to set up"
if domain
else "As we may need to contact you in the future"
),
recipient=[recipient],
reset=reset,
pattern=r"following link[^:]*:\s+([^\s]*)",
Expand Down Expand Up @@ -417,7 +421,9 @@ def _test_registration(
kwargs.get("outreach_preference", True),
)
self.assertPassword(email, password)
confirmation_link = self.assertRegistrationEmail(email)
confirmation_link = self.assertRegistrationEmail(
email, domain=kwargs.get("domain")
)
self.assertConfirmationLinkRedirect(confirmation_link)
response = self.client.verify(confirmation_link)
if late_captcha:
Expand Down Expand Up @@ -452,7 +458,7 @@ def _test_registration_with_domain(
self.assertIsNone(User.objects.get(email=email).is_active)
self.assertPassword(email, password)

confirmation_link = self.assertRegistrationEmail(email)
confirmation_link = self.assertRegistrationEmail(email, domain=domain)

if tampered_domain is not None:
self.assertNotEqual(domain, tampered_domain)
Expand Down

0 comments on commit 8712c26

Please sign in to comment.