feat(users): expand admin coverage and add my-account command#104
Merged
Conversation
- users get/me: --include memberships,groups - users create: --mail-notification, --must-change-passwd, --generate-password, --auth-source-id, --send-information - users update: same four flags (no --send-information) - new my-account command group backed by /my/account.json, the only user-write endpoint Redmine exposes to non-admins; returns api_key + custom_fields - model: UserMembership type so the memberships include surfaces project + role names; new MyAccountUpdate, plus extended User for api_key, mail_notification, must_change_passwd, custom_fields - docs: English + zh-CN updates for users.mdx, new my_account.mdx pages, sidebar entry - tests: unit coverage for include validation/passthrough, new create/update flag wire shapes (send_information sibling, not nested), my-account get/update; e2e coverage for include passthrough, mail_notification round-trip, my-account get/update
- mcp_tools_readonly.golden.json: add get_my_account; refresh get_user and me descriptions touched by the new --include documentation. - TestUsers_GetWithIncludes / TestUsers_CreateWithNewFields / TestUsers_UpdateMailNotification: drop assertions that Redmine echoes memberships, groups, or mail_notification back on GET /users/:id.json. The server does not expose those fields on the public user endpoint (mail_notification is /my/account-only; empty memberships/groups arrays are stripped by the CLI's omitempty before reaching the test). The wire shape is already covered by the unit tests in internal/cmd/user.
- Hoist allowedMailNotifications + ValidateMailNotification + CompleteMailNotification into internal/cmd/user/mail_notification.go so the my-account package can import them instead of re-defining the enum and validators (kept create.go and update.go also using the shared helpers). - Export UserStatusName and FormatCustomFieldValues from the user package so my-account/get.go imports them instead of carrying its own copies. Net -89 lines.
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.
Summary
Closes #80.
users get/users me: new--include memberships,groups(Redmine 2.1+ forgroups); detail output surfaces project + role names per membership and group names.users create/users update: new--mail-notification,--must-change-passwd,--generate-password,--auth-source-idflags;--send-informationon create (emailed sibling, not auserfield).--passwordis no longer hard-required when--generate-passwordis set; the command errors fast if neither is provided.my-accountcommand group backed by/my/account.json— the only user-write endpoint Redmine exposes to non-admins.my-account getincludesapi_keyandcustom_fields(which/users/current.jsonomits);my-account updateaccepts--firstname,--lastname,--mail,--mail-notification.models.UserMembershiptype so the memberships include actually surfaces project + role names instead of falling throughIDName(which only captured the membership ID).my_accountgroup withget_my_accountandupdate_my_accounttools regenerated bygo generate ./....Docs
commands/users.mdxfor new flags + include row.commands/my_account.mdxwith theusers mevsmy-account getdistinction.Users.Test plan
make test(go test ./...) — all green locally.make lint— 0 issues.go generate ./...— MCP catalog refreshed;zz_generated_tools.gocommitted.cd docs && npm run build— Astro builds 43 pages including the new my_account pages in both locales.go build ./...+ smoke-testredmine my-account --help,users create --help,users get --help.make e2e-testagainst Redmine 4.2, 5.1, 6.1 (covered by thee2e.ymlworkflow on this PR).Unit test highlights (new)
TestUserGet_IncludeQueryParam/TestUserMe_IncludePassThrough—?include=memberships,groupsis forwarded verbatim.TestUserGet_IncludeValidation— unknown include short-circuits before any HTTP call.TestUserCreate_NewFlags— assertssend_informationis a sibling of theuserobject, not nested.TestUserCreate_RequiresPasswordOrGenerate— fail-fast when neither is set.TestUserUpdate_NewFlags— only fields whose flags wereChangedreach the wire.TestMyAccount_GetDetail/TestMyAccount_GetJSON—api_key+ custom fields surface in both output modes.TestMyAccount_Update+TestMyAccount_UpdateMailNotificationValidation— PUT body shape, enum validation.E2E (new)
TestUsers_GetWithIncludes—membershipsandgroupskeys present in JSON when requested.TestUsers_CreateWithNewFields+TestUsers_UpdateMailNotification—mail_notificationround-trips through create/update + get.TestMyAccount_Get+TestMyAccount_Update— admin'sapi_keyreturned; firstname round-trips and is restored int.Cleanupsince the admin user is shared.