From 83f9fa306ec4c98ba68a82af993908f9286916d5 Mon Sep 17 00:00:00 2001 From: Eugene Grebenschikov Date: Fri, 3 May 2024 23:33:13 -0700 Subject: [PATCH] Support certificate name(s) in test suite. --- tests/conftest.py | 12 ++++++------ tests/test_otel.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ea4e920..64793ef 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,8 +17,7 @@ ).decode("utf-8") -def self_signed_cert(test_dir): - name = "localhost" +def self_signed_cert(test_dir, name): k = crypto.PKey() k.generate_key(crypto.TYPE_RSA, 2048) cert = crypto.X509() @@ -66,7 +65,7 @@ def nginx_config(request, testdir, logger): @pytest.fixture(scope="module") -def nginx(testdir, nginx_config, certs, logger): +def nginx(testdir, nginx_config, _certs, logger): logger.debug(CAPABILITIES) (testdir / "nginx.conf").write_text(nginx_config) logger.info("Starting nginx...") @@ -101,6 +100,7 @@ def nginx(testdir, nginx_config, certs, logger): @pytest.fixture(scope="module") -def certs(request, testdir): - if getattr(request.module, "CERT_GEN", None) is not None: - return request.module.CERT_GEN(testdir) +def _certs(request, testdir): + if getattr(request.module, "CERTS", None) is not None: + for _ in request.module.CERTS[1:]: + request.module.CERTS[0](testdir, _) diff --git a/tests/test_otel.py b/tests/test_otel.py index 4eec46b..330ea75 100644 --- a/tests/test_otel.py +++ b/tests/test_otel.py @@ -10,7 +10,7 @@ import urllib3 -CERT_GEN = self_signed_cert +CERTS = [self_signed_cert, "localhost"] NGINX_CONFIG = """ {{ test_globals }}