mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Remove _encode_dict
This commit is contained in:
parent
f6e92d84b8
commit
a10b40ed8d
3 changed files with 13 additions and 23 deletions
|
@ -124,7 +124,7 @@ class Authenticator(BaseAuthenticator):
|
|||
if not hashed_password["userPassword"][0].startswith("{CRYPT}$6$"):
|
||||
self.update(
|
||||
"cn=%s" % self.adminuser,
|
||||
{"userPassword": _hash_user_password(password)},
|
||||
{"userPassword": [_hash_user_password(password)]},
|
||||
)
|
||||
|
||||
# Additional LDAP methods
|
||||
|
@ -183,7 +183,7 @@ class Authenticator(BaseAuthenticator):
|
|||
|
||||
"""
|
||||
dn = rdn + "," + self.basedn
|
||||
ldif = modlist.addModlist(self._encode_dict(attr_dict))
|
||||
ldif = modlist.addModlist(attr_dict)
|
||||
|
||||
try:
|
||||
self.con.add_s(dn, ldif)
|
||||
|
@ -238,9 +238,7 @@ class Authenticator(BaseAuthenticator):
|
|||
"""
|
||||
dn = rdn + "," + self.basedn
|
||||
actual_entry = self.search(base=dn, attrs=None)
|
||||
ldif = modlist.modifyModlist(
|
||||
actual_entry[0], self._encode_dict(attr_dict), ignore_oldexistent=1
|
||||
)
|
||||
ldif = modlist.modifyModlist(actual_entry[0], attr_dict, ignore_oldexistent=1)
|
||||
|
||||
try:
|
||||
if new_rdn:
|
||||
|
@ -307,11 +305,3 @@ class Authenticator(BaseAuthenticator):
|
|||
|
||||
def _get_uri(self):
|
||||
return self.uri
|
||||
|
||||
def _encode_dict(self, _dict):
|
||||
return {k: self._encode_list(v) for k, v in _dict.items()}
|
||||
|
||||
def _encode_list(self, _list):
|
||||
if not isinstance(_list, list):
|
||||
_list = [_list]
|
||||
return [s.encode("utf-8") for s in _list]
|
||||
|
|
|
@ -86,19 +86,19 @@ class LDAPServer:
|
|||
ldap_interface.add(rdn, attr_dict)
|
||||
|
||||
admin_dict = {
|
||||
"cn": "admin",
|
||||
"uid": "admin",
|
||||
"description": "LDAP Administrator",
|
||||
"gidNumber": "1007",
|
||||
"uidNumber": "1007",
|
||||
"homeDirectory": "/home/admin",
|
||||
"loginShell": "/bin/bash",
|
||||
"cn": ["admin"],
|
||||
"uid": ["admin"],
|
||||
"description": ["LDAP Administrator"],
|
||||
"gidNumber": ["1007"],
|
||||
"uidNumber": ["1007"],
|
||||
"homeDirectory": ["/home/admin"],
|
||||
"loginShell": ["/bin/bash"],
|
||||
"objectClass": [
|
||||
"organizationalRole",
|
||||
"posixAccount",
|
||||
"simpleSecurityObject",
|
||||
],
|
||||
"userPassword": "yunohost",
|
||||
"userPassword": ["yunohost"],
|
||||
}
|
||||
|
||||
ldap_interface.update("cn=admin", admin_dict)
|
||||
|
|
|
@ -271,8 +271,8 @@ class TestLDAP:
|
|||
)
|
||||
|
||||
uid = new_user_info["uid"][0]
|
||||
new_user_info["uidNumber"] = "555"
|
||||
new_user_info["gidNumber"] = "555"
|
||||
new_user_info["uidNumber"] = ["555"]
|
||||
new_user_info["gidNumber"] = ["555"]
|
||||
new_another_user_uid = "new_another_user"
|
||||
if new_rdn:
|
||||
new_rdn = "uid=%s" % new_another_user_uid
|
||||
|
|
Loading…
Add table
Reference in a new issue