launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25069
[Merge] ~cjwatson/launchpad:email-instance-name into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:email-instance-name into launchpad:master.
Commit message:
Fix instance name in X-Generated-By email headers
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/387840
config.name is the basename of the topmost file in the stack of configuration files. config.instance_name matches the value of LPCONFIG (or its various fallbacks), which is much more informative.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:email-instance-name into launchpad:master.
diff --git a/lib/lp/services/mail/sendmail.py b/lib/lp/services/mail/sendmail.py
index b344b12..a694450 100644
--- a/lib/lp/services/mail/sendmail.py
+++ b/lib/lp/services/mail/sendmail.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""The One True Way to send mail from the Launchpad application.
@@ -435,7 +435,7 @@ def sendmail(message, to_addrs=None, bulk=True):
del message['X-Generated-By']
message['X-Generated-By'] = 'Launchpad (canonical.com)'
message.set_param('Revision', str(versioninfo.revision), 'X-Generated-By')
- message.set_param('Instance', config.name, 'X-Generated-By')
+ message.set_param('Instance', config.instance_name, 'X-Generated-By')
# Add a shared secret header for pre-approval with Mailman. This approach
# helps security, but still exposes us to a replay attack; we consider the
diff --git a/lib/lp/services/mail/tests/test_stub.py b/lib/lp/services/mail/tests/test_stub.py
index 8945153..ec48788 100644
--- a/lib/lp/services/mail/tests/test_stub.py
+++ b/lib/lp/services/mail/tests/test_stub.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2019 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -104,10 +104,10 @@ def test_simple_sendmail():
shows the git revision and instance name.
>>> message.get_params(header='X-Generated-By')
- ... # doctest: +NORMALIZE_WHITESPACE
+ ... # doctest: +NORMALIZE_WHITESPACE,+ELLIPSIS
[('Launchpad (canonical.com)', ''),
('revision', '0000000000000000000000000000000000000000'),
- ('instance', 'launchpad-lazr.conf')]
+ ('instance', 'testrunner_...')]
"""