integration: Validate status code explicitly
Without this validation, test spuriously succeeds, but in fact it doesn't. This might occur if stream is closed with RST_STREAM or GOAWAY.
This commit is contained in:
parent
deacc202ff
commit
9f318d1249
|
@ -45,12 +45,15 @@ func TestH2H1AddXff(t *testing.T) {
|
|||
})
|
||||
defer st.Close()
|
||||
|
||||
_, err := st.http2(requestParam{
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1AddXff",
|
||||
})
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1AddXff2 tests that server appends X-Forwarded-For header
|
||||
|
@ -65,7 +68,7 @@ func TestH2H1AddXff2(t *testing.T) {
|
|||
})
|
||||
defer st.Close()
|
||||
|
||||
_, err := st.http2(requestParam{
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1AddXff2",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-for", "host"),
|
||||
|
@ -74,6 +77,9 @@ func TestH2H1AddXff2(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1StripXff tests that --strip-incoming-x-forwarded-for
|
||||
|
@ -86,7 +92,7 @@ func TestH2H1StripXff(t *testing.T) {
|
|||
})
|
||||
defer st.Close()
|
||||
|
||||
_, err := st.http2(requestParam{
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1StripXff1",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-for", "host"),
|
||||
|
@ -95,6 +101,9 @@ func TestH2H1StripXff(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1StripAddXff tests that --strip-incoming-x-forwarded-for and
|
||||
|
@ -113,7 +122,7 @@ func TestH2H1StripAddXff(t *testing.T) {
|
|||
})
|
||||
defer st.Close()
|
||||
|
||||
_, err := st.http2(requestParam{
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1StripAddXff",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-for", "host"),
|
||||
|
@ -122,6 +131,9 @@ func TestH2H1StripAddXff(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1AddForwardedObfuscated tests that server generates
|
||||
|
@ -471,7 +483,7 @@ func TestH2H1ChunkedRequestBody(t *testing.T) {
|
|||
})
|
||||
defer st.Close()
|
||||
|
||||
_, err := st.http2(requestParam{
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1ChunkedRequestBody",
|
||||
method: "POST",
|
||||
body: []byte("foo"),
|
||||
|
@ -479,6 +491,9 @@ func TestH2H1ChunkedRequestBody(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1MultipleRequestCL tests that server rejects request with
|
||||
|
|
Loading…
Reference in New Issue