defmodule ActivityPub.HeadersTest do use Postland.DataCase, async: true use ExUnitProperties import ActivityPub.Headers property "can verify what it signs" do private = Postland.KeyFixtures.private() |> :public_key.pem_decode() |> hd() |> :public_key.pem_entry_decode() actor_fetcher = fn _ -> Postland.KeyFixtures.public() |> :public_key.pem_decode() |> hd() |> :public_key.pem_entry_decode() end check all( method <- member_of([:get, :post]), body <- StreamData.binary(), host1 <- StreamData.string([?a..?z, ?0..?9, ?-]), host2 <- StreamData.string([?a..?z, ?0..?9, ?-]) ) do url = URI.parse("#{host1}/inbox") actor_url = "#{host2}/actor" headers = signing_headers(method, url, body, actor_url, private) verify(method, "/inbox", headers, actor_fetcher) end end end