diff --git a/sqlalchemy_utils/types/password.py b/sqlalchemy_utils/types/password.py index 6c48036..6c571df 100644 --- a/sqlalchemy_utils/types/password.py +++ b/sqlalchemy_utils/types/password.py @@ -88,7 +88,7 @@ class PasswordType(types.TypeDecorator, ScalarCoercible): if max_length is None: # Calculate the largest possible encoded password. # name + rounds + salt + hash + ($ * 4) of largest hash - max_lengths = [] + max_lengths = [1024] for name in self.context.schemes(): scheme = getattr(__import__('passlib.hash').hash, name) length = 4 + len(scheme.name) diff --git a/tests/types/test_password.py b/tests/types/test_password.py index da4209c..5b1907b 100644 --- a/tests/types/test_password.py +++ b/tests/types/test_password.py @@ -8,7 +8,6 @@ from sqlalchemy_utils import Password, PasswordType @mark.skipif('password.passlib is None') class TestPasswordType(TestCase): - def create_models(self): class User(self.Base): __tablename__ = 'user' @@ -86,3 +85,6 @@ class TestPasswordType(TestCase): expected_length += 4 assert impl.length == expected_length + + def test_without_schemes(self): + assert PasswordType(schemes=[]).length == 1024