MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / TestLoopbackGuard_WebUIJSON

Function TestLoopbackGuard_WebUIJSON

internal/server/loopback_guard_test.go:90–101  ·  view source on GitHub ↗

The web UI sends JSON. The guard accepts the web UI origin for a JSON request, because a browser must do a preflight to send it cross-origin.

(t *testing.T)

Source from the content-addressed store, hash-verified

88// The web UI sends JSON. The guard accepts the web UI origin for a JSON
89// request, because a browser must do a preflight to send it cross-origin.
90func TestLoopbackGuard_WebUIJSON(t *testing.T) {
91 r := guardEngine(nil)
92 req := httptest.NewRequest(http.MethodPost, "/patterns/name", nil)
93 req.Host = "localhost:8080"
94 req.Header.Set("Content-Type", "application/json; charset=utf-8")
95 req.Header.Set("Origin", "http://127.0.0.1:5173")
96 w := httptest.NewRecorder()
97 r.ServeHTTP(w, req)
98 if w.Code != http.StatusOK {
99 t.Errorf("got %d, want %d", w.Code, http.StatusOK)
100 }
101}
102
103// The guard lets a preflight and the Swagger documents through from any
104// Host. It accepts the Host of a CORS origin, but only for that host.

Callers

nothing calls this directly

Calls 1

guardEngineFunction · 0.85

Tested by

no test coverage detected