Compare commits
No commits in common. "1d54e2232fce2aec640ad50d23d430b1e5ad3e91" and "57d0eeaf0f6c91fd9c683e23306369b2a1e93397" have entirely different histories.
1d54e2232f
...
57d0eeaf0f
19
DEVNOTES.md
19
DEVNOTES.md
@ -4,7 +4,6 @@ Notes for developers
|
|||||||
|
|
||||||
```
|
```
|
||||||
python -m unittest tests.test_pop.TestPop3.test_CAPA
|
python -m unittest tests.test_pop.TestPop3.test_CAPA
|
||||||
python -m unittest tests.test_smtp.TestSMTP
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Patch for enable logging in test
|
## Patch for enable logging in test
|
||||||
@ -15,11 +14,7 @@ Patch generated using below
|
|||||||
git diff --patch -U1 tests >> ./DEVNOTES.md
|
git diff --patch -U1 tests >> ./DEVNOTES.md
|
||||||
```
|
```
|
||||||
|
|
||||||
Apply with below. Disables smtp test mail dir cleanup.
|
Apply with below
|
||||||
```
|
|
||||||
ls -ltd /tmp/m41*
|
|
||||||
git checkout tests
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git apply - <<PATCH
|
git apply - <<PATCH
|
||||||
@ -32,18 +27,6 @@ index 55c1a91..a825665 100644
|
|||||||
- logging.basicConfig(level=logging.CRITICAL)
|
- logging.basicConfig(level=logging.CRITICAL)
|
||||||
+ logging.basicConfig(level=logging.DEBUG)
|
+ logging.basicConfig(level=logging.DEBUG)
|
||||||
td = tempfile.TemporaryDirectory(prefix="m41.pop.")
|
td = tempfile.TemporaryDirectory(prefix="m41.pop.")
|
||||||
diff --git a/tests/test_smtp.py b/tests/test_smtp.py
|
|
||||||
index 0554d4c..52d147b 100644
|
|
||||||
--- a/tests/test_smtp.py
|
|
||||||
+++ b/tests/test_smtp.py
|
|
||||||
@@ -18,5 +18,5 @@ def setUpModule() -> None:
|
|
||||||
global MAILS_PATH
|
|
||||||
- logging.basicConfig(level=logging.CRITICAL)
|
|
||||||
+ logging.basicConfig(level=logging.DEBUG)
|
|
||||||
td = tempfile.TemporaryDirectory(prefix="m41.smtp.")
|
|
||||||
- unittest.addModuleCleanup(td.cleanup)
|
|
||||||
+ # unittest.addModuleCleanup(td.cleanup)
|
|
||||||
MAILS_PATH = Path(td.name)
|
|
||||||
PATCH
|
PATCH
|
||||||
```
|
```
|
||||||
|
|
||||||
|
6
Pipfile.lock
generated
6
Pipfile.lock
generated
@ -18,12 +18,12 @@
|
|||||||
"default": {
|
"default": {
|
||||||
"aiosmtpd": {
|
"aiosmtpd": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:5a811826e1a5a06c25ebc3e6c4a704613eb9a1bcf6b78428fbe865f4f6c9a4b8",
|
"sha256:78d7b14f859ad0e6de252b47f9cf1ca6f1c82a8b0f10a9e39bec7e915a6aa5fe",
|
||||||
"sha256:72c99179ba5aa9ae0abbda6994668239b64a5ce054471955fe75f581d2592475"
|
"sha256:a196922f1903e54c4d37c53415b7613056d39e2b1e8249f324b9ee7a439be0f1"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"markers": "python_version >= '3.8'",
|
"markers": "python_version >= '3.8'",
|
||||||
"version": "==1.4.6"
|
"version": "==1.4.5"
|
||||||
},
|
},
|
||||||
"atpublic": {
|
"atpublic": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -20,26 +20,21 @@ logger = logging.getLogger("smtp")
|
|||||||
|
|
||||||
|
|
||||||
class MyHandler(AsyncMessage):
|
class MyHandler(AsyncMessage):
|
||||||
def __init__(self, mails_path: Path, mbox_finder: Callable[[str], list[str]], listener_type: str):
|
def __init__(self, mails_path: Path, mbox_finder: Callable[[str], list[str]]):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.mails_path = mails_path
|
self.mails_path = mails_path
|
||||||
self.mbox_finder = mbox_finder
|
self.mbox_finder = mbox_finder
|
||||||
self.rcpt_tos = []
|
self.rcpt_tos = []
|
||||||
self.peer = None
|
self.peer = None
|
||||||
self.starttls = False
|
|
||||||
self.listener_type = listener_type
|
|
||||||
|
|
||||||
async def handle_DATA(
|
async def handle_DATA(
|
||||||
self, server: SMTP, session: SMTPSession, envelope: SMTPEnvelope
|
self, server: SMTP, session: SMTPSession, envelope: SMTPEnvelope
|
||||||
) -> str:
|
) -> str:
|
||||||
self.rcpt_tos = envelope.rcpt_tos
|
self.rcpt_tos = envelope.rcpt_tos
|
||||||
self.peer = session.peer
|
self.peer = session.peer
|
||||||
if session.ssl:
|
|
||||||
self.starttls = True
|
|
||||||
return await super().handle_DATA(server, session, envelope)
|
return await super().handle_DATA(server, session, envelope)
|
||||||
|
|
||||||
async def handle_message(self, message: Message): # type: ignore[override]
|
async def handle_message(self, message: Message): # type: ignore[override]
|
||||||
message["X-SSL"] = f"Type: {self.listener_type}, STARTTLS: {self.starttls}"
|
|
||||||
all_mboxes: set[str] = set()
|
all_mboxes: set[str] = set()
|
||||||
for addr in self.rcpt_tos:
|
for addr in self.rcpt_tos:
|
||||||
for mbox in self.mbox_finder(addr.lower()):
|
for mbox in self.mbox_finder(addr.lower()):
|
||||||
@ -73,7 +68,7 @@ def protocol_factory_starttls(
|
|||||||
):
|
):
|
||||||
logger.info("Got smtp client cb starttls")
|
logger.info("Got smtp client cb starttls")
|
||||||
try:
|
try:
|
||||||
handler = MyHandler(mails_path, mbox_finder, "starttls")
|
handler = MyHandler(mails_path, mbox_finder)
|
||||||
smtp = SMTP(
|
smtp = SMTP(
|
||||||
handler=handler,
|
handler=handler,
|
||||||
require_starttls=require_starttls,
|
require_starttls=require_starttls,
|
||||||
@ -91,7 +86,7 @@ def protocol_factory(
|
|||||||
):
|
):
|
||||||
logger.info("Got smtp client cb")
|
logger.info("Got smtp client cb")
|
||||||
try:
|
try:
|
||||||
handler = MyHandler(mails_path, mbox_finder, "plain")
|
handler = MyHandler(mails_path, mbox_finder)
|
||||||
smtp = SMTP(handler=handler, enable_SMTPUTF8=smtputf8)
|
smtp = SMTP(handler=handler, enable_SMTPUTF8=smtputf8)
|
||||||
except:
|
except:
|
||||||
logger.exception("Something went wrong")
|
logger.exception("Something went wrong")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-i https://pypi.org/simple
|
-i https://pypi.org/simple
|
||||||
aiosmtpd==1.4.6; python_version >= '3.8'
|
aiosmtpd==1.4.5; python_version >= '3.8'
|
||||||
atpublic==4.1.0; python_version >= '3.8'
|
atpublic==4.1.0; python_version >= '3.8'
|
||||||
attrs==23.2.0; python_version >= '3.7'
|
attrs==23.2.0; python_version >= '3.7'
|
||||||
python-jata==1.2; python_version >= '3.8'
|
python-jata==1.2; python_version >= '3.8'
|
||||||
|
@ -61,7 +61,6 @@ class TestSMTP(unittest.IsolatedAsyncioTestCase):
|
|||||||
X-Peer: ('127.0.0.1', {local_port})
|
X-Peer: ('127.0.0.1', {local_port})
|
||||||
X-MailFrom: foo@sender.com
|
X-MailFrom: foo@sender.com
|
||||||
X-RcptTo: foo@bar.com
|
X-RcptTo: foo@bar.com
|
||||||
X-SSL: Type: plain, STARTTLS: False
|
|
||||||
|
|
||||||
Hello world
|
Hello world
|
||||||
Byee
|
Byee
|
||||||
|
Loading…
Reference in New Issue
Block a user