MCPcopy
hub / github.com/fabiolb/fabio / TestProxyHTTPSTransport

Function TestProxyHTTPSTransport

proxy/http_integration_test.go:589–619  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

587}
588
589func TestProxyHTTPSTransport(t *testing.T) {
590 sni := &sniHandler{}
591
592 server := httptest.NewUnstartedServer(sni)
593 server.TLS = tlsServerConfig()
594 server.StartTLS()
595 defer server.Close()
596
597 proxy := httptest.NewServer(&HTTPProxy{
598 ProtectHeaders: testProtectHeaders,
599 Config: config.Proxy{},
600 Transport: &http.Transport{TLSClientConfig: tlsClientConfig()},
601 Lookup: func(r *http.Request) *route.Target {
602 tbl, _ := route.NewTable(bytes.NewBufferString("route add srv / " + server.URL + ` opts "proto=https host=foo.com tlsskipverify=true"`))
603 return tbl.Lookup(r, route.Picker["rr"], route.Matcher["prefix"], globCache, globEnabled)
604 },
605 })
606 defer proxy.Close()
607
608 resp, body := mustGet(proxy.URL)
609 if got, want := resp.StatusCode, http.StatusOK; got != want {
610 t.Fatalf("got status %d want %d", got, want)
611 }
612 if got, want := string(body), "OK"; got != want {
613 t.Fatalf("got body %q want %q", got, want)
614 }
615 if got, want := sni.sni, "foo.com"; got != want {
616 t.Fatalf("got sni %q want %q", got, want)
617 }
618
619}
620
621func TestProxyHTTPSUpstreamSkipVerify(t *testing.T) {
622 server := httptest.NewUnstartedServer(okHandler)

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
LookupMethod · 0.95
NewTableFunction · 0.92
tlsServerConfigFunction · 0.85
tlsClientConfigFunction · 0.85
mustGetFunction · 0.85
StartTLSMethod · 0.80

Tested by

no test coverage detected