summaryrefslogtreecommitdiff
path: root/tests/mail
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-10-14 11:36:51 +0200
committerGitHub <noreply@github.com>2021-10-14 11:36:51 +0200
commitcdad96e6330cd31185f7496aaf8eb316f2773d6d (patch)
tree6faa4c3801527d4c13adc9ad17b7350f90e371f2 /tests/mail
parentf345c9fb3e6bcc1ad78fead35fc17eaf8133fed5 (diff)
downloaddjango-cdad96e6330cd31185f7496aaf8eb316f2773d6d.tar.gz
Refs #27131 -- Removed SMTPBackendTests.test_server_login().
test_server_login() was a regression test for a crash when passing Unicode strings to SMTP server using CRAM-MD5 method on Python 2. Python 2 is no longer supported and test_server_login() passes even without FakeSMTPChannel.smtp_AUTH() because smtplib.SMTPAuthenticationError is raised when AUTH is not implemented.
Diffstat (limited to 'tests/mail')
-rw-r--r--tests/mail/tests.py39
1 files changed, 1 insertions, 38 deletions
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 30f8252e0a..b9b3e452d5 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -1,5 +1,4 @@
import asyncore
-import base64
import mimetypes
import os
import shutil
@@ -13,7 +12,7 @@ from email.mime.text import MIMEText
from email.utils import parseaddr
from io import StringIO
from pathlib import Path
-from smtplib import SMTP, SMTPAuthenticationError, SMTPException
+from smtplib import SMTP, SMTPException
from ssl import SSLError
from unittest import mock
@@ -1347,15 +1346,6 @@ class FakeSMTPChannel(smtpd.SMTPChannel):
# cares whether the connection attempt was made.
pass
- def smtp_AUTH(self, arg):
- if arg == 'CRAM-MD5':
- # This is only the first part of the login process. But it's enough
- # for our tests.
- challenge = base64.b64encode(b'somerandomstring13579')
- self.push('334 %s' % challenge.decode())
- else:
- self.push('502 Error: login "%s" not implemented' % arg)
-
class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
"""
@@ -1418,20 +1408,6 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
self.join()
-class FakeAUTHSMTPConnection(SMTP):
- """
- A SMTP connection pretending support for the AUTH command. It does not, but
- at least this can allow testing the first part of the AUTH process.
- """
-
- def ehlo(self, name=''):
- response = SMTP.ehlo(self, name=name)
- self.esmtp_features.update({
- 'auth': 'CRAM-MD5 PLAIN LOGIN',
- })
- return response
-
-
class SMTPBackendTestsBase(SimpleTestCase):
@classmethod
@@ -1518,19 +1494,6 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
backend.connection = mock.Mock(spec=object())
self.assertIs(backend.open(), False)
- def test_server_login(self):
- """
- Even if the Python SMTP server doesn't support authentication, the
- login process starts and the appropriate exception is raised.
- """
- class CustomEmailBackend(smtp.EmailBackend):
- connection_class = FakeAUTHSMTPConnection
-
- backend = CustomEmailBackend(username='username', password='password')
- with self.assertRaises(SMTPAuthenticationError):
- with backend:
- pass
-
@override_settings(EMAIL_USE_TLS=True)
def test_email_tls_use_settings(self):
backend = smtp.EmailBackend()