-
Notifications
You must be signed in to change notification settings - Fork 943
feat(coderd): add endpoint to fetch provisioner key details #15505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
995a046
2ca6c91
c67d322
911a47d
1a019bb
c629f07
54437f2
8eeffb1
960084d
4a38977
c89bcd8
0af9e8e
4680484
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,38 @@ | |
err = orgAdmin.DeleteProvisionerKey(ctx, owner.OrganizationID, codersdk.ProvisionerKeyNamePSK) | ||
require.ErrorContains(t, err, "reserved") | ||
} | ||
|
||
func TestProvisionerKey(t *testing.T) { | ||
t.Parallel() | ||
t.Run("GetKey", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) | ||
t.Cleanup(cancel) | ||
dv := coderdtest.DeploymentValues(t) | ||
client, owner := coderdenttest.New(t, &coderdenttest.Options{ | ||
Options: &coderdtest.Options{ | ||
DeploymentValues: dv, | ||
}, | ||
LicenseOptions: &coderdenttest.LicenseOptions{ | ||
Features: license.Features{ | ||
codersdk.FeatureMultipleOrganizations: 1, | ||
}, | ||
}, | ||
}) | ||
|
||
key, err := client.CreateProvisionerKey(ctx, owner.OrganizationID, codersdk.CreateProvisionerKeyRequest{ | ||
Name: "my-test-key", | ||
Tags: map[string]string{"key1": "value1", "key2": "value2"}, | ||
}) | ||
require.NoError(t, err) | ||
|
||
_, err = client.GetProvisionerKey(ctx, key.Key) | ||
require.NoError(t, err) | ||
// require.Equal(t, tags, codersdk.ProvisionerKeyTags{"key1": "value1", "key2": "value2"}) | ||
|
||
erroneousPK, err := client.GetProvisionerKey(ctx, "abcdefghijklmnopqrstuvwxyz01234567890123456") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: you're testing multiple scenarios in one test; it's closer to our style to use table tests in this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest testing following scenarios:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some tests as discussed and changed to table tests - should give more coverage on the different cases. |
||
require.Empty(t, erroneousPK) | ||
require.Error(t, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
}) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.