Repository navigation
feat!: client create result, rename through Update, and in-place Reregister - #153
Merged
Merged
Conversation
…e keys in place
Clients.Create decoded erchef's POST /clients answer into an APIClient,
but under API v1 erchef sends only {"uri", "chef_key"}
(oc_chef_wm_base:create_from_json, oc_chef_wm_key_base:finalize_create_body),
so Name and Validator came back empty and the uri was lost. It now returns
a ClientCreateResult{URI, ChefKey}, like Users.Create's UserCreateResult.
ChefKey gains the key's URI, which erchef embeds, and moves to keys.go;
APIClient.ChefKey, which only carried this, is gone.
Clients.Update and Users.Update took the path from the body's name, so they
could not rename. erchef renames when a PUT body names a different object
and answers 201 with a Location (oc_chef_wm_base:update_from_json,
handle_rename). Both now take the current name for the path; the body
carries the possibly new one, as KeyScope.Update already does. A client PUT
echoes the validated body, so Clients.Update still returns the client.
Clients.Reregister deleted the default key and created a new one: a failure
in between left the client keyless, and the new key never expired whatever
the old one's date. It now sends one PUT .../keys/default with create_key,
which erchef regenerates in place, keeping the expiration
(oc_chef_wm_named_key:from_json, finalize_update_body). A client with no
default key (404) still gets one created.
cinc-server-ng v0.22.0 stores a renaming PUT under the old name, so the new
clients/rename and users/rename integration cases are gaps there.
BREAKING CHANGE: Clients.Create returns *ClientCreateResult instead of
*APIClient; APIClient.ChefKey is removed; Clients.Update(ctx, cl) becomes
Clients.Update(ctx, name, cl); Users.Update(ctx, u) becomes
Users.Update(ctx, name, u).
Signed-off-by: Tim Smith <tsmith84@proton.me>
| if err != nil { | ||
| t.Fatalf("Reregister: %v", err) | ||
| } | ||
| if key.PrivateKey == "" || key.PrivateKey == created.ChefKey.PrivateKey { |
Both are about cinc-server-ng PUT replies, and the new position does not collide with other additions to the gaps list. Signed-off-by: Tim Smith <tsmith84@proton.me>
…e test Against CINC Server 15.10.125 a client rename succeeds (201, the old name 404s), but the renamed client lists no keys and neither name authenticates, so the rename case's check that the original key still works failed there. Clients.Update and the README now say so, and the case gives the renamed client a key with Reregister, which creates a missing default key, then signs with it. The case passes on erchef. Signed-off-by: Tim Smith <tsmith84@proton.me>
Collaborator
Author
|
Ran the suite against CINC Server 15.10.125 (erchef). Everything passed except |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clients.Createresult. erchef answersPOST /clientswith{"uri", "chef_key": {name, public_key, expiration_date, uri, private_key?}}(oc_chef_wm_base.erl:1080,oc_chef_wm_key_base.erl:92-115). So the*APIClientresult had an emptyNameandValidatorand lost the URI. It now returnsClientCreateResult{URI, ChefKey}, the same shape asUserCreateResult.ChefKeygainsURIand moves tokeys.go, andAPIClient.ChefKeyis removed.Rename through
Update.Clients.UpdateandUsers.Updateused the body's name as the path, so they couldn't rename, although erchef renames on a PUT whose body name differs from the path (201 with Location). Both are nowUpdate(ctx, name, obj), asKeyScope.Updatealready is:nameis refused.Groups can be renamed the same way (
oc_chef_group.erl:145) but are left as they are. Orgs can't be renamed (oc_chef_organization.erl:62).Clients.Reregisterin place. It deleted thedefaultkey and then created a new one. A failed create left the client keyless, and any expiration was reset toinfinity. erchef regenerates a key in place:PUT .../keys/default {"create_key": true}returns the new pair and keeps the expiration (oc_chef_wm_named_key.erl:123-145), the same call pedant uses (platform.rb:234).Reregisternow sends that single PUT. It falls back to creating the key only when there is none (404). A client still can't reregister itself, because erchef answers 403 for the key the request is signed with; this was true before too and is now documented.cinc-server-ng answers a renaming PUT with 200 and stores the new body under the old name.
clients/renameandusers/renameare listed in itsGaps, and AGENTS.md records the difference.Breaking:
Clients.Createreturns*ClientCreateResult, andAPIClient.ChefKeyis removed.Clients.Update(ctx, name, cl)andUsers.Update(ctx, name, u).Test plan
Reregister's in-place PUT, the keyless fallback, a missing client, and a 403 that creates nothingclients/renameandusers/rename(gaps on cinc-server-ng)clients/reregister-keeps-client-usable: signs with the new key, the old key getsErrUnauthorized, and onlydefaultremainsclients/reregister-keylessgo test ./... -race -count=2,cd integration && go test ./..., golangci-lint in both modules