mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
fix: disable relay if built-in DERP is disabled (#12654)
Fixes https://github.com/coder/coder/issues/12493
This commit is contained in:
@ -35,6 +35,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/goleak"
|
||||
"gopkg.in/yaml.v3"
|
||||
"tailscale.com/derp/derphttp"
|
||||
"tailscale.com/types/key"
|
||||
|
||||
"cdr.dev/slog/sloggers/slogtest"
|
||||
|
||||
@ -1830,3 +1832,32 @@ func TestServer_InvalidDERP(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
require.ErrorContains(t, err, "A valid DERP map is required for networking to work")
|
||||
}
|
||||
|
||||
func TestServer_DisabledDERP(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancelFunc()
|
||||
|
||||
// Try to start a server with the built-in DERP server disabled and an
|
||||
// external DERP map.
|
||||
inv, cfg := clitest.New(t,
|
||||
"server",
|
||||
"--in-memory",
|
||||
"--http-address", ":0",
|
||||
"--access-url", "http://example.com",
|
||||
"--derp-server-enable=false",
|
||||
"--derp-config-url", "https://controlplane.tailscale.com/derpmap/default",
|
||||
)
|
||||
clitest.Start(t, inv.WithContext(ctx))
|
||||
accessURL := waitAccessURL(t, cfg)
|
||||
derpURL, err := accessURL.Parse("/derp")
|
||||
require.NoError(t, err)
|
||||
|
||||
c, err := derphttp.NewClient(key.NewNode(), derpURL.String(), func(format string, args ...any) {})
|
||||
require.NoError(t, err)
|
||||
|
||||
// DERP should fail to connect
|
||||
err = c.Connect(ctx)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user