:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(rbac): ignore stale access control rules without entitlement (#64138)
Reece Jones127d2e0103b2
diff --git a/posthog/rbac/test/test_user_access_control.py b/posthog/rbac/test/test_user_access_control.pyindex 1ade2fa59701..b50b2a1142c7 100644--- a/posthog/rbac/test/test_user_access_control.py+++ b/posthog/rbac/test/test_user_access_control.py@@ -527,6 +527,31 @@ class TestUserAccessControlFileSystem(BaseUserAccessControlTest):# Now user is no longer project admin, so file_b is excluded again (they're not the creator).self.assertCountEqual([self.file_a], filtered_for_user_after_removal)+ def test_filtering_ignores_rules_without_entitlement(self):+ # Global "none" rule on file_b (user is not its creator)+ AccessControl.objects.create(+ team=self.team,+ resource="my_resource",+ resource_id="def",+ access_level="none",+ )++ # Sanity: with the entitlement the rule is enforced (file_b hidden)+ self.assertCountEqual(+ [self.file_a],+ self.user_access_control.filter_and_annotate_file_system_queryset(FileSystem.objects.all()),+ )++ # Downgrade: drop the access_control entitlement -> stale rule must be ignored+ self.organization.available_product_features = []+ self.organization.save()++ fresh_uac = UserAccessControl(self.user, self.team)+ self.assertCountEqual(+ [self.file_a, self.file_b],+ fresh_uac.filter_and_annotate_file_system_queryset(FileSystem.objects.all()),+ )+@pytest.mark.eeclass TestUserAccessControlSerializer(BaseUserAccessControlTest):@@ -1206,6 +1231,58 @@ class TestSpecificObjectAccessControl(BaseUserAccessControlTest):assert self.notebook_3.id in notebook_idsassert self.notebook_2.id not in notebook_ids # Explicitly blocked+ def test_filter_queryset_ignores_rules_without_entitlement(self):+ from products.notebooks.backend.models import Notebook++ # Member-level "none" rule blocking notebook_2 for the user+ self._create_access_control(+ resource="notebook",+ resource_id=str(self.notebook_2.id),+ access_level="none",+ organization_member=self.organization_membership,+ )++ # Sanity: with the entitlement the rule is enforced+ self._clear_uac_caches()+ enforced_ids = list(+ self.user_access_control.filter_queryset_by_access_level(Notebook.objects.all()).values_list(+ "id", flat=True+ )+ )+ assert self.notebook_2.id not in enforced_ids++ # Downgrade: drop the access_control entitlement -> stale rule must be ignored+ self.organization.available_product_features = []+ self.organization.save()++ fresh_uac = UserAccessControl(self.user, self.team)+ filtered_ids = list(+ fresh_uac.filter_queryset_by_access_level(Notebook.objects.all()).values_list("id", flat=True)+ )+ assert self.notebook_1.id in filtered_ids+ assert self.notebook_2.id in filtered_ids+ assert self.notebook_3.id in filtered_ids++ def test_blocked_resource_ids_by_scope_ignores_rules_without_entitlement(self):+ # Member-level "none" rule blocking notebook_2 for the user+ self._create_access_control(+ resource="notebook",+ resource_id=str(self.notebook_2.id),+ access_level="none",+ organization_member=self.organization_membership,+ )++ # Sanity: with the entitlement the object is reported as blocked+ self._clear_uac_caches()+ assert str(self.notebook_2.id) in self.user_access_control.blocked_resource_ids_by_scope.get("notebook", set())++ # Downgrade: drop the access_control entitlement -> stale rule must be ignored+ self.organization.available_product_features = []+ self.organization.save()++ fresh_uac = UserAccessControl(self.user, self.team)+ assert fresh_uac.blocked_resource_ids_by_scope == {}+@parameterized.expand([(diff --git a/posthog/rbac/user_access_control.py b/posthog/rbac/user_access_control.pyindex 6f0d6d65779d..f23b367f5200 100644--- a/posthog/rbac/user_access_control.py+++ b/posthog/rbac/user_access_control.py@@ -445,8 +445,9 @@ class UserAccessControl:return Truedef _get_access_controls(self, filters: dict) -> list[_AccessControl]:- if not EE_AVAILABLE:+ if not EE_AVAILABLE or not self.access_controls_supported:return []+# Team-scoped lookups are served from the single bulk preload (filtered in memory);# org-scoped lookups fall through to a targeted query.if self._can_serve_from_preload(filters):@@ -1003,6 +1004,10 @@ class UserAccessControl:if not EE_AVAILABLE or not self._team or self.is_organization_admin:return {}+ if not self.access_controls_supported:+ # Without the entitlement, stale rules in the DB must be ignored, not enforced+ return {}+object_rows_by_resource: dict[APIScopeObject, list[_AccessControl]] = defaultdict(list)for ac in self._cached_access_controls:if ac.resource_id is not None:@@ -1042,6 +1047,10 @@ class UserAccessControl:if not EE_AVAILABLE:return queryset+ if not self.access_controls_supported:+ # Without the entitlement, stale rules in the DB must be ignored, not enforced+ return queryset+# Subquery to check if user has "admin" on the FileSystem's team/projectis_admin_for_project_subquery = (AccessControl.objects.filter(diff --git a/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr b/products/cdp/backend/api/test/__snapshots__/test_plugin.ambrindex 8692c4376960..1c99332e626f 100644--- a/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr+++ b/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr@@ -87,48 +87,6 @@'''# ---# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.10- '''- SELECT "posthog_organization"."id",- "posthog_organization"."name",- "posthog_organization"."slug",- "posthog_organization"."logo_media_id",- "posthog_organization"."created_at",- "posthog_organization"."updated_at",- "posthog_organization"."is_active",- "posthog_organization"."is_not_active_reason",- "posthog_organization"."session_cookie_age",- "posthog_organization"."is_member_join_email_enabled",- "posthog_organization"."is_ai_data_processing_approved",- "posthog_organization"."is_ai_training_opted_in",- "posthog_organization"."is_ai_training_locked",- "posthog_organization"."is_ai_training_cta_shown",- "posthog_organization"."enforce_2fa",- "posthog_organization"."members_can_invite",- "posthog_organization"."members_can_create_projects",- "posthog_organization"."members_can_use_personal_api_keys",- "posthog_organization"."allow_publicly_shared_resources",- "posthog_organization"."default_role_id",- "posthog_organization"."plugins_access_level",- "posthog_organization"."for_internal_metrics",- "posthog_organization"."default_experiment_stats_method",- "posthog_organization"."default_anonymize_ips",- "posthog_organization"."is_hipaa",- "posthog_organization"."is_pending_deletion",- "posthog_organization"."customer_id",- "posthog_organization"."available_product_features",- "posthog_organization"."usage",- "posthog_organization"."never_drop_data",- "posthog_organization"."customer_trust_scores",- "posthog_organization"."setup_section_2_completed",- "posthog_organization"."personalization",- "posthog_organization"."domain_whitelist",- "posthog_organization"."is_platform"- FROM "posthog_organization"- WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid- LIMIT 21- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.11'''SELECT 1 AS "a"FROM "posthog_organizationmembership"@@ -137,7 +95,7 @@LIMIT 1'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.12+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.11'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -179,7 +137,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.13+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.12'''SELECT "posthog_organizationmembership"."id","posthog_organizationmembership"."organization_id",@@ -230,34 +188,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.14- '''- SELECT "ee_accesscontrol"."id",- "ee_accesscontrol"."team_id",- "ee_accesscontrol"."access_level",- "ee_accesscontrol"."resource",- "ee_accesscontrol"."resource_id",- "ee_accesscontrol"."organization_member_id",- "ee_accesscontrol"."role_id",- "ee_accesscontrol"."created_by_id",- "ee_accesscontrol"."created_at",- "ee_accesscontrol"."updated_at"- FROM "ee_accesscontrol"- LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")- INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id")- WHERE (("ee_accesscontrol"."organization_member_id" IS NULL- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)- OR ("posthog_organizationmembership"."user_id" = 99999- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.15+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.13'''SELECT COUNT(*) AS "__count"FROM "posthog_plugin"@@ -271,7 +202,7 @@AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)))'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.16+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.14'''SELECT "posthog_plugin"."id","posthog_plugin"."organization_id",@@ -346,7 +277,7 @@LIMIT 100'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.17+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.15'''SELECT "posthog_user"."id","posthog_user"."password",@@ -391,7 +322,7 @@AND "posthog_user"."id" = 99999)'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.18+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.16'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -433,7 +364,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.19+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.17'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -475,7 +406,16 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.2+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.18+ '''+ SELECT 1 AS "a"+ FROM "posthog_organizationmembership"+ WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid+ AND "posthog_organizationmembership"."user_id" = 99999)+ LIMIT 1+ '''+# ---+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.19'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -517,16 +457,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.20- '''- SELECT 1 AS "a"- FROM "posthog_organizationmembership"- WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid- AND "posthog_organizationmembership"."user_id" = 99999)- LIMIT 1- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.21+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.2'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -568,7 +499,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.22+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.20'''SELECT "posthog_organizationmembership"."id","posthog_organizationmembership"."organization_id",@@ -619,34 +550,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.23- '''- SELECT "ee_accesscontrol"."id",- "ee_accesscontrol"."team_id",- "ee_accesscontrol"."access_level",- "ee_accesscontrol"."resource",- "ee_accesscontrol"."resource_id",- "ee_accesscontrol"."organization_member_id",- "ee_accesscontrol"."role_id",- "ee_accesscontrol"."created_by_id",- "ee_accesscontrol"."created_at",- "ee_accesscontrol"."updated_at"- FROM "ee_accesscontrol"- LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")- INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id")- WHERE (("ee_accesscontrol"."organization_member_id" IS NULL- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)- OR ("posthog_organizationmembership"."user_id" = 99999- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.24+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.21'''SELECT COUNT(*) AS "__count"FROM "posthog_plugin"@@ -660,7 +564,7 @@AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)))'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.25+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.22'''SELECT "posthog_plugin"."id","posthog_plugin"."organization_id",@@ -735,7 +639,7 @@LIMIT 100'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.26+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.23'''SELECT "posthog_user"."id","posthog_user"."password",@@ -780,7 +684,7 @@AND "posthog_user"."id" = 99999)'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.27+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.24'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -822,7 +726,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.28+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.25'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -864,16 +768,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.29- '''- SELECT 1 AS "a"- FROM "posthog_organizationmembership"- WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid- AND "posthog_organizationmembership"."user_id" = 99999)- LIMIT 1- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.3+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.26'''SELECT 1 AS "a"FROM "posthog_organizationmembership"@@ -882,7 +777,7 @@LIMIT 1'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.30+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.27'''SELECT "posthog_organization"."id","posthog_organization"."name",@@ -924,7 +819,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.31+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.28'''SELECT "posthog_organizationmembership"."id","posthog_organizationmembership"."organization_id",@@ -975,34 +870,7 @@LIMIT 21'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.32- '''- SELECT "ee_accesscontrol"."id",- "ee_accesscontrol"."team_id",- "ee_accesscontrol"."access_level",- "ee_accesscontrol"."resource",- "ee_accesscontrol"."resource_id",- "ee_accesscontrol"."organization_member_id",- "ee_accesscontrol"."role_id",- "ee_accesscontrol"."created_by_id",- "ee_accesscontrol"."created_at",- "ee_accesscontrol"."updated_at"- FROM "ee_accesscontrol"- LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")- INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id")- WHERE (("ee_accesscontrol"."organization_member_id" IS NULL- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)- OR ("posthog_organizationmembership"."user_id" = 99999- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.33+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.29'''SELECT COUNT(*) AS "__count"FROM "posthog_plugin"@@ -1016,7 +884,16 @@AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)))'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.34+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.3+ '''+ SELECT 1 AS "a"+ FROM "posthog_organizationmembership"+ WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid+ AND "posthog_organizationmembership"."user_id" = 99999)+ LIMIT 1+ '''+# ---+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.30'''SELECT "posthog_plugin"."id","posthog_plugin"."organization_id",@@ -1185,33 +1062,6 @@'''# ---# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.6- '''- SELECT "ee_accesscontrol"."id",- "ee_accesscontrol"."team_id",- "ee_accesscontrol"."access_level",- "ee_accesscontrol"."resource",- "ee_accesscontrol"."resource_id",- "ee_accesscontrol"."organization_member_id",- "ee_accesscontrol"."role_id",- "ee_accesscontrol"."created_by_id",- "ee_accesscontrol"."created_at",- "ee_accesscontrol"."updated_at"- FROM "ee_accesscontrol"- LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id")- INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id")- WHERE (("ee_accesscontrol"."organization_member_id" IS NULL- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)- OR ("posthog_organizationmembership"."user_id" = 99999- AND "ee_accesscontrol"."resource" = 'plugin'- AND "ee_accesscontrol"."resource_id" IS NOT NULL- AND "ee_accesscontrol"."role_id" IS NULL- AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))- '''-# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.7'''SELECT COUNT(*) AS "__count"FROM "posthog_plugin"@@ -1225,7 +1075,7 @@AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)))'''# ----# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.8+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.7'''SELECT "posthog_user"."id","posthog_user"."password",@@ -1270,6 +1120,48 @@AND "posthog_user"."id" = 99999)'''# ---+# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.8+ '''+ SELECT "posthog_organization"."id",+ "posthog_organization"."name",+ "posthog_organization"."slug",+ "posthog_organization"."logo_media_id",+ "posthog_organization"."created_at",+ "posthog_organization"."updated_at",+ "posthog_organization"."is_active",+ "posthog_organization"."is_not_active_reason",+ "posthog_organization"."session_cookie_age",+ "posthog_organization"."is_member_join_email_enabled",+ "posthog_organization"."is_ai_data_processing_approved",+ "posthog_organization"."is_ai_training_opted_in",+ "posthog_organization"."is_ai_training_locked",+ "posthog_organization"."is_ai_training_cta_shown",+ "posthog_organization"."enforce_2fa",+ "posthog_organization"."members_can_invite",+ "posthog_organization"."members_can_create_projects",+ "posthog_organization"."members_can_use_personal_api_keys",+ "posthog_organization"."allow_publicly_shared_resources",+ "posthog_organization"."default_role_id",+ "posthog_organization"."plugins_access_level",+ "posthog_organization"."for_internal_metrics",+ "posthog_organization"."default_experiment_stats_method",+ "posthog_organization"."default_anonymize_ips",+ "posthog_organization"."is_hipaa",+ "posthog_organization"."is_pending_deletion",+ "posthog_organization"."customer_id",+ "posthog_organization"."available_product_features",+ "posthog_organization"."usage",+ "posthog_organization"."never_drop_data",+ "posthog_organization"."customer_trust_scores",+ "posthog_organization"."setup_section_2_completed",+ "posthog_organization"."personalization",+ "posthog_organization"."domain_whitelist",+ "posthog_organization"."is_platform"+ FROM "posthog_organization"+ WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid+ LIMIT 21+ '''+# ---# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.9'''SELECT "posthog_organization"."id",diff --git a/products/cdp/backend/api/test/test_plugin.py b/products/cdp/backend/api/test/test_plugin.pyindex 47b34a3997d7..bd67287af6cf 100644--- a/products/cdp/backend/api/test/test_plugin.py+++ b/products/cdp/backend/api/test/test_plugin.py@@ -953,22 +953,22 @@ class TestPluginAPI(APIBaseTest, QueryMatchingTest):@snapshot_postgres_queriesdef test_listing_plugins_is_not_nplus1(self, _mock_get, _mock_reload) -> None:- with self.assertNumQueries(10):+ with self.assertNumQueries(9):self._assert_number_of_when_listed_plugins(0)Plugin.objects.create(organization=self.organization)- with self.assertNumQueries(10):+ with self.assertNumQueries(9):self._assert_number_of_when_listed_plugins(1)Plugin.objects.create(organization=self.organization)- with self.assertNumQueries(10):+ with self.assertNumQueries(9):self._assert_number_of_when_listed_plugins(2)Plugin.objects.create(organization=self.organization)- with self.assertNumQueries(10):+ with self.assertNumQueries(9):self._assert_number_of_when_listed_plugins(3)def _assert_number_of_when_listed_plugins(self, expected_plugins_count: int) -> None:diff --git a/products/product_analytics/backend/api/test/test_insight.py b/products/product_analytics/backend/api/test/test_insight.pyindex 00c49500ac39..aef86fcf52bd 100644--- a/products/product_analytics/backend/api/test/test_insight.py+++ b/products/product_analytics/backend/api/test/test_insight.py@@ -4389,6 +4389,10 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):def test_insight_access_control_filtering(self) -> None:"""Test that insights are properly filtered based on access control."""+ self.organization.available_product_features = [+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},+ ]+ self.organization.save()user2 = self._create_user("[email protected]")@@ -4532,6 +4536,11 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):from ee.models.rbac.access_control import AccessControl+ self.organization.available_product_features = [+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},+ ]+ self.organization.save()+# Create insights with different access levelsfilter_dict = {"events": [{"id": "$pageview"}]}