Reverted frontend application deployment, updated tests

This commit is contained in:
Spitfireap
2024-07-22 15:24:44 +02:00
parent 5b978e4475
commit 2f632dc6d7
2 changed files with 13 additions and 8 deletions
@@ -112,17 +112,12 @@ class Command(BaseCommand):
allowed_host = input("What will be the hostname used to access Modoboa? ")
if not allowed_host:
allowed_host = "localhost"
frontend_application_qs = app_model.objects.all()
frontend_application = None
for app in frontend_application_qs:
if app.name == "modoboa_frontend":
frontend_application = app
break
frontend_application = app_model.objects.filter(name="modoboa_frontend")
frontend_path = getattr(settings, "NEW_ADMIN_URL", "new-admin")
base_uri = f"https://{allowed_host}/{frontend_path}"
redirect_uri = f"{base_uri}/login/logged"
client_id = ""
if frontend_application is None:
if not frontend_application.exists():
if options["dev"]:
base_uri = "https://localhost:3000/"
redirect_uri = "https://localhost:3000/login/logged"
@@ -141,7 +136,7 @@ class Command(BaseCommand):
"authorization-code",
)
else:
client_id = frontend_application.client_id
client_id = frontend_application.first().client_id
base_frontend_dir = os.path.join(
os.path.dirname(__file__), "../../../frontend_dist/"
+10
View File
@@ -4,6 +4,7 @@ from io import StringIO
import httmock
from dateutil.relativedelta import relativedelta
from oauth2_provider.models import get_application_model
from django.core import mail
from django.core import management
@@ -60,6 +61,15 @@ class ManagementCommandsTestCase(SimpleModoTestCase):
management.call_command("cleanlogs")
self.assertEqual(models.Log.objects.count(), 1)
def test_non_duplicate_client_creation(self):
"""Test that the load_initial_data command do not create duplicates
client for the frontend deployment."""
app_model = get_application_model()
management.call_command("load_initial_data")
self.assertEqual(1, app_model.objects.filter(name="modoboa_frontend").count())
management.call_command("load_initial_data")
self.assertEqual(1, app_model.objects.filter(name="modoboa_frontend").count())
def test_clean_inactive_accounts(self):
"""Run clean_inactive_accounts command."""
management.call_command("load_initial_data")