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 7fd68da commit bc69186
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions validation/autotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,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)
context = ssl.create_default_context()
context.set_alpn_protocols(["smtp"])
smtpconn = smtplib.SMTP(host, port)
smtpconn.starttls(context=context)
smtpconn.ehlo()
elif server["socket"] == "PLAIN":
Expand All @@ -38,10 +41,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, ssl_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 bc69186

Please sign in to comment.