MCPcopy Create free account
hub / github.com/zalando/skipper / TestForwardToProxy

Function TestForwardToProxy

proxy/proxy_test.go:2271–2318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2269}
2270
2271func TestForwardToProxy(t *testing.T) {
2272 for _, ti := range []struct {
2273 tls *tls.ConnectionState
2274 outgoingURL string
2275 incomingHost string
2276 expectedProxyURL string
2277 expectedRequestURL string
2278 }{{
2279 tls: nil,
2280 outgoingURL: "http://proxy.example.com/anything?key=val",
2281 incomingHost: "example.com",
2282 expectedProxyURL: "http://proxy.example.com",
2283 expectedRequestURL: "http://example.com/anything?key=val",
2284 }, {
2285 tls: nil,
2286 outgoingURL: "https://proxy.example.com/anything?key=val",
2287 incomingHost: "example.com",
2288 expectedProxyURL: "https://proxy.example.com",
2289 expectedRequestURL: "http://example.com/anything?key=val",
2290 }, {
2291 tls: &tls.ConnectionState{},
2292 outgoingURL: "http://proxy.example.com/anything?key=val",
2293 incomingHost: "example.com",
2294 expectedProxyURL: "http://proxy.example.com",
2295 expectedRequestURL: "https://example.com/anything?key=val",
2296 }} {
2297 outgoingURL, _ := url.Parse(ti.outgoingURL)
2298
2299 outgoing := &http.Request{
2300 URL: outgoingURL,
2301 Header: make(http.Header),
2302 }
2303
2304 incoming := &http.Request{
2305 Host: ti.incomingHost,
2306 TLS: ti.tls,
2307 }
2308
2309 outgoing = forwardToProxy(incoming, outgoing)
2310
2311 assert.Equal(t, ti.expectedRequestURL, outgoing.URL.String())
2312
2313 proxyURL, err := proxyFromContext(outgoing)
2314
2315 assert.NoError(t, err)
2316 assert.Equal(t, ti.expectedProxyURL, proxyURL.String())
2317 }
2318}
2319
2320func TestProxyFromEmptyContext(t *testing.T) {
2321 proxyURL, err := proxyFromContext(&http.Request{})

Callers

nothing calls this directly

Calls 4

forwardToProxyFunction · 0.85
proxyFromContextFunction · 0.85
ParseMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…