Mux v3.1.0 Mux.Webhooks.TestUtils View Source
This module provides a utility function for generating valid signatures. You are encouraged to use it for testing how your application behaves against malicious requests.
Link to this section Summary
Functions
Generates a webhook signature. Pass in the raw request body and the
webhook "secret". You may also pass in the desired signature scheme.
Currently, the only valid signature scheme is "v1"
, which is also the
default one if not set explicitly. Any invalid signature scheme will fall
back to the default.
Link to this section Functions
Generates a webhook signature. Pass in the raw request body and the
webhook "secret". You may also pass in the desired signature scheme.
Currently, the only valid signature scheme is "v1"
, which is also the
default one if not set explicitly. Any invalid signature scheme will fall
back to the default.
Note that this function is intended for testing against malformed or malicious webhook requests, so you should use a fake webhook "secret".
Returns the relevant HTTP header value as a string.
Examples
iex> signature = Mux.Webhooks.TestUtils.generate_signature("payload", "SuperSecret123")
"t=1591664030,v1=e43496b6aae982c4c2fd6f8e92935f1d90216f1f64d56024e72390acfb988272"
iex> Mux.Webhooks.verify_header("payload", signature, "SuperSecret123")
:ok