Commit 54d32c8
committed
feat(llm): complete VCR toolkit — strict mode, body redaction, replay normalisation
Finish the LLM fixture record/replay toolkit (U4 cassette manager was already
shipped) with three operational additions, exposed via config + MCP.
- Body-field redaction: FixtureRedactor gains an optional JSON body-field list
(recursive, case-insensitive, on copies); redacts named fields in recorded
request/response bodies. Driven by record_llm_fixtures `redactBodyFields` or
the mockserver.fixtureBodyRedactFields config. Non-JSON bodies untouched;
default (header-only) behaviour unchanged. Reuses FixtureRedactor
.defaultSensitiveHeaders() so the header list cannot diverge.
- Strict VCR mode: load_expectations_from_file `strict` (or
mockserver.llmVcrStrict) registers a lowest-priority catch-all per cassette
path (stable id, so reloads upsert rather than accumulate) returning HTTP 599
so an unmatched request fails loudly. Error body built via the ObjectMapper
(no JSON injection from path values).
- Replay normalisation: load_expectations_from_file `normalizeRequestBodyFields`
drops volatile JSON fields (case-insensitive, objects + arrays) from each
recorded request body and rewrites the matcher to JsonBody
ONLY_MATCHING_FIELDS, so per-run ids/timestamps do not block replay.
Docs: docs/code/llm-mocking.md (VCR section + config rows + source ref),
consumer configuration-properties and AI/MCP tools pages, roadmap status,
changelog.
Tests: FixtureRedactorTest body-redaction cases (request/response/nested/
non-JSON/default-untouched) + LlmMcpToolsTest strict-mode and case-insensitive
replay-normalisation (asserts the dropped field is gone from active
expectations). Core + netty tests green.1 parent 8b40cf2 commit 54d32c8
10 files changed
Lines changed: 433 additions & 10 deletions
File tree
- docs
- code
- plans
- jekyll-www.mock-server.com/mock_server
- mockserver
- mockserver-core/src
- main/java/org/mockserver
- configuration
- fixture
- test/java/org/mockserver/fixture
- mockserver-netty/src
- main/java/org/mockserver/netty/mcp
- test/java/org/mockserver/netty/mcp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
303 | 312 | | |
304 | 313 | | |
305 | 314 | | |
306 | 315 | | |
307 | 316 | | |
| 317 | + | |
| 318 | + | |
308 | 319 | | |
309 | 320 | | |
310 | 321 | | |
| |||
358 | 369 | | |
359 | 370 | | |
360 | 371 | | |
| 372 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| 810 | + | |
810 | 811 | | |
811 | 812 | | |
812 | 813 | | |
| |||
853 | 854 | | |
854 | 855 | | |
855 | 856 | | |
| 857 | + | |
| 858 | + | |
856 | 859 | | |
857 | 860 | | |
858 | 861 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
866 | 891 | | |
867 | 892 | | |
868 | 893 | | |
| |||
mockserver/mockserver-core/src/main/java/org/mockserver/configuration/ConfigurationProperties.java
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| |||
1040 | 1042 | | |
1041 | 1043 | | |
1042 | 1044 | | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1043 | 1071 | | |
1044 | 1072 | | |
1045 | 1073 | | |
| |||
0 commit comments