Skip to content

feat(users): expand admin coverage and add my-account command#104

Merged
aarondpn merged 3 commits into
mainfrom
feat/users-my-account-issue-80
May 19, 2026
Merged

feat(users): expand admin coverage and add my-account command#104
aarondpn merged 3 commits into
mainfrom
feat/users-my-account-issue-80

Conversation

@aarondpn
Copy link
Copy Markdown
Owner

@aarondpn aarondpn commented May 19, 2026

Summary

Closes #80.

  • users get / users me: new --include memberships,groups (Redmine 2.1+ for groups); 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-id flags; --send-information on create (emailed sibling, not a user field). --password is no longer hard-required when --generate-password is set; the command errors fast if neither is provided.
  • New my-account command group backed by /my/account.json — the only user-write endpoint Redmine exposes to non-admins. my-account get includes api_key and custom_fields (which /users/current.json omits); my-account update accepts --firstname, --lastname, --mail, --mail-notification.
  • models.UserMembership type so the memberships include actually surfaces project + role names instead of falling through IDName (which only captured the membership ID).
  • MCP: new my_account group with get_my_account and update_my_account tools regenerated by go generate ./....

Docs

Test plan

  • make test (go test ./...) — all green locally.
  • make lint — 0 issues.
  • go generate ./... — MCP catalog refreshed; zz_generated_tools.go committed.
  • cd docs && npm run build — Astro builds 43 pages including the new my_account pages in both locales.
  • go build ./... + smoke-test redmine my-account --help, users create --help, users get --help.
  • CI: make e2e-test against Redmine 4.2, 5.1, 6.1 (covered by the e2e.yml workflow on this PR).

Unit test highlights (new)

  • TestUserGet_IncludeQueryParam / TestUserMe_IncludePassThrough?include=memberships,groups is forwarded verbatim.
  • TestUserGet_IncludeValidation — unknown include short-circuits before any HTTP call.
  • TestUserCreate_NewFlags — asserts send_information is a sibling of the user object, not nested.
  • TestUserCreate_RequiresPasswordOrGenerate — fail-fast when neither is set.
  • TestUserUpdate_NewFlags — only fields whose flags were Changed reach the wire.
  • TestMyAccount_GetDetail / TestMyAccount_GetJSONapi_key + custom fields surface in both output modes.
  • TestMyAccount_Update + TestMyAccount_UpdateMailNotificationValidation — PUT body shape, enum validation.

E2E (new)

  • TestUsers_GetWithIncludesmemberships and groups keys present in JSON when requested.
  • TestUsers_CreateWithNewFields + TestUsers_UpdateMailNotificationmail_notification round-trips through create/update + get.
  • TestMyAccount_Get + TestMyAccount_Update — admin's api_key returned; firstname round-trips and is restored in t.Cleanup since the admin user is shared.

aarondpn added 3 commits May 19, 2026 19:55
- 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.
@aarondpn aarondpn merged commit 18142fa into main May 19, 2026
6 checks passed
@aarondpn aarondpn deleted the feat/users-my-account-issue-80 branch May 19, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand user admin coverage and add my-account commands

1 participant