Skip to content

feat(python): add user management methods to IggyClient#3695

Open
ethanlin01x wants to merge 10 commits into
apache:masterfrom
ethanlin01x:feat/python-sdk-user-management
Open

feat(python): add user management methods to IggyClient#3695
ethanlin01x wants to merge 10 commits into
apache:masterfrom
ethanlin01x:feat/python-sdk-user-management

Conversation

@ethanlin01x

@ethanlin01x ethanlin01x commented Jul 17, 2026

Copy link
Copy Markdown

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_user and forced callers to the CLI or another SDK to provision users.

What changed?

The Python SDK exposed no part of the Rust UserClient surface besides login_user, so users could not be listed, inspected, created, updated, or deleted from Python.

get_user, get_users, create_user, update_user, and delete_user now bind through to the Rust UserClient, and UserInfo, UserInfoDetails, and UserStatus are exposed as Python classes. As scoped in the issue, create_user always passes None for permissions; the Permissions mapping is left to a follow-up together with update_permissions, change_password, and logout_user.

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

Claude was used to help generate and review this PR and all the changes are checked by the human.

@ethanlin01x
ethanlin01x force-pushed the feat/python-sdk-user-management branch from 321886e to 6fec2bc Compare July 17, 2026 15:44
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.
@ethanlin01x
ethanlin01x force-pushed the feat/python-sdk-user-management branch from 6fec2bc to 7e57428 Compare July 17, 2026 15:51
@ethanlin01x
ethanlin01x marked this pull request as ready for review July 17, 2026 15:53
@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jul 17, 2026
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.03540% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.11%. Comparing base (6f1d548) to head (da1d23a).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
foreign/python/src/user.rs 79.06% 9 Missing ⚠️
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     
Components Coverage Δ
Rust Core 72.05% <ø> (-2.25%) ⬇️
Java SDK 62.44% <ø> (ø)
C# SDK 71.04% <ø> (-1.14%) ⬇️
Python SDK 92.15% <92.03%> (-0.02%) ⬇️
PHP SDK 84.29% <ø> (ø)
Node SDK 91.35% <ø> (+0.09%) ⬆️
Go SDK 42.87% <ø> (ø)
Files with missing lines Coverage Δ
foreign/python/src/client.rs 99.11% <100.00%> (+0.11%) ⬆️
foreign/python/src/lib.rs 100.00% <100.00%> (ø)
foreign/python/src/user.rs 79.06% <79.06%> (ø)

... and 140 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ethanlin01x

Copy link
Copy Markdown
Author

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?

@slbotbm

slbotbm commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

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

Comment thread foreign/python/tests/test_user.py Outdated
Comment thread foreign/python/tests/test_user.py
Comment thread foreign/python/tests/test_user.py Outdated
Comment thread foreign/python/tests/test_user.py Outdated
Comment thread foreign/python/tests/test_user.py Outdated
Comment thread foreign/python/tests/test_user.py Outdated
@slbotbm

slbotbm commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Also, please do commit the new changes as new commits. This will help me in understanding what changed after my review.

@slbotbm

slbotbm commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

/author

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jul 19, 2026
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.
@ethanlin01x

Copy link
Copy Markdown
Author

/ready

@ethanlin01x
ethanlin01x requested a review from slbotbm July 19, 2026 10:53
@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jul 19, 2026
Comment thread foreign/python/tests/test_user.py Outdated
)

@pytest.mark.asyncio
async def test_create_user_password_limit_is_bytes_not_characters(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not required

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, 198274a

Comment thread foreign/python/tests/test_user.py Outdated
ids=["japanese-51-bytes", "emoji-52-bytes"],
)
@pytest.mark.asyncio
async def test_create_user_username_limit_is_bytes_not_characters(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 198274a

assert username not in [user.username for user in users]

@pytest.mark.asyncio
async def test_deleted_user_live_session_loses_identity(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jul 20, 2026
@ethanlin01x
ethanlin01x force-pushed the feat/python-sdk-user-management branch from cabfe1e to 198274a Compare July 20, 2026 17:19
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.
@ethanlin01x
ethanlin01x force-pushed the feat/python-sdk-user-management branch from 881270f to a9bb97b Compare July 20, 2026 17:28
@ethanlin01x
ethanlin01x requested a review from slbotbm July 20, 2026 17:33
@ethanlin01x

Copy link
Copy Markdown
Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python sdk] Add functions related to user management

2 participants