Add unlock-user command to unlock user accounts#306
Open
duanemay wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new uaa unlock-user CLI command (plus docs) to unlock user accounts by username, complementing existing user-management commands (activate/deactivate/delete/etc.).
Changes:
- Introduces
unlock-usercommand implementation that PATCHes/Users/{id}/statuswith{"locked": false}. - Adds Ginkgo/Gomega integration tests covering success paths, flags (
--verbose,--origin,--zone), and error/validation cases. - Updates command reference docs to include the new command and its dedicated page.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/commands/unlock-user.md | Adds documentation for the new unlock-user command (usage, flags, examples). |
| docs/commands.md | Adds unlock-user to the “Managing Users” command index. |
| cmd/unlock_user.go | Implements the unlock-user cobra command and the PATCH call to unlock a user. |
| cmd/unlock_user_test.go | Adds integration tests for unlock-user behavior and validations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+23
to
+40
| err = unlockUserByID(api, user.ID, zoneID) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| log.Infof("Account for user %v successfully unlocked.", utils.Emphasize(user.Username)) | ||
| return nil | ||
| } | ||
|
|
||
| // unlockUserByID makes a PATCH request to /Users/{id}/status with {"locked": false} | ||
| func unlockUserByID(api *uaa.API, userID, zoneID string) error { | ||
| path := fmt.Sprintf("/Users/%s/status", userID) | ||
| data := `{"locked": false}` | ||
|
|
||
| headers := []string{"Content-Type: application/json"} | ||
| if zoneID != "" { | ||
| headers = append(headers, fmt.Sprintf("X-Identity-Zone-Id: %s", zoneID)) | ||
| } |
Comment on lines
+42
to
+49
| _, _, status, err := api.Curl(path, "PATCH", data, headers) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if status >= 400 { | ||
| return fmt.Errorf("unlock user 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.