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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user