bamthomas / aioimaplib

Python asyncio IMAP4rev1 client library
GNU General Public License v3.0
138 stars 59 forks source link

Add unit tests for SSL #33

Closed aliceh75 closed 6 years ago

aliceh75 commented 6 years ago

This PR adds unit tests for the SSL implementation.

Testing this required the IMAP4_SSL implementation to accept an optional custom ssl context (so we could test with self signed certificates). This makes sense anyway as users of the library might want to use self signed certificates - or pass other custom ssl options.

It didn't make sense to have IMAP4_SSL accept a custom ssl context, but not IMAP4 - because doing so would have caused unnecessary duplication of code (and thus possible bugs later if someone changed one implementation and not the other).

Thus the difference between IMAP4 and IMAP4_SSL is that the former will use a plain connection if no ssl context is provided, while the latter will create a default ssl context if none is provided.

This makes sense architecturally too as it means users of IMAP4 can delegate the choice of using SSL or not to higher level code without having to test for it and use a different class. IMAP4_SSL becomes a convenience class for users who want to quickly write something using SSL, and who are happy with the default ssl context settings.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.2%) to 95.839% when pulling 7cbf9d7223cef4f3ee981693399422b29cd473c3 on aliceh75:ssl_tests into 6572fe5346cafc76a7b137e5069290df08ee7194 on bamthomas:master.

aliceh75 commented 6 years ago

The test that failed is not to do with this PR. That particular test sometimes passes and sometimes fails - and this was the case before I started writing this code. Anyway, I'll see if I can fix it.

bamthomas commented 6 years ago

hello @aliceh75 thank you again for this PR. I'll try to have a look at this unstable test. This is really cool to have a test on SSL.