Skip to content

feat: add user/permission management utilities#470

Open
tdstein wants to merge 2 commits intomainfrom
feat/user-permission-management
Open

feat: add user/permission management utilities#470
tdstein wants to merge 2 commits intomainfrom
feat/user-permission-management

Conversation

@tdstein
Copy link
Copy Markdown
Collaborator

@tdstein tdstein commented Apr 10, 2026

Summary

Adds 6 SDK improvements for user and permission management, motivated by the need to merge duplicate user records during auth provider migrations:

  • PermissionRole IntEnum — role hierarchy comparison (PermissionRole("owner") > PermissionRole("viewer"))
  • Exact username filterclient.users.find(username="kaia") with client-side post-filtering
  • Permission.content property — lazy back-reference from a permission to its content item
  • Users.get_batch() — retrieve multiple users by GUID list
  • User.permissions.find() — query all permissions for a user across all content items
  • merge_users() admin utility — transfers content ownership and permissions from one user to another, with dry_run support

Test plan

  • pytest tests/posit/connect/test_permissions.py — 17 tests (5 new)
  • pytest tests/posit/connect/test_users.py — 27 tests (8 new)
  • pytest tests/posit/connect/test_admin.py — 7 tests (all new)
  • pytest tests/ — full suite, 419 tests, no regressions

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 10, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
2472 2316 94% 0% 🟢

New Files

File Coverage Status
src/posit/connect/admin.py 91% 🟢
TOTAL 91% 🟢

Modified Files

File Coverage Status
src/posit/connect/permissions.py 98% 🟢
src/posit/connect/users.py 97% 🟢
TOTAL 97% 🟢

updated for commit: 07cbb35 by action🐍

tdstein added 2 commits April 10, 2026 14:54
Add 6 improvements for user and permission management workflows:

- PermissionRole IntEnum for role hierarchy comparison
- Exact username filter on Users.find() and Users.find_one()
- Permission.content lazy back-reference to ContentItem
- Users.get_batch() for retrieving multiple users by GUID
- User.permissions.find() to query permissions across all content
- merge_users() admin utility for transferring ownership and permissions
Integration tests covering:
- merge_users: dry_run, ownership transfer, role upgrades
- PermissionRole: ordering, string construction, comparisons
- Users.find(username=): exact match filtering
- Users.get_batch(): multi-GUID retrieval
- User.permissions.find(): cross-content permission query
- Permission.content: back-reference to ContentItem
@tdstein tdstein force-pushed the feat/user-permission-management branch from 1252846 to 07cbb35 Compare April 10, 2026 18:54
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.

1 participant