PhoenixApiToolkit.TestHelpers.put_hmac
You're seeing just the function
put_hmac
, go back to PhoenixApiToolkit.TestHelpers module for more information.
Specs
put_hmac(Plug.Conn.t(), binary(), binary()) :: Plug.Conn.t()
Adds a HMAC-SHA256 signature to the connection's authorization
header for the request body.
Use create_hmac_plug_body/4
to generate a valid body. For use with endpoints secured
with PhoenixApiToolkit.Security.HmacPlug
.
It is possible to override the HMAC secret. The default generates a valid signature, so overrides are not necessary unless you wish to test the HMAC verification itself.
Examples
use Plug.Test
iex> body = %{greeting: "world"} |> Jason.encode!()
iex> conn = conn(:post, "/hello", body)
iex> put_hmac(conn, body, "supersecretkey") |> get_req_header("authorization")
["oseq9TrQc/cyOBU7ujrkKM07tFewcVoaLRK0MgslSos="]