Skip to content

test(BA-4921): expand check_permission_with_scope_chain() test coverage#9742

Open
fregataa wants to merge 3 commits intomainfrom
test/expand-check-permission-scope-chain-cases
Open

test(BA-4921): expand check_permission_with_scope_chain() test coverage#9742
fregataa wants to merge 3 commits intomainfrom
test/expand-check-permission-scope-chain-cases

Conversation

@fregataa
Copy link
Member

@fregataa fregataa commented Mar 6, 2026

Summary

  • Add 15 new test cases for check_permission_with_scope_chain() covering edge cases: operation mismatch, deleted/unassigned roles, multiple roles, mixed AUTO/REF edge chains, deep 3-level AUTO chains, self-scope combinations, user isolation, multiple permissions on same role, and entity type mismatch
  • Extend permission_setup fixture to support user_scope key and optional entity_type parameter
  • Add new fixtures: user_with_deleted_role, user_with_unassigned_role, user_with_two_roles, multi_role_permission_setup, project_in_domain_ref, domain_in_user_scope_auto, other_user_with_permission

Test plan

  • pants lint passes
  • pants check passes (mypy)
  • pants test tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py — all 24 test cases pass

Resolves BA-4921

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 6, 2026 08:31
@github-actions github-actions bot added the size:XL 500~ LoC label Mar 6, 2026
fregataa added a commit that referenced this pull request Mar 6, 2026
Copy link
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

Expands unit test coverage for PermissionDBSource.check_permission_with_scope_chain() by adding edge-case scenarios and extending fixtures to support additional scope/entity variations.

Changes:

  • Added 15 new test cases covering operation/entity mismatches, role assignment edge cases, multi-role behavior, mixed AUTO/REF chains, and deeper AUTO chains.
  • Extended permission_setup fixture to support user_scope and optional (scope_key, operation, entity_type) entries.
  • Added multiple new fixtures to model deleted/unassigned roles, multi-role users, mixed edge relations, and user isolation.

Reviewed changes

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

File Description
tests/unit/manager/repositories/permission_controller/test_check_permission_with_scope_chain.py Adds new fixtures and parametrized tests; extends permission_setup to support user scope and entity type overrides.
changes/9742.test.md Adds a changelog entry documenting the test coverage expansion.

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

fregataa and others added 3 commits March 6, 2026 17:56
Add 15 new test cases covering edge cases: operation mismatch,
deleted/unassigned roles, multiple roles, mixed AUTO/REF chains,
deep 3-level chains, self-scope combinations, user isolation,
multiple permissions, and entity type mismatch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…etrization

Replace raw tuples in permission_setup fixture with typed PermissionEntry
dataclass. Adds runtime type validation in the fixture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fregataa fregataa added this to the 26.3 milestone Mar 6, 2026
@fregataa fregataa force-pushed the test/expand-check-permission-scope-chain-cases branch from 69d1043 to 46e1c03 Compare March 6, 2026 08:56
@fregataa fregataa requested a review from a team March 6, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants