Skip to content

Commit

Permalink
Drop deprecated firstname/lastname in user_create/update + also drop …
Browse files Browse the repository at this point in the history
…old deprecated cert- commands
  • Loading branch information
alexAubin committed Jun 14, 2023
1 parent f6ab380 commit 8ac48ee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 115 deletions.
76 changes: 1 addition & 75 deletions share/actionsmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,10 @@ user:
help: The full name of the user. For example 'Camille Dupont'
extra:
ask: ask_fullname
required: False
required: True
pattern: &pattern_fullname
- !!str ^([^\W_]{1,30}[ ,.'-]{0,3})+$
- "pattern_fullname"
-f:
full: --firstname
help: Deprecated. Use --fullname instead.
extra:
required: False
pattern: &pattern_firstname
- !!str ^([^\W\d_]{1,30}[ ,.'-]{0,3})+$
- "pattern_firstname"
-l:
full: --lastname
help: Deprecated. Use --fullname instead.
extra:
required: False
pattern: &pattern_lastname
- !!str ^([^\W\d_]{1,30}[ ,.'-]{0,3})+$
- "pattern_lastname"
-p:
full: --password
help: User password
Expand Down Expand Up @@ -147,16 +131,6 @@ user:
help: The full name of the user. For example 'Camille Dupont'
extra:
pattern: *pattern_fullname
-f:
full: --firstname
help: Deprecated. Use --fullname instead.
extra:
pattern: *pattern_firstname
-l:
full: --lastname
help: Deprecated. Use --fullname instead.
extra:
pattern: *pattern_lastname
-m:
full: --mail
extra:
Expand Down Expand Up @@ -551,54 +525,6 @@ domain:
extra:
pattern: *pattern_domain

### certificate_status()
cert-status:
deprecated: true
action_help: List status of current certificates (all by default).
arguments:
domain_list:
help: Domains to check
nargs: "*"
--full:
help: Show more details
action: store_true

### certificate_install()
cert-install:
deprecated: true
action_help: Install Let's Encrypt certificates for given domains (all by default).
arguments:
domain_list:
help: Domains for which to install the certificates
nargs: "*"
--force:
help: Install even if current certificate is not self-signed
action: store_true
--no-checks:
help: Does not perform any check that your domain seems correctly configured (DNS, reachability) before attempting to install. (Not recommended)
action: store_true
--self-signed:
help: Install self-signed certificate instead of Let's Encrypt
action: store_true

### certificate_renew()
cert-renew:
deprecated: true
action_help: Renew the Let's Encrypt certificates for given domains (all by default).
arguments:
domain_list:
help: Domains for which to renew the certificates
nargs: "*"
--force:
help: Ignore the validity threshold (30 days)
action: store_true
--email:
help: Send an email to root with logs if some renewing fails
action: store_true
--no-checks:
help: Does not perform any check that your domain seems correctly configured (DNS, reachability) before attempting to renew. (Not recommended)
action: store_true

### domain_url_available()
url-available:
hide_in_help: True
Expand Down
3 changes: 2 additions & 1 deletion src/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ def domain_info(domain):

from yunohost.app import app_info
from yunohost.dns import _get_registar_settings
from yunohost.certificate import certificate_status

_assert_domain_exists(domain)

registrar, _ = _get_registar_settings(domain)
certificate = domain_cert_status([domain], full=True)["certificates"][domain]
certificate = certificate_status([domain], full=True)["certificates"][domain]

apps = []
for app in _installed_apps():
Expand Down
8 changes: 1 addition & 7 deletions src/tests/test_user-group.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ def test_del_group_that_does_not_exist(mocker):


def test_update_user():
with message("user_updated"):
user_update("alice", firstname="NewName", lastname="NewLast")

info = user_info("alice")
assert info["fullname"] == "NewName NewLast"

with message("user_updated"):
user_update("alice", fullname="New2Name New2Last")

Expand Down Expand Up @@ -315,7 +309,7 @@ def test_update_group_remove_user_not_already_in():

def test_update_user_that_doesnt_exist(mocker):
with raiseYunohostError(mocker, "user_unknown"):
user_update("doesnt_exist", firstname="NewName", lastname="NewLast")
user_update("doesnt_exist", fullname="Foo Bar")


def test_update_group_that_doesnt_exist(mocker):
Expand Down
45 changes: 13 additions & 32 deletions src/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,33 +141,20 @@ def user_create(
domain,
password,
fullname=None,
firstname=None,
lastname=None,
mailbox_quota="0",
admin=False,
from_import=False,
loginShell=None,
):
if firstname or lastname:
logger.warning(
"Options --firstname / --lastname of 'yunohost user create' are deprecated. We recommend using --fullname instead."
)

if not fullname or not fullname.strip():
if not firstname.strip():
raise YunohostValidationError(
"You should specify the fullname of the user using option -F"
)
lastname = (
lastname or " "
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
fullname = f"{firstname} {lastname}".strip()
else:
fullname = fullname.strip()
firstname = fullname.split()[0]
lastname = (
" ".join(fullname.split()[1:]) or " "
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
raise YunohostValidationError(
"You should specify the fullname of the user using option -F"
)
fullname = fullname.strip()
firstname = fullname.split()[0]
lastname = (
" ".join(fullname.split()[1:]) or " "
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...

from yunohost.domain import domain_list, _get_maindomain, _assert_domain_exists
from yunohost.hook import hook_callback
Expand Down Expand Up @@ -364,8 +351,6 @@ def user_delete(operation_logger, username, purge=False, from_import=False):
def user_update(
operation_logger,
username,
firstname=None,
lastname=None,
mail=None,
change_password=None,
add_mailforward=None,
Expand All @@ -377,17 +362,15 @@ def user_update(
fullname=None,
loginShell=None,
):
if firstname or lastname:
logger.warning(
"Options --firstname / --lastname of 'yunohost user create' are deprecated. We recommend using --fullname instead."
)

if fullname and fullname.strip():
fullname = fullname.strip()
firstname = fullname.split()[0]
lastname = (
" ".join(fullname.split()[1:]) or " "
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
else:
firstname = None
lastname = None

from yunohost.domain import domain_list
from yunohost.app import app_ssowatconf
Expand Down Expand Up @@ -884,8 +867,7 @@ def update(new_infos, old_infos=False):

user_update(
new_infos["username"],
firstname=new_infos["firstname"],
lastname=new_infos["lastname"],
fullname=(new_infos["firstname"] + " " + new_infos["lastname"]).strip(),
change_password=new_infos["password"],
mailbox_quota=new_infos["mailbox-quota"],
mail=new_infos["mail"],
Expand Down Expand Up @@ -930,8 +912,7 @@ def update(new_infos, old_infos=False):
user["password"],
user["mailbox-quota"],
from_import=True,
firstname=user["firstname"],
lastname=user["lastname"],
fullname=(user["firstname"] + " " + user["lastname"]).strip(),
)
update(user)
result["created"] += 1
Expand Down

0 comments on commit 8ac48ee

Please sign in to comment.