mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -45,8 +45,10 @@ class Command(BaseCommand):
|
||||
user=admin, content_object=admin, is_owner=True)
|
||||
|
||||
lc = models.LocalConfig.objects.first()
|
||||
secret_key = lc.parameters.get_value("secret_key")
|
||||
if not secret_key:
|
||||
condition = (
|
||||
"core" not in lc._parameters or
|
||||
"secret_key" not in lc._parameters["core"])
|
||||
if condition:
|
||||
lc.parameters.set_value("secret_key", random_key())
|
||||
lc.save()
|
||||
|
||||
|
||||
@@ -42,16 +42,23 @@ class AuthenticationTestCase(ModoTestCase):
|
||||
self.assertTrue(response.url.endswith(reverse("core:dashboard")))
|
||||
|
||||
|
||||
class ChangeDefaultAdminTestCase(TestCase):
|
||||
class LoadInitialDataTestCase(TestCase):
|
||||
"""Try to change the default username."""
|
||||
|
||||
def test_management_command(self):
|
||||
def test_change_default_admin(self):
|
||||
"""Use dedicated option."""
|
||||
management.call_command(
|
||||
"load_initial_data", "--admin-username", "modoadmin")
|
||||
self.assertTrue(
|
||||
self.client.login(username="modoadmin", password="password"))
|
||||
|
||||
def test_set_secret_key(self):
|
||||
"""Use dedicated option."""
|
||||
management.call_command("load_initial_data")
|
||||
lc = models.LocalConfig.objects.first()
|
||||
self.assertIn("core", lc._parameters)
|
||||
self.assertIn("secret_key", lc._parameters["core"])
|
||||
|
||||
|
||||
class ProfileTestCase(ModoTestCase):
|
||||
"""Profile related tests."""
|
||||
|
||||
Reference in New Issue
Block a user