mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
admins: moar fixes
This commit is contained in:
parent
3758611d13
commit
1d98604e88
5 changed files with 15 additions and 7 deletions
|
@ -34,7 +34,7 @@ full-tests:
|
|||
PYTEST_ADDOPTS: "--color=yes"
|
||||
before_script:
|
||||
- *install_debs
|
||||
- yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns --force-diskspace
|
||||
- yunohost tools postinstall -d domain.tld -u syssa -f Syssa -l Mine -p the_password --ignore-dyndns --force-diskspace
|
||||
script:
|
||||
- python3 -m pytest --cov=yunohost tests/ src/tests/ src/diagnosers/ --junitxml=report.xml
|
||||
- cd tests
|
||||
|
|
|
@ -52,6 +52,11 @@ yunohost tools migrations run""",
|
|||
|
||||
self.ldap_migration_started = True
|
||||
|
||||
aliases = user_info(new_admin_user).get("mail-aliases", [])
|
||||
old_admin_aliases_to_remove = [alias for alias in aliases if any(alias.startswith(a) for a in ["root@", "admin@", "admins@", "webmaster@", "postmaster@", "abuse@"])]
|
||||
|
||||
user_update(new_admin_user, remove_mailalias=old_admin_aliases_to_remove)
|
||||
|
||||
stuff_to_delete = [
|
||||
"cn=admin,ou=sudo",
|
||||
"cn=admin",
|
||||
|
|
|
@ -38,7 +38,7 @@ def setup_function(function):
|
|||
global maindomain
|
||||
maindomain = _get_maindomain()
|
||||
|
||||
user_create("alice", "Alice", "White", maindomain, "test123Ynh")
|
||||
user_create("alice", "Alice", "White", maindomain, "test123Ynh", admin=True)
|
||||
user_create("bob", "Bob", "Snow", maindomain, "test123Ynh")
|
||||
user_create("jack", "Jack", "Black", maindomain, "test123Ynh")
|
||||
|
||||
|
@ -79,6 +79,7 @@ def test_list_groups():
|
|||
assert "alice" in res
|
||||
assert "bob" in res
|
||||
assert "jack" in res
|
||||
assert "alice" in res["admins"]["members"]
|
||||
for u in ["alice", "bob", "jack"]:
|
||||
assert u in res
|
||||
assert u in res[u]["members"]
|
||||
|
@ -176,7 +177,7 @@ def test_export_user(mocker):
|
|||
result = user_export()
|
||||
should_be = (
|
||||
"username;firstname;lastname;password;mail;mail-alias;mail-forward;mailbox-quota;groups\r\n"
|
||||
f"alice;Alice;White;;alice@{maindomain};{aliases};;0;dev\r\n"
|
||||
f"alice;Alice;White;;alice@{maindomain};;;0;admins,dev\r\n"
|
||||
f"bob;Bob;Snow;;bob@{maindomain};;;0;apps\r\n"
|
||||
f"jack;Jack;Black;;jack@{maindomain};;;0;"
|
||||
)
|
||||
|
|
|
@ -60,7 +60,7 @@ def tools_versions():
|
|||
return ynh_packages_version()
|
||||
|
||||
|
||||
def tools_rootpw(new_password):
|
||||
def tools_rootpw(new_password, check_strength=True):
|
||||
|
||||
from yunohost.user import _hash_user_password
|
||||
from yunohost.utils.password import (
|
||||
|
@ -70,7 +70,8 @@ def tools_rootpw(new_password):
|
|||
import spwd
|
||||
|
||||
assert_password_is_compatible(new_password)
|
||||
assert_password_is_strong_enough("admin", new_password)
|
||||
if check_strength:
|
||||
assert_password_is_strong_enough("admin", new_password)
|
||||
|
||||
new_hash = _hash_user_password(new_password)
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ def user_update(
|
|||
|
||||
# Populate user informations
|
||||
ldap = _get_ldap_interface()
|
||||
attrs_to_fetch = ["givenName", "sn", "mail", "maildrop"]
|
||||
attrs_to_fetch = ["givenName", "sn", "mail", "maildrop", "memberOf"]
|
||||
result = ldap.search(
|
||||
base="ou=users",
|
||||
filter="uid=" + username,
|
||||
|
@ -425,7 +425,8 @@ def user_update(
|
|||
|
||||
# Ensure compatibility and sufficiently complex password
|
||||
assert_password_is_compatible(change_password)
|
||||
assert_password_is_strong_enough("user", change_password) # FIXME FIXME FIXME : gotta use admin profile if user is admin
|
||||
is_admin = "cn=admins,ou=groups,dc=yunohost,dc=org" in result["memberOf"]
|
||||
assert_password_is_strong_enough("admin" if is_admin else "user", change_password)
|
||||
|
||||
new_attr_dict["userPassword"] = [_hash_user_password(change_password)]
|
||||
env_dict["YNH_USER_PASSWORD"] = change_password
|
||||
|
|
Loading…
Add table
Reference in a new issue