feat(02-02): capture named sessions through a loopback proxy

Record Nuxt/MCP traffic as ordered flows via parity:proxy, pin
loopback upstream, and refuse oversized or credential-shaped fixtures.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-17 12:27:57 +02:00
parent 603270da08
commit bb6a5a91c9
9 changed files with 1209 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ import (
func TestParityCommands(t *testing.T) {
names := commandNames()
for _, want := range []string{"parity:record", "parity:replay"} {
for _, want := range []string{"parity:record", "parity:replay", "parity:proxy"} {
if !containsName(names, want) {
t.Fatalf("missing %s in %v", want, names)
}
@@ -99,6 +99,23 @@ func TestParityCommands(t *testing.T) {
if err := runParity("parity:replay", "--fixtures", keyFixture, "--target", keyOrder.URL); err != nil {
t.Fatalf("reordered JSON keys must pass: %v", err)
}
err = runParity("parity:proxy")
if err == nil || !strings.Contains(err.Error(), "--rules") {
t.Fatalf("proxy without rules: %v", err)
}
rulesPath := filepath.Join(outDir, "rules.yaml")
if err := os.WriteFile(rulesPath, []byte("client: nuxt\nkeep_request_headers: []\nkeep_response_headers: []\n"), 0o644); err != nil {
t.Fatal(err)
}
err = runParity("parity:proxy", "--rules", rulesPath, "--fixtures", outDir, "--upstream", "http://example.com")
if err == nil || !strings.Contains(err.Error(), "loopback") {
t.Fatalf("proxy non-loopback upstream: %v", err)
}
err = runParity("parity:proxy", "--rules", rulesPath, "--fixtures", outDir, "--listen", "0.0.0.0:8422")
if err == nil || !strings.Contains(err.Error(), "loopback") {
t.Fatalf("proxy non-loopback listen: %v", err)
}
}
func commandNames() []string {