|
1 | 1 | import asyncore |
2 | | -import base64 |
3 | 2 | import mimetypes |
4 | 3 | import os |
5 | 4 | import shutil |
|
13 | 12 | from email.utils import parseaddr |
14 | 13 | from io import StringIO |
15 | 14 | from pathlib import Path |
16 | | -from smtplib import SMTP, SMTPAuthenticationError, SMTPException |
| 15 | +from smtplib import SMTP, SMTPException |
17 | 16 | from ssl import SSLError |
18 | 17 | from unittest import mock |
19 | 18 |
|
@@ -1321,15 +1320,6 @@ def collect_incoming_data(self, data): |
1321 | 1320 | # cares whether the connection attempt was made. |
1322 | 1321 | pass |
1323 | 1322 |
|
1324 | | - def smtp_AUTH(self, arg): |
1325 | | - if arg == 'CRAM-MD5': |
1326 | | - # This is only the first part of the login process. But it's enough |
1327 | | - # for our tests. |
1328 | | - challenge = base64.b64encode(b'somerandomstring13579') |
1329 | | - self.push('334 %s' % challenge.decode()) |
1330 | | - else: |
1331 | | - self.push('502 Error: login "%s" not implemented' % arg) |
1332 | | - |
1333 | 1323 |
|
1334 | 1324 | class FakeSMTPServer(smtpd.SMTPServer, threading.Thread): |
1335 | 1325 | """ |
@@ -1392,20 +1382,6 @@ def stop(self): |
1392 | 1382 | self.join() |
1393 | 1383 |
|
1394 | 1384 |
|
1395 | | -class FakeAUTHSMTPConnection(SMTP): |
1396 | | - """ |
1397 | | - A SMTP connection pretending support for the AUTH command. It does not, but |
1398 | | - at least this can allow testing the first part of the AUTH process. |
1399 | | - """ |
1400 | | - |
1401 | | - def ehlo(self, name=''): |
1402 | | - response = SMTP.ehlo(self, name=name) |
1403 | | - self.esmtp_features.update({ |
1404 | | - 'auth': 'CRAM-MD5 PLAIN LOGIN', |
1405 | | - }) |
1406 | | - return response |
1407 | | - |
1408 | | - |
1409 | 1385 | class SMTPBackendTestsBase(SimpleTestCase): |
1410 | 1386 |
|
1411 | 1387 | @classmethod |
@@ -1496,19 +1472,6 @@ def test_reopen_connection(self): |
1496 | 1472 | backend.connection = mock.Mock(spec=object()) |
1497 | 1473 | self.assertIs(backend.open(), False) |
1498 | 1474 |
|
1499 | | - def test_server_login(self): |
1500 | | - """ |
1501 | | - Even if the Python SMTP server doesn't support authentication, the |
1502 | | - login process starts and the appropriate exception is raised. |
1503 | | - """ |
1504 | | - class CustomEmailBackend(smtp.EmailBackend): |
1505 | | - connection_class = FakeAUTHSMTPConnection |
1506 | | - |
1507 | | - backend = CustomEmailBackend(username='username', password='password') |
1508 | | - with self.assertRaises(SMTPAuthenticationError): |
1509 | | - with backend: |
1510 | | - pass |
1511 | | - |
1512 | 1475 | @override_settings(EMAIL_USE_TLS=True) |
1513 | 1476 | def test_email_tls_use_settings(self): |
1514 | 1477 | backend = smtp.EmailBackend() |
|
0 commit comments