|
7 | 7 | "github.com/stretchr/testify/require"
|
8 | 8 |
|
9 | 9 | "github.com/coder/coder/v2/cli/clitest"
|
| 10 | + "github.com/coder/coder/v2/coderd/coderdtest" |
10 | 11 | "github.com/coder/coder/v2/codersdk"
|
11 | 12 | "github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
|
12 | 13 | "github.com/coder/coder/v2/enterprise/coderd/license"
|
@@ -37,20 +38,44 @@ func TestProvisionerDaemon_PSK(t *testing.T) {
|
37 | 38 |
|
38 | 39 | func TestProvisionerDaemon_SessionToken(t *testing.T) {
|
39 | 40 | t.Parallel()
|
| 41 | + t.Run("ScopeUser", func(t *testing.T) { |
| 42 | + t.Parallel() |
| 43 | + client, admin := coderdenttest.New(t, &coderdenttest.Options{ |
| 44 | + ProvisionerDaemonPSK: "provisionersftw", |
| 45 | + LicenseOptions: &coderdenttest.LicenseOptions{ |
| 46 | + Features: license.Features{ |
| 47 | + codersdk.FeatureExternalProvisionerDaemons: 1, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }) |
| 51 | + anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID) |
| 52 | + inv, conf := newCLI(t, "provisionerd", "start", "--tag", "scope=user") |
| 53 | + clitest.SetupConfig(t, anotherClient, conf) |
| 54 | + pty := ptytest.New(t).Attach(inv) |
| 55 | + ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong) |
| 56 | + defer cancel() |
| 57 | + clitest.Start(t, inv) |
| 58 | + pty.ExpectMatchContext(ctx, "starting provisioner daemon") |
| 59 | + }) |
40 | 60 |
|
41 |
| - client, _ := coderdenttest.New(t, &coderdenttest.Options{ |
42 |
| - ProvisionerDaemonPSK: "provisionersftw", |
43 |
| - LicenseOptions: &coderdenttest.LicenseOptions{ |
44 |
| - Features: license.Features{ |
45 |
| - codersdk.FeatureExternalProvisionerDaemons: 1, |
| 61 | + t.Run("ScopeOrg", func(t *testing.T) { |
| 62 | + t.Parallel() |
| 63 | + client, admin := coderdenttest.New(t, &coderdenttest.Options{ |
| 64 | + ProvisionerDaemonPSK: "provisionersftw", |
| 65 | + LicenseOptions: &coderdenttest.LicenseOptions{ |
| 66 | + Features: license.Features{ |
| 67 | + codersdk.FeatureExternalProvisionerDaemons: 1, |
| 68 | + }, |
46 | 69 | },
|
47 |
| - }, |
| 70 | + }) |
| 71 | + anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID) |
| 72 | + inv, conf := newCLI(t, "provisionerd", "start", "--tag", "scope=organization") |
| 73 | + clitest.SetupConfig(t, anotherClient, conf) |
| 74 | + pty := ptytest.New(t).Attach(inv) |
| 75 | + ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong) |
| 76 | + defer cancel() |
| 77 | + clitest.Start(t, inv) |
| 78 | + pty.ExpectMatchContext(ctx, "starting provisioner daemon") |
48 | 79 | })
|
49 |
| - inv, conf := newCLI(t, "provisionerd", "start") |
50 |
| - clitest.SetupConfig(t, client, conf) |
51 |
| - pty := ptytest.New(t).Attach(inv) |
52 |
| - ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong) |
53 |
| - defer cancel() |
54 |
| - clitest.Start(t, inv) |
55 |
| - pty.ExpectMatchContext(ctx, "starting provisioner daemon") |
| 80 | + |
56 | 81 | }
|
0 commit comments