Skip to content

feat(BA-5769): add my-role SDK, CLI, and v2 component tests#11179

Open
fregataa wants to merge 5 commits intomainfrom
feat/BA-5769-my-role-sdk-component-tests
Open

feat(BA-5769): add my-role SDK, CLI, and v2 component tests#11179
fregataa wants to merge 5 commits intomainfrom
feat/BA-5769-my-role-sdk-component-tests

Conversation

@fregataa
Copy link
Copy Markdown
Member

Summary

  • Add self-service my_search_assignments endpoint (POST /v2/rbac/assignments/my/search) for users to query their own role assignments
  • Add corresponding SDK method (V2RBACClient.my_search_assignments) and CLI command (./bai my role search)
  • Add v2 REST SDK component tests for assign, revoke, and my-search role assignment operations
  • Rename AdminSearchRoleAssignmentsGQLInputAdminSearchRoleAssignmentsInput and admin_search_role_assignments_gqladmin_search_role_assignments

Test plan

  • Component tests: TestAssignRoleV2 (admin assign success, user permission denied)
  • Component tests: TestRevokeRoleV2 (admin revoke success, user permission denied)
  • Component tests: TestMySearchAssignmentsV2 (own assignments visible, other users' hidden, empty result)
  • All 7 tests pass (pants test tests/component/rbac/test_rbac_role_v2.py)
  • Lint, type check pass

Resolves BA-5769

Copilot AI review requested due to automatic review settings April 18, 2026 13:04
@github-actions github-actions bot added size:L 100~500 LoC comp:manager Related to Manager component comp:client Related to Client component comp:common Related to Common component comp:cli Related to CLI component labels Apr 18, 2026
fregataa added a commit that referenced this pull request Apr 18, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a self-service “my role assignments” search flow to the v2 RBAC REST API, wires it through the v2 SDK and CLI, and expands component coverage for role assignment operations. This also includes a small naming cleanup for the role-assignment search DTO/function that is shared across REST and GraphQL.

Changes:

  • Add POST /v2/rbac/assignments/my/search (auth-required) and handler/adapter support for querying the current user’s assignments.
  • Add v2 SDK method V2RBACClient.my_search_assignments and CLI command group bai my role search.
  • Add v2 REST component tests for assign/revoke/my-search assignment flows and rename AdminSearchRoleAssignmentsGQLInputAdminSearchRoleAssignmentsInput across call sites.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/manager/api/gql/rbac/test_my_roles_resolver.py Updates mocks to match the renamed adapter method.
tests/component/rbac/test_rbac_role_v2.py Adds component tests for v2 assign/revoke and my-search assignment operations.
src/ai/backend/manager/api/rest/v2/rbac/registry.py Registers the new /assignments/my/search route with auth_required.
src/ai/backend/manager/api/rest/v2/rbac/handler.py Implements my_search_assignments REST handler and updates admin search handler to renamed adapter method.
src/ai/backend/manager/api/gql/rbac/types/role.py Updates role-user assignment lookup to use renamed search input/method.
src/ai/backend/manager/api/gql/rbac/resolver/role.py Updates resolvers to use renamed search input/method; preserves base_conditions for my_roles.
src/ai/backend/manager/api/adapters/rbac.py Adds my_search_role_assignments adapter helper and renames admin assignment search method.
src/ai/backend/common/dto/manager/v2/rbac/request.py Renames the role-assignment search request DTO.
src/ai/backend/common/dto/manager/v2/rbac/init.py Re-exports the renamed request DTO.
src/ai/backend/client/v2/domains_v2/rbac.py Adds SDK my_search_assignments and updates request DTO type for assignment search.
src/ai/backend/client/cli/v2/rbac/assignment.py Updates CLI to use renamed request DTO for admin assignment search.
src/ai/backend/client/cli/v2/my/role.py Adds bai my role search CLI command using the new SDK endpoint.
src/ai/backend/client/cli/v2/my/init.py Registers the new my role CLI group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ai/backend/common/dto/manager/v2/rbac/request.py Outdated
Comment thread src/ai/backend/manager/api/rest/v2/rbac/handler.py
fregataa and others added 3 commits April 18, 2026 22:37
- Add my_search_role_assignments adapter method with current_user() scope
- Add REST v2 endpoint POST /assignments/my/search (auth_required)
- Add my_search_assignments SDK method in V2RBACClient
- Add CLI command: ./bai my role search
- Add component tests for assign/revoke/my-search via v2 REST SDK
- Rename AdminSearchRoleAssignmentsGQLInput -> AdminSearchRoleAssignmentsInput
- Rename admin_search_role_assignments_gql -> admin_search_role_assignments

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add my_search_role_assignments adapter method with current_user() scope
- Add REST v2 endpoint POST /assignments/my/search (auth_required)
- Add my_search_assignments SDK method in V2RBACClient
- Add CLI command: ./bai my role search
- Add component tests for assign/revoke/my-search via v2 REST SDK
- Rename AdminSearchRoleAssignmentsGQLInput -> SearchRoleAssignmentsInput
- Rename AdminSearchRoleAssignmentsPayload -> SearchRoleAssignmentsPayload
- Rename admin_search_role_assignments_gql -> admin_search_role_assignments

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fregataa fregataa force-pushed the feat/BA-5769-my-role-sdk-component-tests branch from d241a64 to fa434ae Compare April 18, 2026 14:00
@fregataa fregataa added this to the 26.5 milestone Apr 18, 2026
@fregataa fregataa requested a review from a team April 18, 2026 14:08
Comment thread src/ai/backend/client/cli/v2/my/role.py Outdated
Comment thread src/ai/backend/client/cli/v2/my/role.py
Comment thread src/ai/backend/client/v2/domains_v2/rbac.py
Comment thread src/ai/backend/manager/api/adapters/rbac.py
…ter naming

- Change RoleAssignmentFilter.role_id from UUID to UUIDFilter for
  consistent filtering (supports equals/in/not_equals/not_in)
- Use click.UUID type for --role-id CLI options in my/role.py and
  rbac/assignment.py for proper input validation
- Extract _search_role_assignments private method in RBACAdapter so
  my_search_role_assignments no longer calls admin_search_role_assignments
- Add by_role_id_equals/by_role_id_in to AssignedUserConditions for
  convert_uuid_filter compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size:XL 500~ LoC and removed size:L 100~500 LoC labels Apr 19, 2026
Co-authored-by: octodog <mu001@lablup.com>
@github-actions github-actions bot added the area:docs Documentations label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:cli Related to CLI component comp:client Related to Client component comp:common Related to Common component comp:manager Related to Manager component size:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants