Skip to content

feat: implement comprehensive admin-only management commands

Ahlad Pataparla requested to merge feat/admin-only-endpoints into develop

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_request helper 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-client entry point

  • Testing Added tests/test_admin_commands.py covering all new endpoints and edge cases (e.g., missing authentication)


How to Test

  1. Ensure you are logged in with an account that has admin privileges:

    corpus-client login
  2. Test role listing:

    corpus-client admin roles list
  3. Test category moderation (if pending categories exist):

    corpus-client admin categories list-pending
  4. Verify that non-admin accounts receive the appropriate 403 Forbidden error when attempting these commands.

Related Issues

Closes #38 (closed)

Merge request reports

Loading