Let's hash the password like we do in core during tests

This commit is contained in:
Alexandre Aubin 2020-04-01 22:12:13 +02:00 committed by Alexandre Aubin
parent af3da58ed4
commit d40a91ab9b
2 changed files with 17 additions and 1 deletions

View file

@ -98,7 +98,22 @@ class LDAPServer:
"posixAccount", "posixAccount",
"simpleSecurityObject", "simpleSecurityObject",
], ],
"userPassword": ["yunohost"], "userPassword": [self._hash_user_password("yunohost")],
} }
ldap_interface.update("cn=admin", admin_dict) ldap_interface.update("cn=admin", admin_dict)
def _hash_user_password(self, password):
"""
Copy pasta of what's in yunohost/user.py
"""
import string
import random
import crypt
char_set = string.ascii_uppercase + string.ascii_lowercase + string.digits + "./"
salt = ''.join([random.SystemRandom().choice(char_set) for x in range(16)])
salt = '$6$' + salt + '$'
return '{CRYPT}' + crypt.crypt(str(password), salt)

View file

@ -19,6 +19,7 @@ deps =
gevent-websocket gevent-websocket
bottle >= 0.12 bottle >= 0.12
WebTest >= 2.0, < 2.1 WebTest >= 2.0, < 2.1
python-ldap >= 3.1.0
commands = commands =
pytest {posargs} pytest {posargs}