Closed aliceh75 closed 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.
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.
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.