(t *testing.T)
| 109 | } |
| 110 | |
| 111 | func 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 | } |
nothing calls this directly
no test coverage detected