Skip to content

Commit

Permalink
e2e/tests (TestProxyUpstream): use httpbin/headers/ endpoint to asser…
Browse files Browse the repository at this point in the history
…t traffic
  • Loading branch information
Choraden authored and mmatczuk committed Sep 6, 2023
1 parent d789027 commit e47d6ff
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions e2e/tests/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,10 @@ func TestProxyUpstream(t *testing.T) {
t.Skip("HTTPBIN_PROTOCOL not set to http")
}

res := string(newClient(t, httpbin).GET("/header/via/").ExpectStatus(http.StatusNotFound).Body)
_, viaHeader, ok := strings.Cut(res, "=")
if !ok {
t.Fatalf("unexpected response: %q", res)
}

l := len("1.1 ")
filter := func(s string) string {
i := strings.LastIndex(s, "-")
if i < l {
t.Errorf("unexpected via header: %q", s)
return ""
}
return s[l:i]
}

viaHeader := newClient(t, httpbin).GET("/headers/").Header["Via"]
var success bool
for _, via := range strings.Split(viaHeader, ", ") {
if forwarder.UpstreamProxyServiceName == filter(via) {
for _, via := range viaHeader {
if strings.Contains(via, forwarder.UpstreamProxyServiceName) {
success = true
}
}
Expand Down

0 comments on commit e47d6ff

Please sign in to comment.