Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sssd_test_framework/roles/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def add(
home: str | None = None,
gecos: str | None = None,
shell: str | None = None,
email: str | None = None,
) -> GenericUser:
"""
Create a new user.
Expand All @@ -470,6 +471,8 @@ def add(
:type gecos: str | None, optional
:param shell: Login shell, defaults to None
:type shell: str | None, optional
:param email: email attribute, defaults to None
:type email: str | None, optional
:return: Self.
:rtype: GenericUser
"""
Expand All @@ -485,6 +488,7 @@ def modify(
home: str | None = None,
gecos: str | None = None,
shell: str | None = None,
email: str | None = None,
) -> GenericUser:
"""
Modify existing user.
Expand All @@ -503,6 +507,8 @@ def modify(
:type gecos: str | None, optional
:param shell: Login shell, defaults to None
:type shell: str | None, optional
:param email: email attribute, defaults to None
:type email: str | None, optional
:return: Self.
:rtype: GenericUser
"""
Expand Down
9 changes: 9 additions & 0 deletions sssd_test_framework/roles/ipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def add(
require_password_reset: bool = False,
user_auth_type: str | list[str] | None = None,
sshpubkey: str | list[str] | None = None,
email: str | None = None,
) -> IPAUser:
"""
Create new IPA user.
Expand All @@ -456,9 +457,12 @@ def add(
:type user_auth_type: str | list[str] | None, optional
:param sshpubkey: SSH public key, defaults to None
:type sshpubkey: str | list[str] | None, optional
:param email: email attribute, defaults to None
:type email: str | None, optional
:return: Self.
:rtype: IPAUser
"""

attrs = {
"first": (self.cli.option.VALUE, self.name),
"last": (self.cli.option.VALUE, self.name),
Expand All @@ -470,6 +474,7 @@ def add(
"password": (self.cli.option.SWITCH, True) if password is not None else None,
"user-auth-type": (self.cli.option.VALUE, user_auth_type),
"sshpubkey": (self.cli.option.VALUE, sshpubkey),
"email": (self.cli.option.VALUE, email),
}

if not require_password_reset:
Expand All @@ -494,6 +499,7 @@ def modify(
idp_user_id: str | None = None,
password_expiration: str | None = None,
sshpubkey: str | list[str] | None = None,
email: str | None = None,
) -> IPAUser:
"""
Modify existing IPA user.
Expand Down Expand Up @@ -524,6 +530,8 @@ def modify(
:type password_expiration: str | None, optional
:param sshpubkey: SSH public key, defaults to None
:type sshpubkey: str | list[str] | None, optional
:param email: email attribute, defaults to None
:type email: str | None, optional
:return: Self.
:rtype: IPAUser
"""
Expand All @@ -541,6 +549,7 @@ def modify(
"idp-user-id": (self.cli.option.VALUE, idp_user_id),
"password-expiration": (self.cli.option.VALUE, password_expiration),
"sshpubkey": (self.cli.option.VALUE, sshpubkey),
"email": (self.cli.option.VALUE, email),
}

self._modify(attrs, input=password)
Expand Down
15 changes: 11 additions & 4 deletions sssd_test_framework/roles/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ def add(
shadowLastChange: int | None = None,
sn: str | None = None,
givenName: str | None = None,
mail: str | None = None,
mail: str | None = None, # Remove later once tests are using the email attribute instead of mail
email: str | None = None,
) -> LDAPUser:
"""
Create new LDAP user.
Expand Down Expand Up @@ -698,6 +699,8 @@ def add(
:type givenName: str | None, optional
:param mail: mail LDAP attribute, defaults to None
:type mail: str | None, optional
:param email: mail LDAP attribute, defaults to None
:type mail: str | None, optional
:return: Self.
:rtype: LDAPUser
"""
Expand Down Expand Up @@ -725,13 +728,13 @@ def add(
"shadowLastChange": shadowLastChange,
"sn": sn,
"givenName": givenName,
"mail": mail,
"mail": mail or email,
}

if to_list_without_none([shadowMin, shadowMax, shadowWarning, shadowLastChange]):
attrs["objectClass"].append("shadowAccount")

if to_list_without_none([sn, mail]):
if to_list_without_none([sn, mail, email]):
attrs["sn"] = sn if sn else str(uid)
attrs["objectClass"].append("inetOrgPerson")

Expand All @@ -755,6 +758,7 @@ def modify(
sn: str | DeleteAttribute | None = None,
givenName: str | DeleteAttribute | None = None,
mail: str | DeleteAttribute | None = None,
email: str | DeleteAttribute | None = None,
) -> LDAPUser:
"""
Modify existing LDAP user.
Expand Down Expand Up @@ -790,9 +794,12 @@ def modify(
:type givenName: str | DeleteAttribute | None, optional
:param mail: mail LDAP attribute, defaults to None
:type mail: str | DeleteAttribute | None, optional
:param email: mail LDAP attribute, defaults to None
:type mail: str | DeleteAttribute | None, optional
:return: Self.
:rtype: LDAPUser
"""

attrs: LDAPRecordAttributes = {
"uidNumber": uid,
"gidNumber": gid,
Expand All @@ -807,7 +814,7 @@ def modify(
"cn": cn,
"sn": sn,
"givenName": givenName,
"mail": mail,
"mail": mail or email,
}

self._set(attrs)
Expand Down