From 31d979bd29360374806f233204d6e53a9047b694 Mon Sep 17 00:00:00 2001 From: catborise Date: Sat, 17 Oct 2026 00:00:35 +0300 Subject: [PATCH] test: a fast password hash for the test suite Tests create and log in users for most test cases; Django's default PBKDF2 hash made that half of the suite's time (260 s -> 124 s locally with MD5). The fast hasher is set only when the command is manage.py test. --- webvirtcloud/settings.py.template | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webvirtcloud/settings.py.template b/webvirtcloud/settings.py.template index 13d3648f..91ecbe3b 100644 --- a/webvirtcloud/settings.py.template +++ b/webvirtcloud/settings.py.template @@ -4,6 +4,7 @@ Django settings for webvirtcloud project. """ import os +import sys try: import ldap from django_auth_ldap.config import LDAPSearch, NestedActiveDirectoryGroupType @@ -172,6 +173,10 @@ AUTHENTICATION_BACKENDS = [ LOGIN_URL = "/accounts/login/" +# Tests create users by the thousand: a fast hash for them (manage.py test only) +if sys.argv[1:2] == ["test"]: + PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"] + # Failed logins (django-axes): a user is locked for the address the logins # come from. The limit and the lock time are on the Settings page # (LOGIN_FAILURE_LIMIT, LOGIN_LOCKOUT_MINUTES); unlock with