(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestProvisionerDaemon_PSK(t *testing.T) { |
| 28 | t.Parallel() |
| 29 | |
| 30 | t.Run("OK", func(t *testing.T) { |
| 31 | t.Parallel() |
| 32 | |
| 33 | client, _ := coderdenttest.New(t, &coderdenttest.Options{ |
| 34 | ProvisionerDaemonPSK: "provisionersftw", |
| 35 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 36 | Features: license.Features{ |
| 37 | codersdk.FeatureExternalProvisionerDaemons: 1, |
| 38 | codersdk.FeatureMultipleOrganizations: 1, |
| 39 | }, |
| 40 | }, |
| 41 | }) |
| 42 | inv, conf := newCLI(t, "provisionerd", "start", "--psk=provisionersftw", "--name=matt-daemon") |
| 43 | err := conf.URL().Write(client.URL.String()) |
| 44 | require.NoError(t, err) |
| 45 | pty := ptytest.New(t).Attach(inv) |
| 46 | ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong) |
| 47 | defer cancel() |
| 48 | clitest.Start(t, inv) |
| 49 | pty.ExpectNoMatchBefore(ctx, "check entitlement", "starting provisioner daemon") |
| 50 | pty.ExpectMatchContext(ctx, "matt-daemon") |
| 51 | |
| 52 | var daemons []codersdk.ProvisionerDaemon |
| 53 | require.Eventually(t, func() bool { |
| 54 | daemons, err = client.ProvisionerDaemons(ctx) |
| 55 | if err != nil { |
| 56 | return false |
| 57 | } |
| 58 | return len(daemons) == 1 |
| 59 | }, testutil.WaitShort, testutil.IntervalSlow) |
| 60 | require.Equal(t, "matt-daemon", daemons[0].Name) |
| 61 | require.Equal(t, provisionersdk.ScopeOrganization, daemons[0].Tags[provisionersdk.TagScope]) |
| 62 | require.Equal(t, buildinfo.Version(), daemons[0].Version) |
| 63 | require.Equal(t, proto.CurrentVersion.String(), daemons[0].APIVersion) |
| 64 | }) |
| 65 | |
| 66 | t.Run("AnotherOrgByNameWithUser", func(t *testing.T) { |
| 67 | t.Parallel() |
| 68 | client, _ := coderdenttest.New(t, &coderdenttest.Options{ |
| 69 | ProvisionerDaemonPSK: "provisionersftw", |
| 70 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 71 | Features: license.Features{ |
| 72 | codersdk.FeatureExternalProvisionerDaemons: 1, |
| 73 | codersdk.FeatureMultipleOrganizations: 1, |
| 74 | }, |
| 75 | }, |
| 76 | }) |
| 77 | anotherOrg := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{}) |
| 78 | anotherClient, _ := coderdtest.CreateAnotherUser(t, client, anotherOrg.ID, rbac.RoleTemplateAdmin()) |
| 79 | inv, conf := newCLI(t, "provisionerd", "start", "--name", "org-daemon", "--org", anotherOrg.Name) |
| 80 | clitest.SetupConfig(t, anotherClient, conf) |
| 81 | pty := ptytest.New(t).Attach(inv) |
| 82 | ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong) |
| 83 | defer cancel() |
| 84 | clitest.Start(t, inv) |
nothing calls this directly
no test coverage detected