MCPcopy Index your code
hub / github.com/coder/coder / TestServerTailnet_ReverseProxy_ProxyEnv

Function TestServerTailnet_ReverseProxy_ProxyEnv

coderd/tailnet_test.go:74–100  ·  view source on GitHub ↗

nolint:paralleltest // t.Setenv

(t *testing.T)

Source from the content-addressed store, hash-verified

72
73//nolint:paralleltest // t.Setenv
74func TestServerTailnet_ReverseProxy_ProxyEnv(t *testing.T) {
75 t.Setenv("HTTP_PROXY", "http://169.254.169.254:12345")
76
77 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
78 defer cancel()
79
80 agents, serverTailnet := setupServerTailnetAgent(t, 1)
81 a := agents[0]
82
83 u, err := url.Parse(fmt.Sprintf("http://127.0.0.1:%d", workspacesdk.AgentHTTPAPIServerPort))
84 require.NoError(t, err)
85
86 rp := serverTailnet.ReverseProxy(u, u, a.id, appurl.ApplicationURL{}, "")
87
88 rw := httptest.NewRecorder()
89 req := httptest.NewRequest(
90 http.MethodGet,
91 u.String(),
92 nil,
93 ).WithContext(ctx)
94
95 rp.ServeHTTP(rw, req)
96 res := rw.Result()
97 defer res.Body.Close()
98
99 assert.Equal(t, http.StatusOK, res.StatusCode)
100}
101
102func TestServerTailnet_ReverseProxy(t *testing.T) {
103 t.Parallel()

Callers

nothing calls this directly

Calls 10

setupServerTailnetAgentFunction · 0.85
SetenvMethod · 0.80
WithContextMethod · 0.80
ParseMethod · 0.65
ReverseProxyMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45
ServeHTTPMethod · 0.45
ResultMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected