feat(python): add user management methods to IggyClient#3695
Conversation
321886e to
6fec2bc
Compare
The Python bindings need these types to expose user management, but only UserStatus was re-exported so far.
These types are needed by the upcoming user management methods on IggyClient. Permissions stay unexposed for now, so UserInfoDetails carries the same fields as UserInfo until the follow-up that maps the Permissions structure.
Expose get_user, get_users, create_user, update_user and delete_user, wrapping the Rust SDK UserClient functions like the existing topic and consumer group bindings. create_user always passes no permissions; the Permissions type mapping is left to a follow-up together with update_permissions, change_password and logout_user.
Cover create, get, list, update and delete against a live server, including default status, inactive users, login with created credentials, numeric and name identifiers, repeated listing stability, and pre-connection and pre-authentication failures.
6fec2bc to
7e57428
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3695 +/- ##
============================================
- Coverage 74.29% 65.33% -8.97%
Complexity 937 937
============================================
Files 1302 1302
Lines 148487 132979 -15508
Branches 124042 108494 -15548
============================================
- Hits 110323 86883 -23440
- Misses 34696 42579 +7883
- Partials 3468 3517 +49
🚀 New features to boost your workflow:
|
|
The 3 lines Codecov flags as uncovered in foreign/python/src/user.rs are the #[pyclass(...)] and #[pymethods] attribute lines. They are not missing tests. All hand-written logic in the file is fully exercised by tests/test_user.py. Should these attribute lines be brought to 100% as well, or is it fine to leave them as is? |
Fine as it is |
|
Also, please do commit the new changes as new commits. This will help me in understanding what changed after my review. |
|
/author |
Server error messages are not a stable contract and created_at is server generated, so assert neither.
Replace the hardcoded nonexistent id with a freshly vacated one, drop the repeated get_users snapshot comparison that other clients can invalidate, and assert the strictly ascending id order instead.
The server validates username and password length in bytes (3-50 and 3-100 respectively), not characters. Exercise both bounds for create_user and update_user, including multibyte credentials that fit the byte limits and ones that exceed them while staying within the character count.
Inactive and deleted users cannot log in, invalid identifiers fail client-side without a server round trip, an update with no fields is accepted as a noop, and deletion covers root protection, double deletion, removal from listings, live session behavior, and username reuse with fresh credentials.
|
/ready |
cabfe1e to
198274a
Compare
Without permission management in the Python SDK, this test passes even if the deleted session stays authenticated, so it cannot prove its claim. Reduce it to a no-op with a TODO to restore later.
881270f to
a9bb97b
Compare
|
/ready |
Which issue does this PR address?
Closes #3682
Rationale
Adds the missing user management operations to the Python SDK, which previously had no binding beyond
login_userand forced callers to the CLI or another SDK to provision users.What changed?
The Python SDK exposed no part of the Rust
UserClientsurface besideslogin_user, so users could not be listed, inspected, created, updated, or deleted from Python.get_user,get_users,create_user,update_user, anddelete_usernow bind through to the RustUserClient, andUserInfo,UserInfoDetails, andUserStatusare exposed as Python classes. As scoped in the issue,create_useralways passesNonefor permissions; thePermissionsmapping is left to a follow-up together withupdate_permissions,change_password, andlogout_user.Local Execution
AI Usage
Claude was used to help generate and review this PR and all the changes are checked by the human.