Skip to content

Add SSL support (SMTPS/STARTTLS) to CLI#252

Merged
pepoluan merged 28 commits intoaio-libs:masterfrom
pepoluan:ssl-cli
Feb 22, 2021
Merged

Add SSL support (SMTPS/STARTTLS) to CLI#252
pepoluan merged 28 commits intoaio-libs:masterfrom
pepoluan:ssl-cli

Conversation

@pepoluan
Copy link
Copy Markdown
Collaborator

What do these changes do?

Implement support for SMTPS/STARTTLS for the CLI program.

Are there changes in behavior for the user?

None. This is a totally new feature that does not impact current users.

Related issue number

Closes #172

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • tox testenvs have been executed in the following environments:
    • Windows 10 (via PyCharm tox runner): (ALL)
    • Windows 10 (via Cygwin): qa,py-{nocov,cov}
    • Ubuntu 18.04 on WSL 1.0: (ALL) + static + pypy3-{nocov,cov,diffcov}
    • FreeBSD 12.2 on VBox: (ALL) + static + pypy3-{nocov,cov,diffcov}
  • Documentation reflects the changes
  • Add a news fragment into the NEWS.rst file

Original name of "args" make it a bit difficult trying to troubleshoot.
Added 5 parameters plus validation of their combinations.

Also test case for the validation logic.
Validation is simply checking they exist.

Also test case
Whoa, we never asserted this before...
It is ignored anyways if --tlscert and --tlskey not specified.
This makes them easily importable by test suites.

Also create an __all__ module attribute listing all the variables (excl.
fixtures) available in conftest.py
* test_ssl_files renamed to test_ssl_files_err
* Use constants for test_ssl_files_err
* isort
* black
When run using pytest directly, 1.0 is enough.

But tox (and probably PyCharm tox runner) added enough overhead that 1.0
is barely enough, resulting in flakey test.
A bit of difference between tox & GA:

* In tox, Bandit is run in "qa", because Bandit can run on Windows and
  if placed in "static", it will not be run, and that's a loss.
* In GA, Bandig is run during "Static Code Checking" because that's more
  accurate.
Lines marked "# nosec" are intentional, so we suppress Bandit's
complaints on those lines.
According to Bandit docs in https://github.com/PyCQA/bandit, we should
run Bandit using the same Python version as will be used by the program.

Since aiosmtpd is meant to be a cross-platform, cross-version library,
we move it up there to Bandit-test with every supported version.
* Extract test_tls, test_tls_noreq, and test_smtps into a separate class
  to better control the event loop
* Change from "naive timeout" (which sometimes result in test-flakines
  to Event-based continuation (more deterministic)
* Schedule the autostop to as near as possible to main() call
Because the watch_for_* watchers are now much more deterministic after
we change over to Event-based-continuation.
PyPy3.7.9-7.3.3 still barfs here.
@pepoluan pepoluan changed the title Ssl cli Add SSL support (SMTPS/STARTTLS) to CLI Feb 20, 2021
@pepoluan pepoluan added this to the 1.4 milestone Feb 20, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2021

Codecov Report

Merging #252 (40306c7) into master (d137f8d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #252   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines         1542      1571   +29     
  Branches       285       293    +8     
=========================================
+ Hits          1542      1571   +29     
Impacted Files Coverage Δ
aiosmtpd/__init__.py 100.00% <100.00%> (ø)
aiosmtpd/main.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d137f8d...40306c7. Read the comment docs.

@pepoluan pepoluan marked this pull request as ready for review February 20, 2021 17:35
* Some region..endregion folders
* main(("-n", ...)) calls wrapped in main_n() func
# Conflicts:
#	.github/workflows/unit-testing-and-coverage.yml
#	aiosmtpd/__init__.py
#	aiosmtpd/docs/NEWS.rst
#	aiosmtpd/tests/test_main.py
Apparently Unicode triangles is not as universal as the checkerboard
pattern. Go figure.
@pepoluan pepoluan added the CLI label Feb 22, 2021
@pepoluan pepoluan merged commit 32cdfe0 into aio-libs:master Feb 22, 2021
@pepoluan pepoluan deleted the ssl-cli branch February 22, 2021 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add STARTTLS support to aiosmtpd cli

1 participant