Add set-password command with admin functionality and CLI documentation#307
Open
duanemay wants to merge 1 commit into
Open
Add set-password command with admin functionality and CLI documentation#307duanemay wants to merge 1 commit into
set-password command with admin functionality and CLI documentation#307duanemay wants to merge 1 commit 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.
| | `uaac user ids [username\|id...]` | *(no equivalent)* | Use `uaa get-user USERNAME` for individual lookups | | ||
| | `uaac user unlock [name]` | *(no equivalent)* | Use `uaa curl /Users/USER_ID/status -X PATCH -d '{"locked":false}'` | | ||
| | `uaac password set [name]` | *(no equivalent)* | Use `uaa curl /Users/USER_ID/password -X PUT -d '{"password":"NEW"}'` | | ||
| | `uaac user unlock [name]` | [`uaa unlock-user USERNAME`](commands/unlock-user.md) | | |
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) | ||
| } |
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.