MCPcopy
hub / github.com/cloudflare/cloudflared / TestProxySingleOrigin

Function TestProxySingleOrigin

proxy/proxy_test.go:148–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestProxySingleOrigin(t *testing.T) {
149 log := zerolog.Nop()
150
151 ctx, cancel := context.WithCancel(t.Context())
152
153 flagSet := flag.NewFlagSet(t.Name(), flag.PanicOnError)
154 flagSet.Bool("hello-world", true, "")
155
156 cliCtx := cli.NewContext(cli.NewApp(), flagSet, nil)
157 err := cliCtx.Set("hello-world", "true")
158 require.NoError(t, err)
159
160 ingressRule, err := ingress.ParseIngressFromConfigAndCLI(&config.Configuration{}, cliCtx, &log)
161 require.NoError(t, err)
162
163 require.NoError(t, ingressRule.StartOrigins(&log, ctx.Done()))
164
165 originDialer := ingress.NewOriginDialer(ingress.OriginConfig{
166 DefaultDialer: testDefaultDialer,
167 TCPWriteTimeout: 1 * time.Second,
168 }, &log)
169
170 proxy := NewOriginProxy(ingressRule, originDialer, testTags, cfdflow.NewLimiter(0), &log)
171 t.Run("testProxyHTTP", testProxyHTTP(proxy))
172 t.Run("testProxyWebsocket", testProxyWebsocket(proxy))
173 t.Run("testProxySSE", testProxySSE(proxy))
174 cancel()
175}
176
177func testProxyHTTP(proxy connection.OriginProxy) func(t *testing.T) {
178 return func(t *testing.T) {

Callers

nothing calls this directly

Calls 12

NewOriginDialerFunction · 0.92
NewOriginProxyFunction · 0.85
testProxyHTTPFunction · 0.85
testProxyWebsocketFunction · 0.85
testProxySSEFunction · 0.85
BoolMethod · 0.80
StartOriginsMethod · 0.80
ContextMethod · 0.65
NameMethod · 0.65
RunMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected