Skip to content

Testing

lacme.testing

Test utilities for lacme.

Provides :class:MockACMEServer, an in-process ACME server backed by :class:httpx.MockTransport for integration testing.

MockACMEServer

In-process mock ACME server for integration tests.

Implements enough of the ACME protocol to support the full :meth:~lacme.client.Client.issue flow. Does not verify JWS signatures — focuses on protocol flow testing.

Not thread-safe. Intended for single-threaded or single-async-task test scenarios.

Usage::

server = MockACMEServer()
transport = server.as_transport()
http = httpx.AsyncClient(transport=transport, base_url="https://acme.test")
async with Client(
    directory_url="https://acme.test/directory",
    http_client=http,
    account_key=key,
    challenge_handler=handler,
) as client:
    bundle = await client.issue(["example.com"])
as_transport
as_transport() -> httpx.MockTransport

Return an :class:httpx.MockTransport wrapping this server.

validate_challenge
validate_challenge(challenge_url: str) -> None

Manually validate a challenge (when auto_validate=False).