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

Function TestProxyRegisterDeregister

enterprise/coderd/workspaceproxy_test.go:278–667  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestProxyRegisterDeregister(t *testing.T) {
279 t.Parallel()
280
281 setupWithDeploymentValues := func(t *testing.T, dv *codersdk.DeploymentValues) (*codersdk.Client, database.Store) {
282 db, pubsub := dbtestutil.NewDB(t)
283 client, _ := coderdenttest.New(t, &coderdenttest.Options{
284 Options: &coderdtest.Options{
285 DeploymentValues: dv,
286 Database: db,
287 Pubsub: pubsub,
288 IncludeProvisionerDaemon: true,
289 },
290 ReplicaSyncUpdateInterval: time.Minute,
291 LicenseOptions: &coderdenttest.LicenseOptions{
292 Features: license.Features{
293 codersdk.FeatureWorkspaceProxy: 1,
294 },
295 },
296 })
297
298 return client, db
299 }
300
301 setup := func(t *testing.T) (*codersdk.Client, database.Store) {
302 dv := coderdtest.DeploymentValues(t)
303 return setupWithDeploymentValues(t, dv)
304 }
305
306 t.Run("OK", func(t *testing.T) {
307 t.Parallel()
308
309 client, db := setup(t)
310
311 ctx := testutil.Context(t, testutil.WaitLong)
312 const (
313 proxyName = "hello"
314 proxyDisplayName = "Hello World"
315 proxyIcon = "/emojis/flag.png"
316 )
317 createRes, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
318 Name: proxyName,
319 DisplayName: proxyDisplayName,
320 Icon: proxyIcon,
321 })
322 require.NoError(t, err)
323
324 proxyClient := wsproxysdk.New(client.URL, createRes.ProxyToken)
325
326 // Register
327 req := wsproxysdk.RegisterWorkspaceProxyRequest{
328 AccessURL: "https://proxy.coder.test",
329 WildcardHostname: "*.proxy.coder.test",
330 DerpEnabled: true,
331 ReplicaID: uuid.New(),
332 ReplicaHostname: "mars",
333 ReplicaError: "",
334 ReplicaRelayAddress: "http://127.0.0.1:8080",
335 Version: buildinfo.Version(),

Callers

nothing calls this directly

Calls 15

StatusCodeMethod · 0.95
NewDBFunction · 0.92
NewFunction · 0.92
DeploymentValuesFunction · 0.92
ContextFunction · 0.92
NewFunction · 0.92
VersionFunction · 0.92
CreateWorkspaceProxyMethod · 0.80
NotEmptyMethod · 0.80
WorkspaceProxyByIDMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected