MCPcopy
hub / github.com/perkeep/perkeep / testServer

Function testServer

internal/httputil/auth_test.go:28–44  ·  view source on GitHub ↗
(t *testing.T, l net.Listener)

Source from the content-addressed store, hash-verified

26)
27
28func 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
46func TestLocalhostAuthIPv6(t *testing.T) {
47 l, err := net.Listen("tcp", "[::1]:0")

Callers 2

TestLocalhostAuthIPv6Function · 0.85
TestLocalhostAuthIPv4Function · 0.85

Calls 2

IsLocalhostFunction · 0.70
StartMethod · 0.65

Tested by

no test coverage detected