diff --git a/tests/core/test_httpy.py b/tests/core/test_httpy.py new file mode 100644 index 0000000..bf5053a --- /dev/null +++ b/tests/core/test_httpy.py @@ -0,0 +1,36 @@ +# FIXME: Better way than hitting live httpbin? +import dataclasses + +import pytest + +from core.httpy import Client # TODO: Test async client + + +@dataclasses.dataclass +class MockActor: + private_key: str + public_key: str + public_key_id: str + + +@pytest.fixture +def signing_actor(keypair): + return MockActor( + private_key=keypair["private_key"], + public_key=keypair["public_key_id"], + public_key_id="https://example.com/test-actor", + ) + + +def test_basics(): + with Client() as client: + resp = client.get("https://httpbin.org/status/200") + assert resp.status_code == 200 + + +def test_signature(signing_actor): + with Client(actor=signing_actor) as client: + resp = client.get("https://httpbin.org/headers") + resp.raise_for_status() + body = resp.json() + assert "Signature" in body["headers"]