| Age | Commit message (Collapse) | Author |
|
See DEP 0018.
Added:
* MAILERS setting.
* django.core.mail.mailers dict-like EmailBackend factory.
* `using` argument to mail sending APIs.
* `sent_using` attribute to mail.outbox messages in locmem backend.
* MAILERS in startproject settings template, set to console backend.
* AdminLogHandler.using argument.
* BrokenLinkEmailsMiddleware.send_mail() method.
Updated:
* BaseEmailBackend to track the MAILERS alias used to construct it, and
to report errors for unknown kwargs (OPTIONS).
* EmailBackend implementations to initialize from kwargs (OPTIONS) only
when MAILERS is being used.
* smtp.EmailBackend to require `host` option and to default `port`
option based on SSL/TLS options.
* SimpleTestCase setup to substitute the locmem backend for all defined
MAILERS configurations.
* Django's tests that send mail to define MAILERS.
Deprecated:
* EMAIL_BACKEND and other backend-related EMAIL_* settings.
* mail.get_connection().
* The `connection`, `fail_silently`, `auth_user`, and `auth_password`
arguments to mail functions.
* The EmailMessage.connection attribute.
* BaseEmailBackend support for `fail_silently`. Backends that support
fail_silently (SMTP, console, file) now implement it directly.
* AdminEmailHandler.email_backend argument.
Removed undocumented features without deprecation:
* EmailMessage.get_connection() method. (send() now raises an error if a
subclass has attempted to override it.)
* EmailMessage.send() no longer sets self.connection to the connection
used for sending. (It still _uses_ a pre-existing self.connection.)
* AdminEmailHandler.connection() method. (Init now raises an error if a
subclass has attempted to override it.)
Thanks to Natalia Bidart for shepherding DEP 0018 and for extensive
reviews and suggestions on the implementation.
Thanks to Jacob Rief for the initial implementation and multiple
iterations while refining the design.
Co-authored-by: Jacob Rief <jacob.rief@gmail.com>
|
|
Simplified and removed use of soon-to-be-deprecated or removed features
from tests for AdminEmailHandler and BrokenLinkEmailsMiddleware. Added
or updated cases to ensure `fail_silently` usage remains consistent
during the transition to email providers.
Changed custom FailingEmailBackend to respect fail_silently and record
its use in a class-level property.
In AdminEmailHandlerTest:
* Added make_log_record() helper to reduce duplicated code.
* Changed test_fail_silently() to send through the FailingEmailBackend,
which will fail if not initialized with fail_silently=True. (Rather
than inspecting attributes of a soon-to-be-deprecated connection.)
* Simplified test_uses_custom_email_backend() by replacing monkeypatches
with inspectable custom backend.
* In test_customize_send_mail_method(), removed use of the undocumented
self.connection() method and the soon-to-be-deprecated `connection`
arg to mail_managers(). This test verifies a subclass can customize
sending by mailing the managers rather than the admins. Involving a
email backend connection was irrelevant.
In BrokenLinkEmailsMiddlewareTest, added a case with FailingEmailBackend
to verify send uses fail_silently=True.
|
|
tests.
Thanks JaeHyuck Sa and Jake Howard for the reviews.
|
|
for consistency.
|
|
|
|
Suitably crafted requests containing a CRLF sequence in the request
path may have allowed log injection, potentially corrupting log files,
obscuring other attacks, misleading log post-processing tools, or
forging log entries.
To mitigate this, all positional formatting arguments passed to the
logger are now escaped using "unicode_escape" encoding.
Thanks to Seokchan Yoon (https://ch4n3.kr/) for the report.
Co-authored-by: Carlton Gibson <carlton@noumenal.es>
Co-authored-by: Jake Howard <git@theorangeone.net>
|
|
`log_response()`.
|
|
|
|
Previously, the ADMINS and MANAGERS settings were lists of (name, address)
tuples (where the name had been unused). Deprecated use of tuples.
Updated settings value sanity checks, and changed from ValueError to
ImproperlyConfigured.
|
|
EmailMultiAlternatives.alternatives to use namedtuples.
This makes it more descriptive to pull out the named fields.
|
|
|
|
|
|
|
|
and tests.
|
|
|
|
|
|
This allows better debugging and filtering of errors.
|
|
This also prevents sending <form> tags in emails.
|
|
Inspired by Adam Johnson talk on DjangoCon Europe 2021.
|
|
The SetupConfigureLogging test case does not restore the logging config
after its execution. It leaves the logger django.request with an empty
handlers array.
This also removes the last use of LOGGING_CONFIG, introduced in
43503b093a35ca4707c16d865f10929960bfa0b8.
|
|
Setting default_msec_format=None will make it the same, unfortunately
it's not supported by Python, see https://bugs.python.org/issue40300.
|
|
* assertIsNone()/assertIsNotNone() instead of comparing to None.
* assertLess() for < comparisons.
* assertIs() for 'is' expressions.
* assertIsInstance() for isinstance() expressions.
* rounding of assertAlmostEqual() for round() expressions.
* assertIs(..., True/False) instead of comparing to True/False.
* assertIs()/assertIsNot() for ==/!= comparisons.
* assertNotEqual() for == comparisons.
* assertTrue()/assertFalse() instead of comparing to True/False.
|
|
|
|
|
|
Use tempfile.TemporaryDirectory() in AdminScriptTestCase.setUp()
to create and destroy a temporary directory for each test. It removes
the need for individual tests to delete files.
For test classes that don't use the temporary directory, inherit from
SimpleTestCase.
|
|
Thanks Mariusz Felisiak for auditing.
|
|
|
|
Follow up to 081e78716085ff4af08604af5d084c8fd27c0730.
|
|
* Added logging of 500 responses for instantiated responses.
* Added logging of all 4xx and 5xx responses.
|
|
|
|
|
|
|
|
|
|
|
|
Thanks Tim Graham for the review.
|
|
|
|
|
|
|
|
|
|
|
|
Allowed ServerFormatter to handle simple string messages or messages with
formatting arguments. The formatter will set the server_time variable on
the log record if it's required by the format string but wasn't passed in
extra parameters.
|
|
|
|
Thanks Tim Graham for polishing the patch, updating the tests, and
writing documentation. Thanks Carl Meyer for shepherding the DEP.
|
|
Refs #26572, #17281. The RFC doesn't limit total length, just the line length
which is already taken care of by Python itself.
Thanks Tim Graham for the review.
|
|
the 404.
For example, this avoids a warning in the case of a request that's
redirected to a language-prefixed URL by LocaleMiddleware.
|
|
|
|
|
|
|
|
Thanks Akshesh Doshi for the initial patch and Tim Graham for the review
|
|
default.
|