(t *testing.T)
| 87 | } |
| 88 | |
| 89 | func 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 | |
| 111 | func TestAccessReject(t *testing.T) { |
| 112 | proxy := NewProxyHandler(&Config{ |
nothing calls this directly
no test coverage detected