MCPcopy Index your code
hub / github.com/SenseUnit/dumbproxy / TestDirectResponse

Function TestDirectResponse

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

Source from the content-addressed store, hash-verified

87}
88
89func TestDirectResponse(t *testing.T) {
90 proxy := NewProxyHandler(&Config{
91 DirectResponse: staticReject{status: http.StatusOK, body: "direct response"},
92 })
93 rr := httptest.NewRecorder()
94 req := &http.Request{
95 Method: http.MethodGet,
96 URL: &url.URL{Path: "/"},
97 Host: "web.nacl.one",
98 RemoteAddr: "198.51.100.7:1234",
99 }
100
101 proxy.ServeHTTP(rr, req)
102
103 if rr.Code != http.StatusOK {
104 t.Fatalf("status = %d, want %d", rr.Code, http.StatusOK)
105 }
106 if rr.Body.String() != "direct response" {
107 t.Fatalf("body = %q, want direct response", rr.Body.String())
108 }
109}
110
111func TestAccessReject(t *testing.T) {
112 proxy := NewProxyHandler(&Config{

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