diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py index 7f1287fba0..f39591c779 100644 --- a/common/djangoapps/student/tests/test_email.py +++ b/common/djangoapps/student/tests/test_email.py @@ -136,7 +136,7 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase): params = { 'username': 'test_user', 'email': 'test_user@example.com', - 'password': 'edx', + 'password': 'long_password', 'name': 'Test User', 'honor_code': True, 'terms_of_service': True diff --git a/common/djangoapps/util/tests/test_password_policy_validators.py b/common/djangoapps/util/tests/test_password_policy_validators.py index f0ffe3c2b1..f5eea255bf 100644 --- a/common/djangoapps/util/tests/test_password_policy_validators.py +++ b/common/djangoapps/util/tests/test_password_policy_validators.py @@ -45,6 +45,11 @@ class PasswordPolicyValidatorsTestCase(unittest.TestCase): validate_password(password, user) assert msg in ' '.join(cm.value.messages) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_unicode_password(self): """ Tests that validate_password enforces unicode """ unicode_str = '𤭮' @@ -55,12 +60,17 @@ class PasswordPolicyValidatorsTestCase(unittest.TestCase): assert len(unicode_str) == 1 # Test length check - self.validation_errors_checker(byte_str, 'This password is too short. It must contain at least 2 characters.') - self.validation_errors_checker(byte_str + byte_str, None) + self.validation_errors_checker(byte_str, 'This password is too short. It must contain at least 4 characters.') + self.validation_errors_checker(byte_str * 4, None) # Test badly encoded password self.validation_errors_checker(b'\xff\xff', 'Invalid password.') + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_password_unicode_normalization(self): """ Tests that validate_password normalizes passwords """ # s ̣ ̇ (s with combining dot below and combining dot above) @@ -70,7 +80,7 @@ class PasswordPolicyValidatorsTestCase(unittest.TestCase): # When we normalize we expect the not_normalized password to fail # because it should be normalized to '\u1E69' -> ṩ self.validation_errors_checker(not_normalized_password, - 'This password is too short. It must contain at least 2 characters.') + 'This password is too short. It must contain at least 4 characters.') @data( ([create_validator_config('common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 2})], # lint-amnesty, pylint: disable=line-too-long diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 0bc05545f7..8e73ab2ec3 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -2689,20 +2689,30 @@ class RegistrationValidationViewTests(test_utils.ApiTestCase, OpenEdxEventsTestM {"username": str(USERNAME_INVALID_CHARS_ASCII)} ) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_password_empty_validation_decision(self): # 2 is the default setting for minimum length found in lms/envs/common.py # under AUTH_PASSWORD_VALIDATORS.MinimumLengthValidator - msg = 'This password is too short. It must contain at least 2 characters.' + msg = 'This password is too short. It must contain at least 4 characters.' self.assertValidationDecision( {'password': ''}, {"password": msg} ) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_password_bad_min_length_validation_decision(self): password = 'p' # 2 is the default setting for minimum length found in lms/envs/common.py # under AUTH_PASSWORD_VALIDATORS.MinimumLengthValidator - msg = 'This password is too short. It must contain at least 2 characters.' + msg = 'This password is too short. It must contain at least 4 characters.' self.assertValidationDecision( {'password': password}, {"password": msg}