feat(python): add user management methods to IggyClient#3695
feat(python): add user management methods to IggyClient#3695ethanlin01x wants to merge 10 commits into
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 73.99% 72.11% -1.89%
Complexity 937 937
============================================
Files 1301 1302 +1
Lines 147393 142232 -5161
Branches 122945 117748 -5197
============================================
- Hits 109063 102567 -6496
- Misses 34858 35892 +1034
- Partials 3472 3773 +301
🚀 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 |
| ) | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_create_user_password_limit_is_bytes_not_characters( |
| ids=["japanese-51-bytes", "emoji-52-bytes"], | ||
| ) | ||
| @pytest.mark.asyncio | ||
| async def test_create_user_username_limit_is_bytes_not_characters( |
| assert username not in [user.username for user in users] | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_deleted_user_live_session_loses_identity( |
There was a problem hiding this comment.
This test does not prove its claim:
- get_user(username) is None only proves deleted target no longer resolves.
- get_users() already fails before deletion because user has no permissions.
- Test still passes if deleted session remains authenticated.
Let's comment this out and add a todo to uncomment once permission management is added to python sdk
There was a problem hiding this comment.
Thanks, you're right. Reduced it to a no-op with a TODO to restore once permission management lands in the Python SDK (a9bb97b). Kept the function and docstring so the intent stays visible.
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.