From 7ce8af61925759e1b1516bf175c5a3c2dab590c5 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Fri, 12 Jan 2024 03:15:14 +0100 Subject: [PATCH] fix recovery tests Signed-off-by: Marc 'risson' Schmitt --- authentik/tenants/tests/test_recovery.py | 6 ++---- authentik/tenants/tests/utils.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/authentik/tenants/tests/test_recovery.py b/authentik/tenants/tests/test_recovery.py index ddee18360..fb9422812 100644 --- a/authentik/tenants/tests/test_recovery.py +++ b/authentik/tenants/tests/test_recovery.py @@ -2,6 +2,7 @@ from json import loads from django.urls import reverse +from django_tenants.utils import get_public_schema_name from authentik.core.models import Token, TokenIntents, User from authentik.lib.config import CONFIG @@ -18,10 +19,7 @@ class TestAPI(TenantAPITestCase): def setUp(self): super().setUp() - self.tenant = Tenant.objects.create( - name=generate_id(), - schema_name="t_" + generate_id(length=63 - 2) - ) + self.tenant = Tenant.objects.get(schema_name=get_public_schema_name()) self.user: User = User.objects.create_user(username="recovery-test-user") @CONFIG.patch("outposts.disable_embedded_outpost", True) diff --git a/authentik/tenants/tests/utils.py b/authentik/tenants/tests/utils.py index 5f11bbfa3..a92635ac0 100644 --- a/authentik/tenants/tests/utils.py +++ b/authentik/tenants/tests/utils.py @@ -10,7 +10,7 @@ class TenantAPITestCase(APITransactionTestCase): for db_name in self._databases_names(include_mirrors=False): with connections[db_name].cursor() as cursor: cursor.execute( - "SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname !~ 'pg_*' AND nspname != 'information_schema' AND nspname != 'public' AND nspname != 'template'" + "SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname ~ 't_.*'" ) schemas = cursor.fetchall() for row in schemas: