(t *testing.T, l net.Listener)
| 26 | ) |
| 27 | |
| 28 | func testServer(t *testing.T, l net.Listener) *httptest.Server { |
| 29 | ts := &httptest.Server{ |
| 30 | Listener: l, |
| 31 | Config: &http.Server{ |
| 32 | Handler: http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { |
| 33 | if IsLocalhost(r) { |
| 34 | fmt.Fprintf(rw, "authorized") |
| 35 | return |
| 36 | } |
| 37 | fmt.Fprintf(rw, "unauthorized") |
| 38 | }), |
| 39 | }, |
| 40 | } |
| 41 | ts.Start() |
| 42 | |
| 43 | return ts |
| 44 | } |
| 45 | |
| 46 | func TestLocalhostAuthIPv6(t *testing.T) { |
| 47 | l, err := net.Listen("tcp", "[::1]:0") |
no test coverage detected