UPD: enable stronger password validation and eventually warning message on login
All checks were successful
buildbot/tox Build done.

This commit is contained in:
2020-12-22 18:42:06 +01:00
parent 47dd196c6a
commit c3f72a50ff
11 changed files with 132 additions and 63 deletions

View File

@@ -9,7 +9,7 @@ from ..emails import PasswordSetEmail
TEST_USERNAME = 'user'
TEST_PASSWORD = u'me||ön 2'
TEST_PASSWORD = u'me||ön 21ABll'
TEST_EMAIL = 'root@localhost'
PASSWORD_EMAIL_TEMPLATE = u"""Hallo {fullname},

View File

@@ -9,7 +9,7 @@ from dav_base.tests.generic import FormDataSet, FormsTestCase
from ..forms import LoginForm, SetPasswordForm, CreateAndSendPasswordForm
TEST_USERNAME = 'root@localhost'
TEST_PASSWORD = u'me||ön 2'
TEST_PASSWORD = u'me||ön 21ABll'
TEST_EMAIL = TEST_USERNAME
USERNAME_MAX_LENGTH = 254
@@ -108,7 +108,7 @@ class SetPasswordFormTestCase(FormsTestCase):
def test_mismatch(self):
data_sets = [
FormDataSet({'new_password': 'mellon12', 'new_password_repeat': 'mellon13'},
FormDataSet({'new_password': 'mellonAB12+-', 'new_password_repeat': 'mellonAB13+-'},
[('new_password_repeat', 'password_mismatch')]),
]
super(SetPasswordFormTestCase, self).test_invalid_data(data_sets=data_sets, form_kwargs={'user': self.user})
@@ -150,9 +150,10 @@ class SetPasswordFormTestCase(FormsTestCase):
def test_valid(self):
data_sets = [
FormDataSet({'new_password': 'mellon12', 'new_password_repeat': 'mellon12'}),
FormDataSet({'new_password': 'mellon12', 'new_password_repeat': 'mellon12', 'send_password_mail': True}),
FormDataSet({'new_password': u'"ä§ Mellon12', 'new_password_repeat': u'"ä§ Mellon12'}),
FormDataSet({'new_password': 'mellonAB12+-', 'new_password_repeat': 'mellonAB12+-'}),
FormDataSet({'new_password': 'mellonAB12+-', 'new_password_repeat': 'mellonAB12+-',
'send_password_mail': True}),
FormDataSet({'new_password': u'"ä§ MellonAB12+-', 'new_password_repeat': u'"ä§ MellonAB12+-'}),
FormDataSet({'new_password': 'mellon12' * 128, 'new_password_repeat': 'mellon12' * 128}),
]
super(SetPasswordFormTestCase, self).test_valid_data(data_sets=data_sets, form_kwargs={'user': self.user})

View File

@@ -9,7 +9,7 @@ from selenium.webdriver.common.keys import Keys
from dav_base.tests.generic import ScreenshotTestCase
TEST_USERNAME = 'root@localhost'
TEST_PASSWORD = u'me||ön 2'
TEST_PASSWORD = u'me||ön 21ABll'
TEST_EMAIL = TEST_USERNAME

View File

@@ -12,7 +12,7 @@ from dav_base.tests.generic import SeleniumTestCase
from .generic import SeleniumAuthMixin
TEST_USERNAME = 'root@localhost'
TEST_PASSWORD = 'me||ön 2'
TEST_PASSWORD = 'me||ön 21ABll'
TEST_EMAIL = TEST_USERNAME

View File

@@ -83,22 +83,22 @@ class CustomWordlistPasswordValidatorTestCase(SimpleTestCase):
def test_invalid(self):
invalid_passwords = [
(u'passwort', [
u'The password must not contain the word \'passwort\'',
u'Das Passwort darf nicht die Zeichenfolge \'passwort\' enthalten.',
]),
(u'abcdDaVefgh', [
u'The password must not contain the word \'dav\'',
u'Das Passwort darf nicht die Zeichenfolge \'dav\' enthalten.',
]),
(u'abcdsektIonefgh', [
u'The password must not contain the word \'sektion\'',
u'Das Passwort darf nicht die Zeichenfolge \'sektion\' enthalten.',
]),
(u'alpen12verein34KArlsruhE berge', [
u'The password must not contain the word \'karlsruhe\'',
u'The password must not contain the word \'berge\'',
u'Das Passwort darf nicht die Zeichenfolge \'karlsruhe\' enthalten.',
u'Das Passwort darf nicht die Zeichenfolge \'berge\' enthalten.',
]),
(u'heinzel@alpenverein-karlsruhe.de', [
u'The password must not contain the word \'heinzel\'',
u'The password must not contain the word \'alpenverein\'',
u'The password must not contain the word \'karlsruhe\'',
u'Das Passwort darf nicht die Zeichenfolge \'heinzel\' enthalten.',
u'Das Passwort darf nicht die Zeichenfolge \'alpenverein\' enthalten.',
u'Das Passwort darf nicht die Zeichenfolge \'karlsruhe\' enthalten.',
]),
]
@@ -140,66 +140,66 @@ class CharacterClassPasswordValidatorTestCase(SimpleTestCase):
def test_invalid(self):
invalid_passwords = [
(u'', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 characters from A-Z',
u'The password must contain at least 2 digits from 0-9',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'A+-', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 characters from A-Z',
u'The password must contain at least 2 digits from 0-9',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
]),
(u'1234567890*', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 characters from A-Z',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'34*/()', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 characters from A-Z',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
]),
(u'AA', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 digits from 0-9',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'CD0.,', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 digits from 0-9',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
]),
(u'EF56', [
u'The password must contain at least 2 characters from a-z',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'8GH?!8', [
u'The password must contain at least 2 characters from a-z',
u'Das Passwort muss mindestens 2 Kleinbuchstaben enthalten.',
]),
(u'bbX', [
u'The password must contain at least 2 characters from A-Z',
u'The password must contain at least 2 digits from 0-9',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'$cd%', [
u'The password must contain at least 2 characters from A-Z',
u'The password must contain at least 2 digits from 0-9',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
]),
(u'ef90', [
u'The password must contain at least 2 characters from A-Z',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'1g=h3~', [
u'The password must contain at least 2 characters from A-Z',
u'Das Passwort muss mindestens 2 Großbuchstaben enthalten.',
]),
(u'Gi&jH', [
u'The password must contain at least 2 digits from 0-9',
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
(u'IkK:i;', [
u'The password must contain at least 2 digits from 0-9',
u'Das Passwort muss mindestens 2 Ziffern enthalten.',
]),
(u'mKn4L8', [
u'The password must contain at least 2 non alpha numeric characters',
u'Das Passwort muss mindestens 2 Sonderzeichen enthalten.',
]),
]

View File

@@ -10,7 +10,7 @@ from django.urls import reverse
from ..forms import LoginForm, SetPasswordForm, CreateAndSendPasswordForm
TEST_USERNAME = 'root@localhost'
TEST_PASSWORD = u'me||ön 2'
TEST_PASSWORD = u'me||ön 21ABll'
TEST_EMAIL = TEST_USERNAME