Write tenant isolation integration tests #19

Open
opened 2026-04-20 09:37:11 +00:00 by sharang · 0 comments
Owner

Problem

The most critical security assumption — that Tenant A cannot access Tenant B's data — has zero automated tests. This means any regression in the tenant isolation code (#5) could silently ship to production.

Required Actions

  1. Add backend-compliance/compliance/tests/test_tenant_isolation.py
  2. Test matrix (at minimum):
    • Tenant A authenticated user cannot GET any resource belonging to Tenant B
    • Tenant A user cannot PATCH/DELETE Tenant B's records
    • Supplying X-Tenant-ID for another tenant after #5 fix is rejected with 403
    • DSR requests, VVT entries, company profiles, change requests — all scoped
  3. Tests must run against a real test database (transactional fixture with rollback), not mocks
  4. Add to CI test-python-backend job

Acceptance Criteria

  • Test suite contains at minimum 10 cross-tenant access scenarios, all returning non-200
  • Tests run in CI and are not marked @pytest.mark.skip
  • Depends on: #5 (tenant isolation fix)
## Problem The most critical security assumption — that Tenant A cannot access Tenant B's data — has zero automated tests. This means any regression in the tenant isolation code (#5) could silently ship to production. ## Required Actions 1. Add `backend-compliance/compliance/tests/test_tenant_isolation.py` 2. Test matrix (at minimum): - Tenant A authenticated user cannot GET any resource belonging to Tenant B - Tenant A user cannot PATCH/DELETE Tenant B's records - Supplying `X-Tenant-ID` for another tenant after #5 fix is rejected with 403 - DSR requests, VVT entries, company profiles, change requests — all scoped 3. Tests must run against a real test database (transactional fixture with rollback), not mocks 4. Add to CI `test-python-backend` job ## Acceptance Criteria - Test suite contains at minimum 10 cross-tenant access scenarios, all returning non-200 - Tests run in CI and are not marked `@pytest.mark.skip` - Depends on: #5 (tenant isolation fix)
sharang added this to the M4: Testing & Contract Stability milestone 2026-04-20 09:37:11 +00:00
sharang added the testingseverity: highsecurity labels 2026-04-20 09:37:11 +00:00
Sign in to join this conversation.