Skip to content

test(e2e): org delete leaves no access and no live policy - #2021

Open
AmanGIT07 wants to merge 1 commit into
mainfrom
test/org-delete-acceptance
Open

AmanGIT07 wants to merge 1 commit into
mainfrom
test/org-delete-acceptance

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Summary

Adds an e2e test for the organization delete. After DeleteOrganization, nobody who had access can get the org, its projects or a resource inside one; no live policy is left on them; no live policy names the deleted group or service user; and the rows stay with deleted_at set. Test only.

Changes

  • test/e2e/regression/api_test.go: TestOrganizationDeleteLeavesNoAccessAndNoLivePolicy.

Technical Details

  • The org has an enabled project, a disabled project, a compute/order resource in the enabled project, a group and a service user. Users get access through the org owner role, the org viewer role, a direct project policy, the group, and a role on the resource; the service user through a project policy.
  • Before the delete, the test checks that each of them has the access it was given, and that live policies exist on every object and principal it checks afterwards.
  • Access is checked with CheckFederatedResourcePermission. With ids it asks SpiceDB only, so a deleted object answers false.
  • An org delete does not delete users, so the policy check by principal covers the group and the service user.
  • A personal access token of a deleted org stops working; TestPATOfDeletedOrgStopsAuthenticating in pat_test.go covers it.

Test Plan

  • The new test passes.
  • It fails when the cascade misses a step:
    • projects skipped: access is left on the project and the resource;
    • resources skipped: access is left on the resource;
    • project policies skipped: live policies are left on both projects;
    • org policies skipped: live policies are left on the org;
    • service users skipped: the service user row is not marked deleted;
    • resource policies skipped: a live policy is left on the resource.
  • go test ./test/e2e/... passes.
  • golangci-lint run ./test/e2e/regression/... reports no issues.

After DeleteOrganization, nobody who had access can get the org, its projects
or a resource inside one, no live policy is left on them or names the deleted
group or service user, and the rows stay marked deleted.
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Oct 23, 2026 4:34pm UTC

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 78c1825 and 142efb8.

📒 Files selected for processing: 1
  • test/e2e/regression/api_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Tests
    • Added regression coverage confirming that deleting an organization removes access to its projects and resources and leaves no active policies for related users and groups.

Adds an end-to-end regression test for organization deletion. The test checks access and live policies before deletion, then verifies access removal, policy cleanup, and soft-deleted database records.

Changes: Organization Deletion

Layer / File(s) Summary
Create principals and verify pre-deletion access
test/e2e/regression/api_test.go
Creates an organization, projects, resource, users, group, and service user. Adds scoped policies and checks access and live-policy counts before deletion.
Verify post-deletion cleanup
test/e2e/regression/api_test.go
Checks that subjects lose access, no live policies remain for tracked resources and principals, and database records remain marked deleted.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: whoabhisheksah

Merge Risk: ⚪ Minimal · up to 142ef

The new deletion regression test has no identified merge-blocking issue; merge after normal checks.

Pre-merge checks: Passed 2
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 39987793044

Coverage remained the same at 55.729%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 41926
Covered Lines: 23365
Line Coverage: 55.73%
Coverage Strength: 19.39 hits per line

💛 - Coveralls

This branch was successfully deployed

1 active deployment
Preview — 142efb8f Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants