From ef92b54db3b84720ed919640e5108783fcf1b8ad Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 8 Apr 2017 18:34:10 +0900 Subject: [PATCH] Revert "integration: Add tests for X-Forwarded-Proto handling" This reverts commit 6aa581d2f05efd70c6e1fcf5689dd176bce76240. --- gennghttpxfun.py | 2 +- integration-tests/nghttpx_http2_test.go | 202 +----------------------- 2 files changed, 3 insertions(+), 201 deletions(-) diff --git a/gennghttpxfun.py b/gennghttpxfun.py index 1f4d9b79..770d023d 100755 --- a/gennghttpxfun.py +++ b/gennghttpxfun.py @@ -163,7 +163,7 @@ OPTIONS = [ "redirect-https-port", "frontend-max-requests", "single-thread", - "add-x-forwarded-proto", + "no-add-x-forwarded-proto", "strip-incoming-x-forwarded-proto", "single-process", ] diff --git a/integration-tests/nghttpx_http2_test.go b/integration-tests/nghttpx_http2_test.go index 71f74d74..04d3badc 100644 --- a/integration-tests/nghttpx_http2_test.go +++ b/integration-tests/nghttpx_http2_test.go @@ -35,105 +35,6 @@ func TestH2H1PlainGET(t *testing.T) { } } -// TestH2H1AddXfp tests that server appends :scheme to the existing -// x-forwarded-proto header field. -func TestH2H1AddXfp(t *testing.T) { - st := newServerTester([]string{"--add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { - xfp := r.Header.Get("X-Forwarded-Proto") - if got, want := xfp, "foo, http"; got != want { - t.Errorf("X-Forwarded-Proto = %q; want %q", got, want) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H1AddXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - -// TestH2H1NoAddXfp tests that server does not append :scheme to the -// existing x-forwarded-proto header field. -func TestH2H1NoAddXfp(t *testing.T) { - st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) { - xfp := r.Header.Get("X-Forwarded-Proto") - if got, want := xfp, "foo"; got != want { - t.Errorf("X-Forwarded-Proto = %q; want %q", got, want) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H1NoAddXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - -// TestH2H1StripXfp tests that server strips incoming -// x-forwarded-proto header field. -func TestH2H1StripXfp(t *testing.T) { - st := newServerTester([]string{"--add-x-forwarded-proto", "--strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { - xfp := r.Header.Get("X-Forwarded-Proto") - if got, want := xfp, "http"; got != want { - t.Errorf("X-Forwarded-Proto = %q; want %q", got, want) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H1StripXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - -// TestH2H1StripNoAddXfp tests that server strips incoming -// x-forwarded-proto header field, and does not add another. -func TestH2H1StripNoAddXfp(t *testing.T) { - st := newServerTester([]string{"--strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { - if got, found := r.Header["X-Forwarded-Proto"]; found { - t.Errorf("X-Forwarded-Proto = %q; want nothing", got) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H1StripNoAddXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - // TestH2H1AddXff tests that server generates X-Forwarded-For header // field when forwarding request to backend. func TestH2H1AddXff(t *testing.T) { @@ -840,7 +741,7 @@ func TestH2H1SNI(t *testing.T) { // with http value since :scheme is http, even if the frontend // connection is encrypted. func TestH2H1TLSXfp(t *testing.T) { - st := newServerTesterTLS([]string{"--add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { + st := newServerTesterTLS(nil, t, func(w http.ResponseWriter, r *http.Request) { if got, want := r.Header.Get("x-forwarded-proto"), "http"; got != want { t.Errorf("x-forwarded-proto: want %v; got %v", want, got) } @@ -1854,7 +1755,7 @@ func TestH2H2NoHostRewrite(t *testing.T) { // with http value since :scheme is http, even if the frontend // connection is encrypted. func TestH2H2TLSXfp(t *testing.T) { - st := newServerTesterTLS([]string{"--http2-bridge", "--add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { + st := newServerTesterTLS([]string{"--http2-bridge"}, t, func(w http.ResponseWriter, r *http.Request) { if got, want := r.Header.Get("x-forwarded-proto"), "http"; got != want { t.Errorf("x-forwarded-proto: want %v; got %v", want, got) } @@ -1872,105 +1773,6 @@ func TestH2H2TLSXfp(t *testing.T) { } } -// TestH2H2AddXfp tests that server appends :scheme to the existing -// x-forwarded-proto header field. -func TestH2H2AddXfp(t *testing.T) { - st := newServerTesterTLS([]string{"--http2-bridge", "--add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { - xfp := r.Header.Get("X-Forwarded-Proto") - if got, want := xfp, "foo, http"; got != want { - t.Errorf("X-Forwarded-Proto = %q; want %q", got, want) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H2AddXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - -// TestH2H2NoAddXfp tests that server does not append :scheme to the -// existing x-forwarded-proto header field. -func TestH2H2NoAddXfp(t *testing.T) { - st := newServerTesterTLS([]string{"--http2-bridge"}, t, func(w http.ResponseWriter, r *http.Request) { - xfp := r.Header.Get("X-Forwarded-Proto") - if got, want := xfp, "foo"; got != want { - t.Errorf("X-Forwarded-Proto = %q; want %q", got, want) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H2NoAddXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - -// TestH2H2StripXfp tests that server strips incoming -// x-forwarded-proto header field. -func TestH2H2StripXfp(t *testing.T) { - st := newServerTesterTLS([]string{"--http2-bridge", "--strip-incoming-x-forwarded-proto", "--add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { - xfp := r.Header.Get("X-Forwarded-Proto") - if got, want := xfp, "http"; got != want { - t.Errorf("X-Forwarded-Proto = %q; want %q", got, want) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H2StripXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - -// TestH2H2StripNoAddXfp tests that server strips incoming -// x-forwarded-proto header field, and does not add another. -func TestH2H2StripNoAddXfp(t *testing.T) { - st := newServerTesterTLS([]string{"--http2-bridge", "--strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) { - if got, found := r.Header["X-Forwarded-Proto"]; found { - t.Errorf("X-Forwarded-Proto = %q; want nothing", got) - } - }) - defer st.Close() - - res, err := st.http2(requestParam{ - name: "TestH2H2StripNoAddXfp", - header: []hpack.HeaderField{ - pair("x-forwarded-proto", "foo"), - }, - }) - if err != nil { - t.Fatalf("Error st.http2() = %v", err) - } - if got, want := res.status, 200; got != want { - t.Errorf("status = %v; want %v", got, want) - } -} - // TestH2H2AddXff tests that server generates X-Forwarded-For header // field when forwarding request to backend. func TestH2H2AddXff(t *testing.T) {