Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/code.cloudfoundry.org/gorouter/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/ghttp"
"golang.org/x/net/http2"

tls_helpers "code.cloudfoundry.org/cf-routing-test-helpers/tls"
"code.cloudfoundry.org/gorouter/config"
Expand Down Expand Up @@ -309,10 +308,15 @@ var _ = Describe("Router Integration", func() {
Expect(resp.StatusCode).To(Equal(http.StatusOK))
Expect(resp.Proto).To(Equal("HTTP/1.1"))

h2_client := &http.Client{Transport: &http2.Transport{TLSClientConfig: clientTLSConfig}}
_, err = h2_client.Get(fmt.Sprintf("https://test.%s:%d", test_util.LocalhostDNS, cfg.SSLPort))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("unexpected ALPN protocol"))
h2OnlyProtocols := new(http.Protocols)
h2OnlyProtocols.SetHTTP2(true)
h2_client := &http.Client{Transport: &http.Transport{TLSClientConfig: clientTLSConfig.Clone(), Protocols: h2OnlyProtocols}}
resp, err = h2_client.Get(fmt.Sprintf("https://test.%s:%d", test_util.LocalhostDNS, cfg.SSLPort))
// HTTP/2 is disabled on the server, so a client attempting h2 must not
// negotiate it over ALPN and falls back to HTTP/1.1.
Expect(err).ToNot(HaveOccurred())
Expect(resp.TLS.NegotiatedProtocol).ToNot(Equal("h2"))
Expect(resp.Proto).To(Equal("HTTP/1.1"))
})
})

Expand Down Expand Up @@ -355,7 +359,9 @@ var _ = Describe("Router Integration", func() {
}
}()
Eventually(func() bool { return appRegistered(routesUri, runningApp1) }).Should(BeTrue())
client := &http.Client{Transport: &http2.Transport{TLSClientConfig: clientTLSConfig}}
h2OnlyProtocols := new(http.Protocols)
h2OnlyProtocols.SetHTTP2(true)
client := &http.Client{Transport: &http.Transport{TLSClientConfig: clientTLSConfig.Clone(), Protocols: h2OnlyProtocols}}
resp, err := client.Get(fmt.Sprintf("https://test.%s:%d", test_util.LocalhostDNS, cfg.SSLPort))
Expect(err).ToNot(HaveOccurred())
Expect(resp.StatusCode).To(Equal(http.StatusOK))
Expand Down
14 changes: 7 additions & 7 deletions src/code.cloudfoundry.org/gorouter/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/onsi/gomega/gbytes"
"github.com/openzipkin/zipkin-go/propagation/b3"
"go.uber.org/zap"
"golang.org/x/net/http2"
"golang.org/x/net/websocket"

"code.cloudfoundry.org/gorouter/common/health"
Expand Down Expand Up @@ -164,13 +163,14 @@ var _ = Describe("Proxy", func() {
tlsCert, err := tls.X509KeyPair(gorouterCertChain.CACertPEM, gorouterCertChain.CAPrivKeyPEM)
Expect(err).NotTo(HaveOccurred())

h2ClientTLSConfig := &tls.Config{
Certificates: []tls.Certificate{tlsCert},
RootCAs: rootCACertPool,
}
h2OnlyProtocols := new(http.Protocols)
h2OnlyProtocols.SetHTTP2(true)
client := &http.Client{
Transport: &http2.Transport{
TLSClientConfig: &tls.Config{
Certificates: []tls.Certificate{tlsCert},
RootCAs: rootCACertPool,
},
},
Transport: &http.Transport{TLSClientConfig: h2ClientTLSConfig, Protocols: h2OnlyProtocols},
}

req, err := http.NewRequest("GET", "https://"+proxyServer.Addr().String(), nil)
Expand Down
Loading