Class FixtureRedactor
Operates on copies: the live event log is never mutated. Header values for a configurable set of header names are replaced with a placeholder ("***REDACTED***").
Default sensitive headers: Authorization, x-api-key, api-key,
Cookie, Set-Cookie, Proxy-Authorization.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a redactor with the default sensitive header list and no body-field redaction.FixtureRedactor(Collection<String> sensitiveHeaders) Create a redactor with a custom sensitive header list and no body-field redaction.FixtureRedactor(Collection<String> sensitiveHeaders, Collection<String> sensitiveBodyFields) Create a redactor with custom sensitive headers and JSON body field names. -
Method Summary
Modifier and TypeMethodDescriptionThe default sensitive header names (case-insensitive), as an unmodifiable set, so callers can reuse them when constructing a redactor with additional body fields without re-declaring the list.redact(Expectation[] expectations) Redact sensitive headers in an array of expectations.redact(Expectation[] expectations, boolean preserveConstraints) Redact sensitive headers in an array of expectations.redactRequestDefinition(RequestDefinition requestDefinition) Redact sensitive headers (and configured JSON body fields) in a single request definition, returning a redacted clone.redactResponseObject(HttpResponse response) Redact sensitive headers (and configured JSON body fields) in a single response, returning a redacted clone.
-
Field Details
-
REDACTED_PLACEHOLDER
- See Also:
-
-
Constructor Details
-
FixtureRedactor
public FixtureRedactor()Create a redactor with the default sensitive header list and no body-field redaction. -
FixtureRedactor
Create a redactor with a custom sensitive header list and no body-field redaction.- Parameters:
sensitiveHeaders- header names to redact (case-insensitive)
-
FixtureRedactor
Create a redactor with custom sensitive headers and JSON body field names. Body fields are matched case-insensitively at any depth of a JSON request/response body; their values are replaced with the placeholder.- Parameters:
sensitiveHeaders- header names to redact (case-insensitive)sensitiveBodyFields- JSON field names to redact in bodies (case-insensitive)
-
-
Method Details
-
defaultSensitiveHeaders
The default sensitive header names (case-insensitive), as an unmodifiable set, so callers can reuse them when constructing a redactor with additional body fields without re-declaring the list. -
redact
Redact sensitive headers in an array of expectations. Returns new Expectation objects; the originals are not modified.The
Times/TimeToLiveof the result default to unlimited and the expectationidis dropped — appropriate for the fixture export/import use case where redacted expectations are re-imported as fresh, unlimited mocks. Useredact(Expectation[], boolean)withpreserveConstraints=trueto keep the original replay constraints and id (e.g. on the recorded-expectation path).- Parameters:
expectations- the expectations to redact- Returns:
- new expectations with sensitive header values replaced
-
redact
Redact sensitive headers in an array of expectations. Returns new Expectation objects; the originals are not modified.- Parameters:
expectations- the expectations to redactpreserveConstraints- whentrue, copyTimes,TimeToLive,priorityandidfrom each source expectation into its redacted result; whenfalse, default to unlimitedTimes/TimeToLiveand drop the id (original fixture export/import behaviour)- Returns:
- new expectations with sensitive header values replaced
-
redactRequestDefinition
Redact sensitive headers (and configured JSON body fields) in a single request definition, returning a redacted clone. The original is never mutated. Non-HttpRequestrequest definitions (e.g. OpenAPI definitions) are returned unchanged.Used by the live event-log / dashboard redaction path so the masked copy is shown without affecting verification, which reads the unredacted request directly.
- Parameters:
requestDefinition- the request to redact (may benull)- Returns:
- a redacted clone, or the original for null / non-HttpRequest inputs
-
redactResponseObject
Redact sensitive headers (and configured JSON body fields) in a single response, returning a redacted clone. The original is never mutated.- Parameters:
response- the response to redact (may benull)- Returns:
- a redacted clone, or
nullwhenresponseis null
-