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

Function TestProvisionerDaemon_PSK

enterprise/cli/provisionerdaemonstart_test.go:27–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func 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)

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
NewFunction · 0.92
StartFunction · 0.92
VersionFunction · 0.92
CreateOrganizationFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleTemplateAdminFunction · 0.92
SetupConfigFunction · 0.92
newCLIFunction · 0.85
ExpectMatchContextMethod · 0.80
WithContextMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected