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

Function TestServer_DisabledDERP_ExternalMap

cli/server_test.go:2489–2522  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2487}
2488
2489func TestServer_DisabledDERP_ExternalMap(t *testing.T) {
2490 t.Parallel()
2491
2492 derpMap, _ := tailnettest.RunDERPAndSTUN(t)
2493 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2494 httpapi.Write(context.Background(), w, http.StatusOK, derpMap)
2495 }))
2496 t.Cleanup(srv.Close)
2497
2498 ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitShort)
2499 defer cancelFunc()
2500
2501 // Try to start a server with the built-in DERP server disabled and an
2502 // external DERP map.
2503 inv, cfg := clitest.New(t,
2504 "server",
2505 dbArg(t),
2506 "--http-address", ":0",
2507 "--access-url", "http://example.com",
2508 "--derp-server-enable=false",
2509 "--derp-config-url", srv.URL,
2510 )
2511 clitest.Start(t, inv.WithContext(ctx))
2512 accessURL := waitAccessURL(t, cfg)
2513 derpURL, err := accessURL.Parse("/derp")
2514 require.NoError(t, err)
2515
2516 c, err := derphttp.NewClient(key.NewNode(), derpURL.String(), func(format string, args ...any) {})
2517 require.NoError(t, err)
2518
2519 // DERP should fail to connect
2520 err = c.Connect(ctx)
2521 require.Error(t, err)
2522}
2523
2524type runServerOpts struct {
2525 waitForSnapshot bool

Callers

nothing calls this directly

Calls 12

RunDERPAndSTUNFunction · 0.92
WriteFunction · 0.92
NewFunction · 0.92
StartFunction · 0.92
WithContextMethod · 0.80
dbArgFunction · 0.70
waitAccessURLFunction · 0.70
CleanupMethod · 0.65
ParseMethod · 0.65
ConnectMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected