Add set-password command with admin functionality and CLI documentation#307
Open
duanemay wants to merge 2 commits into
Open
Add set-password command with admin functionality and CLI documentation#307duanemay wants to merge 2 commits into
set-password command with admin functionality and CLI documentation#307duanemay wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an administrative set-password command to the uaa CLI and documents it in the command reference and UAAC migration guide.
Changes:
- Introduces
uaa set-password USERNAMEwith optional interactive password prompt, plus--origin/--zonesupport. - Adds Ginkgo/Gomega coverage for success paths and common error/validation scenarios.
- Updates CLI docs to include
set-passwordand references it from the UAAC migration table.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/migrating-from-uaac.md | Updates UAAC→UAA command mapping table to reference set-password (and currently also references unlock-user). |
| docs/commands/set-password.md | New documentation page for uaa set-password (usage, flags, examples, auth requirements). |
| docs/commands.md | Adds set-password to the command reference index. |
| cmd/set_password.go | Implements set-password command, lookup-by-username then PUT to /Users/{id}/password. |
| cmd/set_password_test.go | Adds integration-style command tests using ghttp server assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+19
to
+21
| if user.Meta == nil { | ||
| return errors.New("The user did not have expected metadata version.") | ||
| } |
| // setPasswordByID makes a PUT request to /Users/{id}/password with {"password": "newpassword"} | ||
| func setPasswordByID(api *uaa.API, userID, password, zoneID string) error { | ||
| path := fmt.Sprintf("/Users/%s/password", userID) | ||
| data := fmt.Sprintf(`{"password": "%s"}`, password) |
Comment on lines
+75
to
+84
| // Get password from flag or prompt if not provided | ||
| if userPassword == "" { | ||
| secret := cli.InteractiveSecret{Prompt: "New password"} | ||
| var err error | ||
| userPassword, err = secret.Get() | ||
| if err != nil { | ||
| cli.NotifyErrorsWithRetry(err, log, GetSavedConfig()) | ||
| return | ||
| } | ||
| } |
Comment on lines
+42
to
+49
| _, _, status, err := api.Curl(path, "PUT", data, headers) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if status >= 400 { | ||
| return fmt.Errorf("set password failed with status %d", status) | ||
| } |
Comment on lines
+19
to
+21
| if user.Meta == nil { | ||
| return errors.New("The user did not have expected metadata version.") | ||
| } |
Comment on lines
+34
to
+36
| path := fmt.Sprintf("/Users/%s/password", userID) | ||
| data := fmt.Sprintf(`{"password": "%s"}`, password) | ||
|
|
Comment on lines
+42
to
+49
| _, _, status, err := api.Curl(path, "PUT", data, headers) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if status >= 400 { | ||
| return fmt.Errorf("set password failed with status %d", status) | ||
| } |
| Expect(session).Should(Exit(1)) | ||
| }) | ||
|
|
||
| It("displays help when no password provided (interactive mode skipped in tests)", func() { |
Remove the unused Meta.Version check that misleadingly implied optimistic locking; set-password only needs the user ID. JSON-encode the password with encoding/json instead of raw fmt.Sprintf to avoid producing invalid JSON when the password contains quotes, backslashes, or newlines. Surface the UAA response body in errors (both the password PUT and the SCIM lookup) instead of a status-only message, and give an actionable error when the interactive password prompt fails on non-TTY stdin. Also fix a dead link to the not-yet-merged unlock-user docs in the UAAC migration guide. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
No description provided.