class _UserForm(formencode.Schema): allow_extra_fields = True filter_extra_fields = True username = All(v.UnicodeString(strip=True, min=1, not_empty=True), v.ValidUsername(edit, old_data)) if edit: new_password = All( v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=False)) password_confirmation = All( v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=False), ) admin = v.StringBoolean(if_missing=False) else: password = All(v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=True)) password_confirmation = All( v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=False)) active = v.StringBoolean(if_missing=False) firstname = v.UnicodeString(strip=True, min=1, not_empty=False) lastname = v.UnicodeString(strip=True, min=1, not_empty=False) email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data)) chained_validators = [v.ValidPasswordsMatch()]
class _UserForm(formencode.Schema): allow_extra_fields = True filter_extra_fields = True username = All(v.UnicodeString(strip=True, min=1, not_empty=True), v.ValidUsername(edit, old_data)) if edit: new_password = All( v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=False)) password_confirmation = All( v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=False), ) admin = v.StringBoolean(if_missing=False) else: password = All(v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=True)) password_confirmation = All( v.ValidPassword(), v.UnicodeString(strip=False, min=6, not_empty=False)) password_change = v.StringBoolean(if_missing=False) create_repo_group = v.StringBoolean(if_missing=False) active = v.StringBoolean(if_missing=False) firstname = v.UnicodeString(strip=True, min=1, not_empty=False) lastname = v.UnicodeString(strip=True, min=1, not_empty=False) email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data)) extern_name = v.UnicodeString(strip=True) extern_type = v.UnicodeString(strip=True) language = v.OneOf(available_languages, hideList=False, testValueList=True, if_missing=None) chained_validators = [v.ValidPasswordsMatch()]
class _PasswordChangeForm(formencode.Schema): allow_extra_fields = True filter_extra_fields = True current_password = v.ValidOldPassword(username)(not_empty=True) new_password = All(v.ValidPassword(), v.UnicodeString(strip=False, min=6)) new_password_confirmation = All(v.ValidPassword(), v.UnicodeString(strip=False, min=6)) chained_validators = [ v.ValidPasswordsMatch('new_password', 'new_password_confirmation') ]
def test_register_special_chars(self): response = self.app.post( url(controller='login', action='register'), { 'username': '******', 'password': '******', 'password_confirmation': 'ąćźżąśśśś', 'email': '*****@*****.**', 'firstname': 'test', 'lastname': 'test' }) msg = validators.ValidPassword()._messages['invalid_password'] response.mustcontain(msg)
def test_ValidPassword(self): validator = v.ValidPassword() self.assertEqual('lol', validator.to_python('lol')) self.assertEqual(None, validator.to_python(None)) self.assertRaises(formencode.Invalid, validator.to_python, 'ąćżź')
def test_ValidPassword(): validator = v.ValidPassword() assert 'lol' == validator.to_python('lol') assert None == validator.to_python(None) pytest.raises(formencode.Invalid, validator.to_python, 'ąćżź')