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

Function TestGetProvisionerKey

enterprise/coderd/provisionerkeys_test.go:138–268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestGetProvisionerKey(t *testing.T) {
139 t.Parallel()
140
141 tests := []struct {
142 name string
143 useFakeKey bool
144 fakeKey string
145 success bool
146 expectedErr string
147 }{
148 {
149 name: "ok",
150 success: true,
151 expectedErr: "",
152 },
153 {
154 name: "using unknown key",
155 useFakeKey: true,
156 fakeKey: "unknownKey",
157 success: false,
158 expectedErr: "provisioner daemon key invalid",
159 },
160 {
161 name: "no key provided",
162 useFakeKey: true,
163 fakeKey: "",
164 success: false,
165 expectedErr: "provisioner daemon key required",
166 },
167 }
168
169 for _, tt := range tests {
170 t.Run(tt.name, func(t *testing.T) {
171 t.Parallel()
172
173 ctx := testutil.Context(t, testutil.WaitShort)
174 dv := coderdtest.DeploymentValues(t)
175 client, owner := coderdenttest.New(t, &coderdenttest.Options{
176 Options: &coderdtest.Options{
177 DeploymentValues: dv,
178 },
179 LicenseOptions: &coderdenttest.LicenseOptions{
180 Features: license.Features{
181 codersdk.FeatureMultipleOrganizations: 1,
182 codersdk.FeatureExternalProvisionerDaemons: 1,
183 },
184 },
185 })
186
187 //nolint:gocritic // ignore This client is operating as the owner user, which has unrestricted permissions
188 key, err := client.CreateProvisionerKey(ctx, owner.OrganizationID, codersdk.CreateProvisionerKeyRequest{
189 Name: "my-test-key",
190 Tags: map[string]string{"key1": "value1", "key2": "value2"},
191 })
192 require.NoError(t, err)
193
194 pk := key.Key
195 if tt.useFakeKey {

Callers

nothing calls this directly

Calls 9

ContextFunction · 0.92
DeploymentValuesFunction · 0.92
NewFunction · 0.92
CreateProvisionerKeyMethod · 0.80
GetProvisionerKeyMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.45
EmptyMethod · 0.45
SessionTokenMethod · 0.45

Tested by

no test coverage detected