(t *testing.T)
| 42 | ) |
| 43 | |
| 44 | func 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 | |
| 88 | func TestReinitializeAgent(t *testing.T) { |
| 89 | t.Parallel() |
nothing calls this directly
no test coverage detected