Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhurt committed Jan 26, 2018
1 parent bb7e2b0 commit 77e152c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions proxy/http_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,41 @@ func TestProxyRequestIDHeader(t *testing.T) {
}
}

func TestProxySTSHeader(t *testing.T) {
server := httptest.NewServer(okHandler)
defer server.Close()

proxy := httptest.NewTLSServer(&HTTPProxy{
Config: config.Proxy{
STSHeader: config.STSHeader{
MaxAge: 31536000,
Subdomains: true,
Preload: true,
},
},
Transport: &http.Transport{TLSClientConfig: tlsInsecureConfig()},
Lookup: func(r *http.Request) *route.Target {
return &route.Target{URL: mustParse(server.URL)}
},
})
defer proxy.Close()

client := http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsInsecureConfig(),
},
}
resp, err := client.Get(proxy.URL)
if err != nil {
panic(err)
}

if got, want := resp.Header.Get("Strict-Transport-Security"),
"max-age=31536000; includeSubdomains; preload"; got != want {
t.Errorf("got %v want %v", got, want)
}
}

func TestProxyNoRouteHTML(t *testing.T) {
want := "<html>503</html>"
noroute.SetHTML(want)
Expand Down

0 comments on commit 77e152c

Please sign in to comment.