feat: implement comprehensive admin-only management commands
Overview
This Merge Request introduces a new admin command group to the CLI, providing a unified interface for administrative tasks that were previously only available via direct API calls or the backend database.
Changes
-
New Admin Command Group Added a modular sub-command structure in
src/corpus_client_cli/admin.py:-
admin roles: List, get, and create system roles -
admin users: Paginated listing of all registered users -
admin auth: Administrative utilities, including remote password resets -
admin categories: Full lifecycle management (list pending, create, approve, reject, and delete) -
admin history: Management of pending history restore operations
-
-
Standardized Admin Requests Implemented a private
_admin_requesthelper to handle:- Automatic authentication state verification
- Consistent header management (
Authorization: Bearer <token>) - Standardized error reporting and JSON output rendering using
rich
-
CLI Integration Registered the admin sub-app in the main
corpus-cliententry point -
Testing Added
tests/test_admin_commands.pycovering all new endpoints and edge cases (e.g., missing authentication)
How to Test
-
Ensure you are logged in with an account that has admin privileges:
corpus-client login -
Test role listing:
corpus-client admin roles list -
Test category moderation (if pending categories exist):
corpus-client admin categories list-pending -
Verify that non-admin accounts receive the appropriate
403 Forbiddenerror when attempting these commands.
Related Issues
Closes #38 (closed)