Updated test

This commit is contained in:
Antoine Nguyen
2025-06-23 10:22:36 +02:00
parent 8ea5928869
commit 3013d1f581
3 changed files with 32 additions and 6 deletions
+4 -4
View File
@@ -24,6 +24,10 @@ const imapMigrationEnabled = computed(
() => parametersStore.imapMigrationEnabled
)
const openRspamdDashboard = () => {
router.push(rspamdUrl.value)
}
const settings = []
const adminMenuItems = [
{
@@ -136,8 +140,4 @@ onMounted(() => {
})
}
})
const openRspamdDashboard = () => {
router.push(rspamdUrl.value)
}
</script>
+27 -1
View File
@@ -5,7 +5,7 @@ from django.test import override_settings
from django.urls import reverse
from modoboa.core import factories as core_factories
from modoboa.core.models import User, LocalConfig
from modoboa.core.models import User
from modoboa.core.tests import test_ldap
from modoboa.lib.tests import NO_LDAP, ModoAPITestCase
from modoboa.limits import utils as limits_utils
@@ -46,6 +46,32 @@ class AccountTestCase(ModoAPITestCase):
super().setUpTestData()
factories.populate_database()
def test_random_password(self):
# Setting allow_special_characters to False
self.localconfig.parameters.set_value("allow_special_characters", False, "core")
random_password_length = self.localconfig.parameters.get_value(
"random_password_length", "core"
)
self.localconfig.save()
random_password = lib.make_password()
self.assertEqual(len(random_password), random_password_length)
self.assertEqual(
len([char for char in random_password if char in list(string.punctuation)]),
0,
)
# And with allow_special_characters to True
self.localconfig.parameters.set_value("allow_special_characters", True, "core")
self.localconfig.save()
random_password = lib.make_password()
self.assertEqual(len(random_password), random_password_length)
self.assertNotEqual(
len([char for char in random_password if char in list(string.punctuation)]),
0,
)
def test_aliases_update_on_disable(self):
"""Check if aliases are disabled when account is disabled."""
account = User.objects.get(username="user@test.com")
+1 -1
View File
@@ -61,7 +61,7 @@ def get_dovecot_schemes():
return [f"{{{smart_str(scheme)}}}" for scheme in schemes.split()], status
def cache_available_password_hasher(bypass_cache=False):
def cache_available_password_hasher(bypass_cache: bool = False):
available_schemes, status = get_dovecot_schemes()
password_scheme_choice = [
(hasher.name, hasher.label)