phase0: fix cross-plugin import, remove app.tenant_id, create cross-tenant v2 tests

- Fix report_generator/jobs.py: use DmsContract instead of direct DMS import
- Remove app.tenant_id from set_tenant_context (only app.current_tenant_id)
- Create tests/test_cross_tenant_security_v2.py with real RLS tests using
  unprivileged crm_api role (NOSUPERUSER, NOBYPASSRLS)
- Fix existing tests referencing app.tenant_id
- Git baseline tag v-phase0-baseline at 11d6faa
- Production DB backup at /tmp/crm_backup_20260731_015514.dump
This commit is contained in:
Agent Zero
2026-07-31 01:57:51 +02:00
parent 11d6faa34b
commit 032a7e80a8
5 changed files with 419 additions and 21 deletions
+2 -10
View File
@@ -441,9 +441,9 @@ async def test_tenant_context_variable_consistency(
db_session: AsyncSession,
tenant_a: Tenant,
):
"""Test that set_tenant_context sets both app.current_tenant_id and app.tenant_id."""
"""Test that set_tenant_context sets app.current_tenant_id (the only standard)."""
await set_tenant_context(db_session, tenant_a.id)
# Check app.current_tenant_id
result = await db_session.execute(
text("SELECT current_setting('app.current_tenant_id', true)")
@@ -451,11 +451,3 @@ async def test_tenant_context_variable_consistency(
current_tid = result.scalar()
assert current_tid == str(tenant_a.id), \
f"app.current_tenant_id not set correctly: {current_tid}"
# Check app.tenant_id (legacy)
result = await db_session.execute(
text("SELECT current_setting('app.tenant_id', true)")
)
legacy_tid = result.scalar()
assert legacy_tid == str(tenant_a.id), \
f"app.tenant_id not set correctly: {legacy_tid}"