Skip to content

Add set-password command with admin functionality and CLI documentation#307

Open
duanemay wants to merge 1 commit into
masterfrom
Add-set-password
Open

Add set-password command with admin functionality and CLI documentation#307
duanemay wants to merge 1 commit into
masterfrom
Add-set-password

Conversation

@duanemay

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 22:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 USERNAME with optional interactive password prompt, plus --origin / --zone support.
  • Adds Ginkgo/Gomega coverage for success paths and common error/validation scenarios.
  • Updates CLI docs to include set-password and 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 thread cmd/set_password.go
Comment on lines +19 to +21
if user.Meta == nil {
return errors.New("The user did not have expected metadata version.")
}
Comment thread cmd/set_password.go
// 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 thread cmd/set_password.go
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 thread cmd/set_password.go
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants