17289 update tests

This commit is contained in:
Arthur Hanson 2024-08-30 10:49:37 -07:00
parent b57de257b5
commit 44c37ecdc5
4 changed files with 8 additions and 38 deletions

View File

@ -76,7 +76,7 @@ AUTH_PASSWORD_VALIDATORS = getattr(configuration, 'AUTH_PASSWORD_VALIDATORS', [
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
}, },
{ {
"NAME": "utilities.password_validation.NumericAlphaPasswordValidator", "NAME": "utilities.password_validation.AlphanumericPasswordValidator",
}, },
]) ])
BASE_PATH = trailing_slash(getattr(configuration, 'BASE_PATH', '')) BASE_PATH = trailing_slash(getattr(configuration, 'BASE_PATH', ''))

View File

@ -90,23 +90,10 @@ class UserTest(APIViewTestCases.APIViewTestCase):
user.refresh_from_db() user.refresh_from_db()
self.assertTrue(user.check_password(data['password'])) self.assertTrue(user.check_password(data['password']))
@override_settings(AUTH_PASSWORD_VALIDATORS=[ @override_settings(AUTH_PASSWORD_VALIDATORS=[{
{ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", 'OPTIONS': {'min_length': 8}
}, }])
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
"OPTIONS": {
"min_length": 8,
},
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "utilities.password_validation.NumericAlphaPasswordValidator",
},
])
def test_password_validation_enforced(self): def test_password_validation_enforced(self):
""" """
Test that any configured password validation rules (AUTH_PASSWORD_VALIDATORS) are enforced. Test that any configured password validation rules (AUTH_PASSWORD_VALIDATORS) are enforced.

View File

@ -60,23 +60,6 @@ class UserTestCase(
'last_name': 'newlastname', 'last_name': 'newlastname',
} }
@override_settings(AUTH_PASSWORD_VALIDATORS=[
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
"OPTIONS": {
"min_length": 8,
},
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "utilities.password_validation.NumericAlphaPasswordValidator",
},
])
def test_password_validation_enforced(self): def test_password_validation_enforced(self):
""" """
Test that any configured password validation rules (AUTH_PASSWORD_VALIDATORS) are enforced. Test that any configured password validation rules (AUTH_PASSWORD_VALIDATORS) are enforced.
@ -97,8 +80,8 @@ class UserTestCase(
self.assertHttpStatus(response, 200) self.assertHttpStatus(response, 200)
# Password long enough # Password long enough
data['password'] = 'fooBar12' data['password'] = 'fooBarFoo123'
data['confirm_password'] = 'fooBar12' data['confirm_password'] = 'fooBarFoo123'
self.assertHttpStatus(self.client.post(**request), 302) self.assertHttpStatus(self.client.post(**request), 302)
# Password no number # Password no number

View File

@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
class NumericAlphaPasswordValidator: class AlphanumericPasswordValidator:
""" """
Validate that the password has at least one numeral, one uppercase letter and one lowercase letter. Validate that the password has at least one numeral, one uppercase letter and one lowercase letter.
""" """