Coffrify. Testing
(Coffrify v0.9.0)
View Source
Test helpers for apps consuming the Coffrify Elixir SDK.
Coffrify.Testing.Fixtures— minimal but realistic response shapes for transfers, webhooks, API keys, events.Coffrify.Testing.sign_payload_test/3— build a{body, headers}pair that passesCoffrify.Webhook.Verification.verify/4, so your handler tests don't need to hit the live API.
Summary
Functions
Sign a payload using the same scheme as Coffrify's server. Returns
{body, headers_list} ready to plug into a Plug.Test.conn/3 call.
Convenience: assert that a self-signed payload verifies. Returns the decoded event on success, raises with the rejection reason otherwise.
Functions
Sign a payload using the same scheme as Coffrify's server. Returns
{body, headers_list} ready to plug into a Plug.Test.conn/3 call.
Options
:event_id— explicitwebhook-id(defaultevt_<rand>):timestamp— explicitwebhook-timestamp(defaultnow):extra_headers— extra headers merged into the result
Example
{body, headers} =
Coffrify.Testing.sign_payload_test("whsec_abc...",
Jason.encode!(%{type: "ping"}))
conn =
:post
|> Plug.Test.conn("/webhook", body)
|> Map.update!(:req_headers, &(&1 ++ headers))
Convenience: assert that a self-signed payload verifies. Returns the decoded event on success, raises with the rejection reason otherwise.