(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func 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 { |
nothing calls this directly
no test coverage detected