(t *testing.T)
| 550 | } |
| 551 | |
| 552 | func TestProxyHTTPSUpstream(t *testing.T) { |
| 553 | server := httptest.NewUnstartedServer(okHandler) |
| 554 | server.TLS = tlsServerConfig() |
| 555 | server.StartTLS() |
| 556 | defer server.Close() |
| 557 | |
| 558 | proxy := httptest.NewServer(&HTTPProxy{ |
| 559 | ProtectHeaders: testProtectHeaders, |
| 560 | Config: config.Proxy{}, |
| 561 | Transport: &http.Transport{TLSClientConfig: tlsClientConfig()}, |
| 562 | Lookup: func(r *http.Request) *route.Target { |
| 563 | tbl, _ := route.NewTable(bytes.NewBufferString("route add srv / " + server.URL + ` opts "proto=https"`)) |
| 564 | return tbl.Lookup(r, route.Picker["rr"], route.Matcher["prefix"], globCache, globEnabled) |
| 565 | }, |
| 566 | }) |
| 567 | defer proxy.Close() |
| 568 | |
| 569 | resp, body := mustGet(proxy.URL) |
| 570 | if got, want := resp.StatusCode, http.StatusOK; got != want { |
| 571 | t.Fatalf("got status %d want %d", got, want) |
| 572 | } |
| 573 | if got, want := string(body), "OK"; got != want { |
| 574 | t.Fatalf("got body %q want %q", got, want) |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | type sniHandler struct { |
| 579 | sni string |
nothing calls this directly
no test coverage detected