mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-07 16:18:16 -06:00
17289 update tests
This commit is contained in:
parent
b57de257b5
commit
44c37ecdc5
@ -76,7 +76,7 @@ AUTH_PASSWORD_VALIDATORS = getattr(configuration, 'AUTH_PASSWORD_VALIDATORS', [
|
||||
"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', ''))
|
||||
|
@ -90,23 +90,10 @@ class UserTest(APIViewTestCases.APIViewTestCase):
|
||||
user.refresh_from_db()
|
||||
self.assertTrue(user.check_password(data['password']))
|
||||
|
||||
@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",
|
||||
},
|
||||
])
|
||||
@override_settings(AUTH_PASSWORD_VALIDATORS=[{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
'OPTIONS': {'min_length': 8}
|
||||
}])
|
||||
def test_password_validation_enforced(self):
|
||||
"""
|
||||
Test that any configured password validation rules (AUTH_PASSWORD_VALIDATORS) are enforced.
|
||||
|
@ -60,23 +60,6 @@ class UserTestCase(
|
||||
'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):
|
||||
"""
|
||||
Test that any configured password validation rules (AUTH_PASSWORD_VALIDATORS) are enforced.
|
||||
@ -97,8 +80,8 @@ class UserTestCase(
|
||||
self.assertHttpStatus(response, 200)
|
||||
|
||||
# Password long enough
|
||||
data['password'] = 'fooBar12'
|
||||
data['confirm_password'] = 'fooBar12'
|
||||
data['password'] = 'fooBarFoo123'
|
||||
data['confirm_password'] = 'fooBarFoo123'
|
||||
self.assertHttpStatus(self.client.post(**request), 302)
|
||||
|
||||
# Password no number
|
||||
|
@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError
|
||||
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.
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user