-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4905 from open-formulieren/issue/4895-outgoing-em…
…ail-logging-improvements [#4895] outgoing email logging improvements
- Loading branch information
Showing
5 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
from django.test import TestCase | ||
|
||
from openforms.config.models import GlobalConfiguration | ||
from openforms.emails.constants import EmailContentTypeChoices, EmailEventChoices | ||
from openforms.logging.models import TimelineLogProxy | ||
|
||
from ..tasks import send_email_cosigner | ||
|
@@ -175,3 +176,34 @@ def test_form_link_not_allowed_in_email(self): | |
|
||
self.assertNotIn(form_link, email.body) | ||
self.assertIn(submission.public_registration_reference, email.body) | ||
|
||
def test_headers_in_cosign_request_email(self): | ||
submission = SubmissionFactory.from_components( | ||
components_list=[ | ||
{ | ||
"key": "cosign", | ||
"type": "cosign", | ||
"label": "Cosign component", | ||
}, | ||
], | ||
submitted_data={"cosign": "[email protected]"}, | ||
form_url="http://testserver/myform/", | ||
) | ||
send_email_cosigner(submission.id) | ||
|
||
self.assertEqual(len(mail.outbox), 1) | ||
message = mail.outbox[0] | ||
|
||
# UUID is not a constant, so just test if it exists | ||
submission_uuid = message.extra_headers.pop("X-OF-Content-UUID", None) | ||
self.assertIsNotNone(submission_uuid) | ||
|
||
# Test remaining headers | ||
self.assertEqual( | ||
message.extra_headers, | ||
{ | ||
"Content-Language": "nl", | ||
"X-OF-Content-Type": EmailContentTypeChoices.submission, | ||
"X-OF-Event": EmailEventChoices.cosign_request, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from privates.test import temp_private_root | ||
|
||
from openforms.config.models import GlobalConfiguration | ||
from openforms.emails.constants import EmailContentTypeChoices, EmailEventChoices | ||
from openforms.emails.models import ConfirmationEmailTemplate | ||
from openforms.emails.tests.factories import ConfirmationEmailTemplateFactory | ||
from openforms.forms.tests.factories import FormStepFactory | ||
|
@@ -641,6 +642,37 @@ def test_template_is_rendered_in_submission_language(self): | |
self.assertIn("Translated Radio option 1", html_message) | ||
self.assertIn("Translated Select option 2", html_message) | ||
|
||
def test_headers_present_in_confirmation_email(self): | ||
submission = SubmissionFactory.from_components( | ||
completed=True, | ||
components_list=[ | ||
{ | ||
"key": "email", | ||
"confirmationRecipient": True, | ||
}, | ||
], | ||
submitted_data={"email": "[email protected]"}, | ||
) | ||
with override_settings(CELERY_TASK_ALWAYS_EAGER=True): | ||
send_confirmation_email(submission.id) | ||
|
||
self.assertEqual(len(mail.outbox), 1) | ||
message = mail.outbox[0] | ||
|
||
# UUID is not a constant, so just test if it exists | ||
submission_uuid = message.extra_headers.pop("X-OF-Content-UUID", None) | ||
self.assertIsNotNone(submission_uuid) | ||
|
||
# Test remaining headers | ||
self.assertEqual( | ||
message.extra_headers, | ||
{ | ||
"Content-Language": "nl", | ||
"X-OF-Content-Type": EmailContentTypeChoices.submission, | ||
"X-OF-Event": EmailEventChoices.confirmation, | ||
}, | ||
) | ||
|
||
|
||
class RaceConditionTests(TransactionTestCase): | ||
@patch("openforms.submissions.tasks.emails._send_confirmation_email") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters