# HG changeset patch # User Thomas Sileo # Date 1556058706 -7200 # Wed Apr 24 00:31:46 2019 +0200 # Node ID 033ed400773f1061da8983af693d61dabb13d1ee # Parent fbbfd7c807780b8daab5f21ae5d3fa22b30b0686 Update HTTP sig tests diff --git a/tests/test_httpsig.py b/tests/test_httpsig.py --- a/tests/test_httpsig.py +++ b/tests/test_httpsig.py @@ -21,6 +21,7 @@ back.FETCH_MOCK["https://lol.com#lol"] = { "publicKey": k.to_dict(), "id": "https://lol.com", + "type": "Person", } httpretty.register_uri(httpretty.POST, "https://remote-instance.com", body="ok") @@ -34,3 +35,25 @@ resp.request.headers, resp.request.body, ) + + +@httpretty.activate +def test_httpsig_key(): + back = InMemBackend() + ap.use_backend(back) + + k = Key("https://lol.com", "https://lol.com/key/lol") + k.new() + back.FETCH_MOCK["https://lol.com/key/lol"] = k.to_dict() + + httpretty.register_uri(httpretty.POST, "https://remote-instance.com", body="ok") + + auth = httpsig.HTTPSigAuth(k) + resp = requests.post("https://remote-instance.com", json={"ok": 1}, auth=auth) + + assert httpsig.verify_request( + resp.request.method, + resp.request.path_url, + resp.request.headers, + resp.request.body, + )