MCPcopy
hub / github.com/larksuite/cli / TestProxyHandler_UnsupportedVersion

Function TestProxyHandler_UnsupportedVersion

sidecar/server-demo/handler_test.go:128–141  ·  view source on GitHub ↗

TestProxyHandler_UnsupportedVersion verifies the handler rejects requests whose HeaderProxyVersion is absent or set to an unknown value. Kept in front so an old client paired with a newer server (or vice versa) surfaces a clear 400 instead of a misleading HMAC mismatch downstream.

(t *testing.T)

Source from the content-addressed store, hash-verified

126// front so an old client paired with a newer server (or vice versa) surfaces
127// a clear 400 instead of a misleading HMAC mismatch downstream.
128func TestProxyHandler_UnsupportedVersion(t *testing.T) {
129 h := newTestHandler([]byte("key"))
130 for _, v := range []string{"", "v0", "v2"} {
131 req := httptest.NewRequest("GET", "/path", nil)
132 if v != "" {
133 req.Header.Set(sidecar.HeaderProxyVersion, v)
134 }
135 w := httptest.NewRecorder()
136 h.ServeHTTP(w, req)
137 if w.Code != http.StatusBadRequest {
138 t.Errorf("version=%q: expected 400, got %d", v, w.Code)
139 }
140 }
141}
142
143func TestProxyHandler_MissingTimestamp(t *testing.T) {
144 h := newTestHandler([]byte("key"))

Callers

nothing calls this directly

Calls 3

newTestHandlerFunction · 0.70
SetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected