Skip to content

Commit 2ce9498

Browse files
fix(tests): avoid flaky password_too_similar registration failures (#8460)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 2f1a915 commit 2ce9498

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

api/users/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import secrets
32
import string
43
import typing
54
import uuid
@@ -12,6 +11,7 @@
1211
from django.db import models
1312
from django.db.models import Count, QuerySet
1413
from django.utils import timezone
14+
from django.utils.crypto import get_random_string
1515
from django_lifecycle import ( # type: ignore[import-untyped]
1616
AFTER_SAVE,
1717
LifecycleModel,
@@ -110,10 +110,10 @@ def get_by_natural_key(self, email): # type: ignore[no-untyped-def]
110110

111111
def make_random_password(
112112
self,
113-
length: int = 10,
113+
length: int = 14,
114114
allowed_chars: str = string.ascii_letters + string.digits,
115115
) -> str:
116-
return "".join(secrets.choice(allowed_chars) for _ in range(length))
116+
return get_random_string(length, allowed_chars)
117117

118118

119119
class FFAdminUser(LifecycleModel, AbstractUser): # type: ignore[django-manager-missing,misc]

0 commit comments

Comments
 (0)