plug_body_digest v0.6.1 PlugBodyDigest.ConnTest View Source

Helpers for testing request body digests with Plug/Phoenix.

Note

When testing with Plug.Test or Phoenix.ConnTest, the request body is not always read through Plug.Parsers, in which case the custom body_reader is not invoked. In particular this happens when setting params_or_body to a map.

Digest header verification is skipped when this happens, so in test cases that verify the correct handling of the Digest header, both for positive and negative test scenarions, always pass in the body as a binary!

Link to this section Summary

Functions

Add an HTTP Digest header (RFC3230, section 4.3.2).

Link to this section Functions

Link to this function

with_digest(conn, body_or_digests)

View Source

Add an HTTP Digest header (RFC3230, section 4.3.2).

When the request body is passed in as a binary, a SHA-256 digest of the body is calculated and added as part of the header. Alternatively, a map of digest types and values may be provided.