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

Function TestSetRequestUrlFromRequest

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

Source from the content-addressed store, hash-verified

476}
477
478func TestSetRequestUrlFromRequest(t *testing.T) {
479 for _, ti := range []struct {
480 msg string
481 originalURL *url.URL
482 expectedURL *url.URL
483 req *http.Request
484 }{{
485 "Scheme and Host are set when empty",
486 &url.URL{Scheme: "", Host: ""},
487 &url.URL{Scheme: "http", Host: "example.com"},
488 &http.Request{TLS: nil, Host: "example.com"},
489 }, {
490 "Scheme and Host are not modified when already set",
491 &url.URL{Scheme: "http", Host: "example.com"},
492 &url.URL{Scheme: "http", Host: "example.com"},
493 &http.Request{TLS: &tls.ConnectionState{}, Host: "example2.com"},
494 }, {
495 "Scheme is set to http when TLS not set",
496 &url.URL{Scheme: ""},
497 &url.URL{Scheme: "http"},
498 &http.Request{TLS: nil},
499 }, {
500 "Scheme is set to https when TLS is set",
501 &url.URL{Scheme: ""},
502 &url.URL{Scheme: "https"},
503 &http.Request{TLS: &tls.ConnectionState{}},
504 }} {
505 u, _ := url.Parse(ti.originalURL.String())
506 setRequestURLFromRequest(u, ti.req)
507
508 beq := reflect.DeepEqual(ti.expectedURL, u)
509 if !beq {
510 t.Error(ti.msg, "<urls don't match>", ti.expectedURL, u)
511 }
512 }
513}
514
515func TestSetRequestUrlForDynamicBackend(t *testing.T) {
516 for _, ti := range []struct {

Callers

nothing calls this directly

Calls 4

setRequestURLFromRequestFunction · 0.85
ParseMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…