MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / TestHTTP2ConfigurationSet

Function TestHTTP2ConfigurationSet

connection/http2_test.go:61–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestHTTP2ConfigurationSet(t *testing.T) {
62 http2Conn, edgeConn := newTestHTTP2Connection()
63
64 ctx, cancel := context.WithCancel(t.Context())
65 var wg sync.WaitGroup
66 wg.Add(1)
67 go func() {
68 defer wg.Done()
69 _ = http2Conn.Serve(ctx)
70 }()
71
72 edgeHTTP2Conn, err := testTransport.NewClientConn(edgeConn)
73 require.NoError(t, err)
74
75 reqBody := []byte(`{
76"version": 2,
77"config": {"warp-routing": {"enabled": true}, "originRequest" : {"connectTimeout": 10}, "ingress" : [ {"hostname": "test", "service": "https://localhost:8000" } , {"service": "http_status:404"} ]}}
78`)
79 reader := bytes.NewReader(reqBody)
80 req, err := http.NewRequestWithContext(ctx, http.MethodPut, "http://localhost:8080/ok", reader)
81 require.NoError(t, err)
82 req.Header.Set(InternalUpgradeHeader, ConfigurationUpdate)
83
84 resp, err := edgeHTTP2Conn.RoundTrip(req)
85 require.NoError(t, err)
86 require.Equal(t, http.StatusOK, resp.StatusCode)
87 bdy, err := io.ReadAll(resp.Body)
88 defer resp.Body.Close()
89 require.NoError(t, err)
90 assert.Equal(t, `{"lastAppliedVersion":2,"err":null}`, string(bdy))
91 cancel()
92 wg.Wait()
93}
94
95func TestServeHTTP(t *testing.T) {
96 tests := []testRequest{

Callers

nothing calls this directly

Calls 9

newTestHTTP2ConnectionFunction · 0.85
WaitMethod · 0.80
ContextMethod · 0.65
AddMethod · 0.65
ServeMethod · 0.65
EqualMethod · 0.65
CloseMethod · 0.65
SetMethod · 0.45
RoundTripMethod · 0.45

Tested by

no test coverage detected