MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / TestAccessReject

Function TestAccessReject

handler/direct_test.go:111–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

109}
110
111func TestAccessReject(t *testing.T) {
112 proxy := NewProxyHandler(&Config{
113 Dialer: deniedDialer{},
114 AccessReject: staticReject{status: http.StatusTeapot, body: "access response"},
115 })
116 rr := httptest.NewRecorder()
117 req := &http.Request{
118 Method: http.MethodConnect,
119 URL: &url.URL{Host: "openrouter.ai:443"},
120 RequestURI: "openrouter.ai:443",
121 Host: "openrouter.ai:443",
122 RemoteAddr: "198.51.100.7:1234",
123 ProtoMajor: 1,
124 }
125
126 proxy.ServeHTTP(rr, req)
127
128 if rr.Code != http.StatusTeapot {
129 t.Fatalf("status = %d, want %d", rr.Code, http.StatusTeapot)
130 }
131 if rr.Body.String() != "access response" {
132 t.Fatalf("body = %q, want access response", rr.Body.String())
133 }
134}

Callers

nothing calls this directly

Calls 4

ServeHTTPMethod · 0.95
NewProxyHandlerFunction · 0.85
FatalfMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected