From 63dd3c91e1fef16321c6d485e4a476576511954e Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 28 Jul 2020 00:01:42 +0300 Subject: [PATCH] python tests: do not enable strict certificate checks by default Since introduction of provider database, these certificate checks are enabled for test servers anyway, but this setting prevents usage of local servers with self-signed certificates. --- python/src/deltachat/testplugin.py | 11 ++++++++--- python/tox.ini | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index a993c6820..5bf386c6c 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -32,6 +32,10 @@ def pytest_addoption(parser): "--ignored", action="store_true", help="Also run tests marked with the ignored marker", ) + parser.addoption( + "--strict-tls", action="store_true", + help="Never accept invalid TLS certificates for test accounts", + ) def pytest_configure(config): @@ -282,9 +286,10 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data): if "e2ee_enabled" not in configdict: configdict["e2ee_enabled"] = "1" - # Enable strict certificate checks for online accounts - configdict["imap_certificate_checks"] = str(const.DC_CERTCK_STRICT) - configdict["smtp_certificate_checks"] = str(const.DC_CERTCK_STRICT) + if pytestconfig.getoption("--strict-tls"): + # Enable strict certificate checks for online accounts + configdict["imap_certificate_checks"] = str(const.DC_CERTCK_STRICT) + configdict["smtp_certificate_checks"] = str(const.DC_CERTCK_STRICT) tmpdb = tmpdir.join("livedb%d" % self.live_count) ac = self.make_account(tmpdb.strpath, logid="ac{}".format(self.live_count), quiet=quiet) diff --git a/python/tox.ini b/python/tox.ini index 91180223a..9417c5544 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -7,7 +7,7 @@ envlist = [testenv] commands = - pytest -n6 --reruns 2 --reruns-delay 5 -v -rsXx --ignored {posargs: tests examples} + pytest -n6 --reruns 2 --reruns-delay 5 -v -rsXx --ignored --strict-tls {posargs: tests examples} python tests/package_wheels.py {toxworkdir}/wheelhouse passenv = TRAVIS