(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestProvisionerKeys(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | |
| 23 | t.Run("CRUD", func(t *testing.T) { |
| 24 | t.Parallel() |
| 25 | |
| 26 | client, owner := coderdenttest.New(t, &coderdenttest.Options{ |
| 27 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 28 | Features: license.Features{ |
| 29 | codersdk.FeatureExternalProvisionerDaemons: 1, |
| 30 | }, |
| 31 | }, |
| 32 | }) |
| 33 | orgAdminClient, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.ScopedRoleOrgAdmin(owner.OrganizationID)) |
| 34 | |
| 35 | name := "dont-TEST-me" |
| 36 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 37 | inv, conf := newCLI( |
| 38 | t, |
| 39 | "provisioner", "keys", "create", name, "--tag", "foo=bar", "--tag", "my=way", |
| 40 | ) |
| 41 | |
| 42 | pty := ptytest.New(t) |
| 43 | inv.Stdout = pty.Output() |
| 44 | clitest.SetupConfig(t, orgAdminClient, conf) |
| 45 | |
| 46 | err := inv.WithContext(ctx).Run() |
| 47 | require.NoError(t, err) |
| 48 | |
| 49 | line := pty.ReadLine(ctx) |
| 50 | require.Contains(t, line, "Successfully created provisioner key") |
| 51 | require.Contains(t, line, strings.ToLower(name)) |
| 52 | // empty line |
| 53 | _ = pty.ReadLine(ctx) |
| 54 | key := pty.ReadLine(ctx) |
| 55 | require.NotEmpty(t, key) |
| 56 | require.NoError(t, provisionerkey.Validate(key)) |
| 57 | |
| 58 | inv, conf = newCLI( |
| 59 | t, |
| 60 | "provisioner", "keys", "ls", |
| 61 | ) |
| 62 | pty = ptytest.New(t) |
| 63 | inv.Stdout = pty.Output() |
| 64 | clitest.SetupConfig(t, orgAdminClient, conf) |
| 65 | |
| 66 | err = inv.WithContext(ctx).Run() |
| 67 | require.NoError(t, err) |
| 68 | line = pty.ReadLine(ctx) |
| 69 | require.Contains(t, line, "NAME") |
| 70 | require.Contains(t, line, "CREATED AT") |
| 71 | require.Contains(t, line, "TAGS") |
| 72 | line = pty.ReadLine(ctx) |
| 73 | require.Contains(t, line, strings.ToLower(name)) |
| 74 | require.Contains(t, line, "foo=bar my=way") |
| 75 | |
| 76 | inv, conf = newCLI( |
| 77 | t, |
nothing calls this directly
no test coverage detected