Skip to content

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

Open
duanemay wants to merge 2 commits into
masterfrom
Add-set-password
Open

Add set-password command with admin functionality and CLI documentation#307
duanemay wants to merge 2 commits 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.

Comment thread docs/migrating-from-uaac.md Outdated
Comment thread cmd/set_password.go Outdated
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 Outdated
// 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 Outdated
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)
}

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment thread cmd/set_password.go Outdated
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
Comment on lines +34 to +36
path := fmt.Sprintf("/Users/%s/password", userID)
data := fmt.Sprintf(`{"password": "%s"}`, password)

Comment thread cmd/set_password.go Outdated
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 thread cmd/set_password_test.go Outdated
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>
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