Skip to content

Commit

Permalink
Set imap/smtp APLN in autotest
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Jul 17, 2024
1 parent f76f427 commit 11db1b9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions validation/autotest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import smtplib
import os
import ssl
try:
import yaml # pip install pyyaml
except ModuleNotFoundError:
Expand All @@ -19,10 +20,13 @@ def test_smtp(server: dict):
host = server["hostname"]
port = server["port"]
if server["socket"] == "SSL":
smtplib.SMTP_SSL(host, port)
context = ssl.create_default_context()
context.set_alpn_protocols("smtp")
smtplib.SMTP_SSL(host, port, context=context)
elif server["socket"] == "STARTTLS":
smtpconn = smtplib.SMTP(host, port)
smtpconn = smtplib.SMTP(host, port, context=context)
context = ssl.create_default_context()
context.set_alpn_protocols("smtp")
smtpconn.starttls(context=context)
smtpconn.ehlo()
elif server["socket"] == "PLAIN":
Expand All @@ -38,10 +42,13 @@ def test_imap(server: dict):
host = server["hostname"]
port = server["port"]
if server["socket"] == "SSL":
imaplib.IMAP4_SSL(host, port=port)
context = ssl.create_default_context()
context.set_alpn_protocols("imap")
imaplib.IMAP4_SSL(host, port=port, context=context)
elif server["socket"] == "STARTTLS":
imapconn = imaplib.IMAP4(host, port=port)
context = ssl.create_default_context()
context.set_alpn_protocols("imap")
imapconn.starttls(ssl_context=context)
elif server["socket"] == "PLAIN":
imaplib.IMAP4(host, port)
Expand Down

0 comments on commit 11db1b9

Please sign in to comment.