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

Function TestBlockNonBrowser

enterprise/coderd/workspaceagents_test.go:44–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42)
43
44func TestBlockNonBrowser(t *testing.T) {
45 t.Parallel()
46 t.Run("Enabled", func(t *testing.T) {
47 t.Parallel()
48 client, user := coderdenttest.New(t, &coderdenttest.Options{
49 BrowserOnly: true,
50 Options: &coderdtest.Options{
51 IncludeProvisionerDaemon: true,
52 },
53 LicenseOptions: &coderdenttest.LicenseOptions{
54 Features: license.Features{
55 codersdk.FeatureBrowserOnly: 1,
56 },
57 },
58 })
59 r := setupWorkspaceAgent(t, client, user, 0)
60 ctx := testutil.Context(t, testutil.WaitShort)
61 //nolint:gocritic // Testing that even the owner gets blocked.
62 _, err := workspacesdk.New(client).DialAgent(ctx, r.sdkAgent.ID, nil)
63 var apiErr *codersdk.Error
64 require.ErrorAs(t, err, &apiErr)
65 require.Equal(t, http.StatusConflict, apiErr.StatusCode())
66 })
67 t.Run("Disabled", func(t *testing.T) {
68 t.Parallel()
69 client, user := coderdenttest.New(t, &coderdenttest.Options{
70 Options: &coderdtest.Options{
71 IncludeProvisionerDaemon: true,
72 },
73 LicenseOptions: &coderdenttest.LicenseOptions{
74 Features: license.Features{
75 codersdk.FeatureBrowserOnly: 0,
76 },
77 },
78 })
79 r := setupWorkspaceAgent(t, client, user, 0)
80 ctx := testutil.Context(t, testutil.WaitShort)
81 //nolint:gocritic // Testing RBAC is not the point of this test.
82 conn, err := workspacesdk.New(client).DialAgent(ctx, r.sdkAgent.ID, nil)
83 require.NoError(t, err)
84 _ = conn.Close()
85 })
86}
87
88func TestReinitializeAgent(t *testing.T) {
89 t.Parallel()

Callers

nothing calls this directly

Calls 9

StatusCodeMethod · 0.95
NewFunction · 0.92
ContextFunction · 0.92
NewFunction · 0.92
setupWorkspaceAgentFunction · 0.85
RunMethod · 0.65
DialAgentMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected