Package org.mockserver.imports
Class ImportRedaction
java.lang.Object
org.mockserver.imports.ImportRedaction
Applies
FixtureRedactor masking to expectations produced by the import
pipeline (HarImporter, PostmanCollectionImporter) before they
are persisted, so real credentials in captured traffic never land in the
expectation store.
Redaction is on by default. Imported requests and responses
have sensitive headers (Authorization, X-Api-Key, Cookie,
Set-Cookie, Proxy-Authorization, etc. — see
FixtureRedactor.defaultSensitiveHeaders()) and well-known sensitive JSON
body fields replaced with FixtureRedactor.REDACTED_PLACEHOLDER. The
placeholder keeps the expectation structurally intact so it still matches.
Callers can disable redaction or extend the sensitive-key list via
ImportRedaction.Options. The expectation id assigned by the importer is preserved
across redaction (the underlying FixtureRedactor rebuilds expectations
without copying the id).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRedaction options for an import. -
Field Summary
FieldsModifier and TypeFieldDescriptionDefault JSON body field names redacted on import (case-insensitive, matched at any depth). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<Expectation>redact(List<Expectation> expectations, ImportRedaction.Options options) Redact the supplied expectations according tooptions.
-
Field Details
-
DEFAULT_SENSITIVE_BODY_FIELDS
Default JSON body field names redacted on import (case-insensitive, matched at any depth). Covers the common secret-bearing field names seen in captured API traffic.
-
-
Constructor Details
-
ImportRedaction
public ImportRedaction()
-
-
Method Details
-
redact
public static List<Expectation> redact(List<Expectation> expectations, ImportRedaction.Options options) Redact the supplied expectations according tooptions. When redaction is disabled the input list is returned unchanged; otherwise a new list of redacted expectations (preserving each expectation's id) is returned.- Parameters:
expectations- expectations produced by an importer (may be empty)options- redaction options; defaults to enabled ifnull- Returns:
- the redacted (or original, when disabled) expectations
-