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

Function appServer

coderd/workspaceapps/apptest/setup.go:324–363  ·  view source on GitHub ↗

nolint:revive

(t *testing.T, headers http.Header, isHTTPS bool, handler http.Handler)

Source from the content-addressed store, hash-verified

322
323//nolint:revive
324func appServer(t *testing.T, headers http.Header, isHTTPS bool, handler http.Handler) uint16 {
325 defaultHandler := http.HandlerFunc(
326 func(w http.ResponseWriter, r *http.Request) {
327 _, err := r.Cookie(codersdk.SessionTokenCookie)
328 assert.ErrorIs(t, err, http.ErrNoCookie)
329 w.Header().Set("X-Forwarded-For", r.Header.Get("X-Forwarded-For"))
330 w.Header().Set("X-Got-Host", r.Host)
331 for name, values := range headers {
332 for _, value := range values {
333 w.Header().Add(name, value)
334 }
335 }
336 w.WriteHeader(http.StatusOK)
337 _, _ = w.Write([]byte(proxyTestAppBody))
338 },
339 )
340
341 if handler == nil {
342 handler = defaultHandler
343 }
344
345 server := httptest.NewUnstartedServer(handler)
346
347 server.Config.ReadHeaderTimeout = time.Minute
348 if isHTTPS {
349 server.StartTLS()
350 } else {
351 server.Start()
352 }
353 t.Cleanup(func() {
354 server.Close()
355 })
356
357 _, portStr, err := net.SplitHostPort(server.Listener.Addr().String())
358 require.NoError(t, err)
359 port, err := strconv.ParseUint(portStr, 10, 16)
360 require.NoError(t, err)
361
362 return uint16(port)
363}
364
365//nolint:revive
366func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.UUID, me codersdk.User, port uint16, serveHTTPS bool, workspaceMutators ...func(*codersdk.CreateWorkspaceRequest)) (codersdk.Workspace, codersdk.WorkspaceAgent) {

Callers 2

RunFunction · 0.85

Calls 11

SetMethod · 0.65
GetMethod · 0.65
AddMethod · 0.65
WriteMethod · 0.65
StartMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
HeaderMethod · 0.45
WriteHeaderMethod · 0.45
StringMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected