Skip to content

Commit

Permalink
version 20200429.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Apr 30, 2020
1 parent 92b0c0c commit 407cc51
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pydal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "20200429.3"
__version__ = "20200429.4"

from .base import DAL
from .objects import Field
Expand Down
12 changes: 6 additions & 6 deletions pydal/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4507,15 +4507,15 @@ class IS_STRONG(Validator):
>>> IS_STRONG(es=True, entropy=1, min=2)('a')
('a', 'Minimum length is 2')
>>> IS_STRONG(es=True, entropy=100)('abc123')
('abc123', 'Entropy (32.35) less than required (100)')
('abc123', 'Password too simple (32.35/100)')
>>> IS_STRONG(es=True, entropy=100)('and')
('and', 'Entropy (14.57) less than required (100)')
('and', 'Password too simple (14.57/100)')
>>> IS_STRONG(es=True, entropy=100)('aaa')
('aaa', 'Entropy (14.42) less than required (100)')
('aaa', 'Password too simple (14.42/100)')
>>> IS_STRONG(es=True, entropy=100)('a1d')
('a1d', 'Entropy (15.97) less than required (100)')
('a1d', 'Password too simple (15.97/100)')
>>> IS_STRONG(es=True, entropy=100)('añd')
('a\\xc3\\xb1d', 'Entropy (18.13) less than required (100)')
('a\\xc3\\xb1d', 'Password too simple (18.13/100)')
"""

Expand Down Expand Up @@ -4565,7 +4565,7 @@ def validate(self, value, record_id=None):
entropy = calc_entropy(value)
if entropy < self.entropy:
failures.append(
self.translator("Entropy (%(have)s) less than required (%(need)s)")
self.translator("Password too simple (%(have)s/%(need)s)")
% dict(have=entropy, need=self.entropy)
)
if isinstance(self.min, int) and self.min > 0:
Expand Down
12 changes: 6 additions & 6 deletions tests/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,20 +1048,20 @@ def test_IS_STRONG(self):
rtn = IS_STRONG(es=True, entropy=1, min=2)("a")
self.assertEqual(rtn, ("a", "Minimum length is 2"))
rtn = IS_STRONG(es=True, entropy=100)("abc123")
self.assertEqual(rtn, ("abc123", "Entropy (32.35) less than required (100)"))
self.assertEqual(rtn, ("abc123", "Password too simple (32.35/100)"))
rtn = IS_STRONG(es=True, entropy=100)("and")
self.assertEqual(rtn, ("and", "Entropy (14.57) less than required (100)"))
self.assertEqual(rtn, ("and", "Password too simple (14.57/100)"))
rtn = IS_STRONG(es=True, entropy=100)("aaa")
self.assertEqual(rtn, ("aaa", "Entropy (14.42) less than required (100)"))
self.assertEqual(rtn, ("aaa", "Password too simple (14.42/100)"))
rtn = IS_STRONG(es=True, entropy=100)("a1d")
self.assertEqual(rtn, ("a1d", "Entropy (15.97) less than required (100)"))
self.assertEqual(rtn, ("a1d", "Password too simple (15.97/100)"))
rtn = IS_STRONG(es=True, entropy=100)("añd")
if PY2:
self.assertEqual(
rtn, ("a\xc3\xb1d", "Entropy (18.13) less than required (100)")
rtn, ("a\xc3\xb1d", "Password too simple (18.13/100)")
)
else:
self.assertEqual(rtn, ("añd", "Entropy (18.13) less than required (100)"))
self.assertEqual(rtn, ("añd", "Password too simple (18.13/100)"))
rtn = IS_STRONG()("********")
self.assertEqual(rtn, ("********", None))
rtn = IS_STRONG(es=True, max=4)("abcde")
Expand Down

0 comments on commit 407cc51

Please sign in to comment.