misc: fix min_password_strength default (#40685)
Default value from models.py was ignored before, now that it is applied, it breaks tests.
This commit is contained in:
parent
b16ea04d38
commit
936426a378
|
@ -0,0 +1,5 @@
|
|||
DEFAULT_MIN_PASSWORD_STRENGTH = 3
|
||||
|
||||
|
||||
def get_default_min_password_strength():
|
||||
return DEFAULT_MIN_PASSWORD_STRENGTH
|
|
@ -7,6 +7,7 @@ from django.db import migrations, models
|
|||
|
||||
import authentic2.utils.evaluate
|
||||
import authentic2.utils.template
|
||||
from authentic2.apps.authenticators import get_default_min_password_strength
|
||||
|
||||
|
||||
def create_login_password_authenticator(apps, schema_editor):
|
||||
|
@ -206,7 +207,7 @@ class Migration(migrations.Migration):
|
|||
(3, 'Good'),
|
||||
(4, 'Strong'),
|
||||
],
|
||||
default=3,
|
||||
default=get_default_min_password_strength,
|
||||
help_text='Password strength, using dynamic indicators such as common names, dates and other popular patterns. Selecting '
|
||||
'"static checks" will instead validate that a password contains enough different kind of caracters. Password indicator on '
|
||||
'registration form will reflect the chosen policy.',
|
||||
|
|
|
@ -37,6 +37,7 @@ from authentic2.models import Attribute
|
|||
from authentic2.utils.evaluate import condition_validator, evaluate_condition
|
||||
from authentic2.utils.template import validate_condition_template
|
||||
|
||||
from . import get_default_min_password_strength
|
||||
from .query import AuthenticatorManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -335,7 +336,7 @@ class LoginPasswordAuthenticator(BaseAuthenticator):
|
|||
min_password_strength = models.IntegerField(
|
||||
verbose_name=_('Minimum password strength'),
|
||||
choices=MIN_PASSWORD_STRENGTH_CHOICES,
|
||||
default=3,
|
||||
default=get_default_min_password_strength,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=_(
|
||||
|
|
|
@ -27,6 +27,7 @@ from django.core.management import call_command
|
|||
from django.db import connection, transaction
|
||||
from django.db.migrations.executor import MigrationExecutor
|
||||
|
||||
import authentic2.apps.authenticators
|
||||
from authentic2.a2_rbac.models import OrganizationalUnit, Role
|
||||
from authentic2.a2_rbac.utils import get_default_ou
|
||||
from authentic2.apps.authenticators.models import LoginPasswordAuthenticator
|
||||
|
@ -42,6 +43,9 @@ from authentic2_idp_oidc.models import OIDCClient
|
|||
from . import utils
|
||||
from .utils import create_user
|
||||
|
||||
# decrease required strength of password for tests
|
||||
authentic2.apps.authenticators.DEFAULT_MIN_PASSWORD_STRENGTH = None
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def settings(settings, request):
|
||||
|
|
|
@ -80,6 +80,7 @@ def test_authenticators_password(app, superuser_or_admin, settings):
|
|||
'button_description',
|
||||
'registration_open',
|
||||
'min_password_strength',
|
||||
'initial-min_password_strength',
|
||||
'password_min_length',
|
||||
'remember_me',
|
||||
'include_ou_selector',
|
||||
|
|
Loading…
Reference in New Issue