Compare commits
No commits in common. "starttls_header" and "main" have entirely different histories.
starttls_h
...
main
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_smtp.TestSMTP
|
||||
```
|
||||
|
||||
## Patch for enable logging in test
|
||||
@ -15,11 +14,7 @@ Patch generated using below
|
||||
git diff --patch -U1 tests >> ./DEVNOTES.md
|
||||
```
|
||||
|
||||
Apply with below. Disables smtp test mail dir cleanup.
|
||||
```
|
||||
ls -ltd /tmp/m41*
|
||||
git checkout tests
|
||||
```
|
||||
Apply with below
|
||||
|
||||
```bash
|
||||
git apply - <<PATCH
|
||||
@ -32,18 +27,6 @@ index 55c1a91..a825665 100644
|
||||
- logging.basicConfig(level=logging.CRITICAL)
|
||||
+ logging.basicConfig(level=logging.DEBUG)
|
||||
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
|
||||
```
|
||||
|
||||
|
6
Pipfile.lock
generated
6
Pipfile.lock
generated
@ -18,12 +18,12 @@
|
||||
"default": {
|
||||
"aiosmtpd": {
|
||||
"hashes": [
|
||||
"sha256:5a811826e1a5a06c25ebc3e6c4a704613eb9a1bcf6b78428fbe865f4f6c9a4b8",
|
||||
"sha256:72c99179ba5aa9ae0abbda6994668239b64a5ce054471955fe75f581d2592475"
|
||||
"sha256:78d7b14f859ad0e6de252b47f9cf1ca6f1c82a8b0f10a9e39bec7e915a6aa5fe",
|
||||
"sha256:a196922f1903e54c4d37c53415b7613056d39e2b1e8249f324b9ee7a439be0f1"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==1.4.6"
|
||||
"version": "==1.4.5"
|
||||
},
|
||||
"atpublic": {
|
||||
"hashes": [
|
||||
|
@ -340,9 +340,7 @@ def make_pop_server_callback(mails_path: Path, users: list[User], timeout_second
|
||||
async def session_cb(reader: StreamReader, writer: StreamWriter):
|
||||
c_shared_state.set(s_state)
|
||||
ip, _ = writer.get_extra_info("peername")
|
||||
c_state.set(
|
||||
State(reader=reader, writer=writer, ip=ip, req_id=s_state.next_id())
|
||||
)
|
||||
c_state.set(State(reader=reader, writer=writer, ip=ip, req_id=s_state.next_id()))
|
||||
logger.info("Got pop server callback")
|
||||
try:
|
||||
try:
|
||||
|
@ -20,31 +20,21 @@ logger = logging.getLogger("smtp")
|
||||
|
||||
|
||||
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__()
|
||||
self.mails_path = mails_path
|
||||
self.mbox_finder = mbox_finder
|
||||
self.rcpt_tos = []
|
||||
self.peer = None
|
||||
self.starttls = False
|
||||
self.listener_type = listener_type
|
||||
|
||||
async def handle_DATA(
|
||||
self, server: SMTP, session: SMTPSession, envelope: SMTPEnvelope
|
||||
) -> str:
|
||||
self.rcpt_tos = envelope.rcpt_tos
|
||||
self.peer = session.peer
|
||||
if session.ssl:
|
||||
self.starttls = True
|
||||
return await super().handle_DATA(server, session, envelope)
|
||||
|
||||
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()
|
||||
for addr in self.rcpt_tos:
|
||||
for mbox in self.mbox_finder(addr.lower()):
|
||||
@ -78,7 +68,7 @@ def protocol_factory_starttls(
|
||||
):
|
||||
logger.info("Got smtp client cb starttls")
|
||||
try:
|
||||
handler = MyHandler(mails_path, mbox_finder, "starttls")
|
||||
handler = MyHandler(mails_path, mbox_finder)
|
||||
smtp = SMTP(
|
||||
handler=handler,
|
||||
require_starttls=require_starttls,
|
||||
@ -96,7 +86,7 @@ def protocol_factory(
|
||||
):
|
||||
logger.info("Got smtp client cb")
|
||||
try:
|
||||
handler = MyHandler(mails_path, mbox_finder, "plain")
|
||||
handler = MyHandler(mails_path, mbox_finder)
|
||||
smtp = SMTP(handler=handler, enable_SMTPUTF8=smtputf8)
|
||||
except:
|
||||
logger.exception("Something went wrong")
|
||||
|
@ -1,5 +1,5 @@
|
||||
-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'
|
||||
attrs==23.2.0; python_version >= '3.7'
|
||||
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-MailFrom: foo@sender.com
|
||||
X-RcptTo: foo@bar.com
|
||||
X-SSL: Type: plain, STARTTLS: False
|
||||
|
||||
Hello world
|
||||
Byee
|
||||
|
Loading…
Reference in New Issue
Block a user