feat: allow disabling stun addresses via env (#7066)

* feat: allow disabling stun addresses via env

Resolves #6791

* Specify a dummy access URL so the tunnel wouldn't start

* Document

---------

Co-authored-by: Kyle Carberry <kyle@carberry.com>
This commit is contained in:
Ammar Bandukwala
2023-04-17 17:20:26 +00:00
committed by GitHub
co-authored by Kyle Carberry
parent 25c1e45930
commit c6b2861493
6 changed files with 44 additions and 6 deletions
+25
View File
@@ -1491,6 +1491,31 @@ func TestServer(t *testing.T) {
w.RequireSuccess()
})
})
t.Run("DisableDERP", func(t *testing.T) {
t.Parallel()
// Make sure that $CODER_DERP_SERVER_STUN_ADDRESSES can be set to
// disable STUN.
inv, cfg := clitest.New(t,
"server",
"--in-memory",
"--http-address", ":0",
"--access-url", "https://example.com",
)
inv.Environ.Set("CODER_DERP_SERVER_STUN_ADDRESSES", "disable")
ptytest.New(t).Attach(inv)
clitest.Start(t, inv)
gotURL := waitAccessURL(t, cfg)
client := codersdk.New(gotURL)
ctx := testutil.Context(t, testutil.WaitMedium)
_ = coderdtest.CreateFirstUser(t, client)
gotConfig, err := client.DeploymentConfig(ctx)
require.NoError(t, err)
require.Len(t, gotConfig.Values.DERP.Server.STUNAddresses, 0)
})
}
func generateTLSCertificate(t testing.TB, commonName ...string) (certPath, keyPath string) {