Skip to content

Commit

Permalink
Return certificates by certs fixture.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimf5 committed Dec 20, 2024
1 parent 67068ff commit 3de3014
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def self_signed_cert(test_dir, name):
(test_dir / f"{name}.crt").write_text(
crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode("utf-8")
)
return (
crypto.dump_privatekey(crypto.FILETYPE_PEM, k),
crypto.dump_certificate(crypto.FILETYPE_PEM, cert),
)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -97,4 +101,4 @@ def nginx(testdir, pytestconfig, nginx_config, certs, logger, otelcol):

@pytest.fixture(scope="module")
def certs(testdir):
self_signed_cert(testdir, "localhost")
yield self_signed_cert(testdir, "localhost")
9 changes: 1 addition & 8 deletions tests/trace_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ def trace_service(request, pytestconfig, testdir, logger, certs):
listen_addr = f"127.0.0.1:{24317 if trace_service.use_otelcol else 14317}"
server.add_insecure_port(listen_addr)
if pytestconfig.option.otelcol is None:
creds = grpc.ssl_server_credentials(
[
(
(testdir / "localhost.key").read_text().encode(),
(testdir / "localhost.crt").read_text().encode(),
)
]
)
creds = grpc.ssl_server_credentials([certs])
server.add_secure_port("127.0.0.1:14318", creds)
listen_addr += " and 127.0.0.1:14318"
logger.info(f"Starting trace service at {listen_addr}...")
Expand Down

0 comments on commit 3de3014

Please sign in to comment.