Skip to content

Commit 6daaa0d

Browse files
committed
fixup! Return certificates by certs fixture.
1 parent 3de3014 commit 6daaa0d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tests/conftest.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def pytest_addoption(parser):
1919
parser.addoption("--globals", default="")
2020

2121

22-
def self_signed_cert(test_dir, name):
22+
def self_signed_cert(name):
2323
k = crypto.PKey()
2424
k.generate_key(crypto.TYPE_RSA, 2048)
2525
cert = crypto.X509()
@@ -29,12 +29,6 @@ def self_signed_cert(test_dir, name):
2929
cert.gmtime_adj_notAfter(365 * 86400) # 365 days
3030
cert.set_pubkey(k)
3131
cert.sign(k, "sha512")
32-
(test_dir / f"{name}.key").write_text(
33-
crypto.dump_privatekey(crypto.FILETYPE_PEM, k).decode("utf-8")
34-
)
35-
(test_dir / f"{name}.crt").write_text(
36-
crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode("utf-8")
37-
)
3832
return (
3933
crypto.dump_privatekey(crypto.FILETYPE_PEM, k),
4034
crypto.dump_certificate(crypto.FILETYPE_PEM, cert),
@@ -101,4 +95,7 @@ def nginx(testdir, pytestconfig, nginx_config, certs, logger, otelcol):
10195

10296
@pytest.fixture(scope="module")
10397
def certs(testdir):
104-
yield self_signed_cert(testdir, "localhost")
98+
key, cert = self_signed_cert("localhost")
99+
(testdir / "localhost.key").write_text(key.decode("utf-8"))
100+
(testdir / "localhost.crt").write_text(cert.decode("utf-8"))
101+
yield (key, cert)

0 commit comments

Comments
 (0)