mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 00:28: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": "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', ''))
|
||||||
|
@ -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.
|
||||||
|
@ -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
|
||||||
|
@ -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.
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user