(t *testing.T)
| 2487 | } |
| 2488 | |
| 2489 | func 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 | |
| 2524 | type runServerOpts struct { |
| 2525 | waitForSnapshot bool |
nothing calls this directly
no test coverage detected