integration: Add http3 affinity cookie test

This commit is contained in:
Tatsuhiro Tsujikawa 2022-11-20 16:31:24 +09:00
parent 5b0cbb4892
commit 5e1b1a0883
1 changed files with 30 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"crypto/rand"
"io"
"net/http"
"regexp"
"testing"
"golang.org/x/net/http2/hpack"
@ -216,3 +217,32 @@ func TestH3H1HTTPSRedirect(t *testing.T) {
t.Errorf("status = %v; want %v", got, want)
}
}
// TestH3H1AffinityCookieTLS tests that affinity cookie is sent back
// in https.
func TestH3H1AffinityCookieTLS(t *testing.T) {
opts := options{
args: []string{"--affinity-cookie"},
quic: true,
}
st := newServerTester(t, opts)
defer st.Close()
res, err := st.http3(requestParam{
name: "TestH3H1AffinityCookieTLS",
scheme: "https",
})
if err != nil {
t.Fatalf("Error st.http3() = %v", err)
}
if got, want := res.status, 200; got != want {
t.Errorf("status = %v; want %v", got, want)
}
const pattern = `affinity=[0-9a-f]{8}; Path=/foo/bar; Secure`
validCookie := regexp.MustCompile(pattern)
if got := res.header.Get("Set-Cookie"); !validCookie.MatchString(got) {
t.Errorf("Set-Cookie: %v; want pattern %v", got, pattern)
}
}