sssd_test_framework.utils.tools
Run various standard Linux commands on remote host.
Classes
|
Interface to getent command. |
|
Result of |
|
Result of |
|
Result of |
|
Result of |
|
|
|
Run various standard commands on remote host. |
|
Result of |
|
Result of |
|
Manage CA certificates and TLS configuration on a remote Linux host. |
|
Result of |
|
Interface to ssh-keygen command. |
|
Result of |
|
Result of 'getsubids'. |
|
Unix group. |
|
Generic Unix object. |
|
Unix user. |
- class sssd_test_framework.utils.tools.GetentUtils(*args, **kwargs)
Bases:
MultihostUtility[MultihostHost]Interface to getent command.
- Parameters:
host (MultihostHost) – Remote host.
- passwd(name: str | int, *, service: str | None = None) PasswdEntry | None
Call
getent passwd $name- Parameters:
name (str | int) – User name or id.
service (str | None) – Service used, defaults to None
- Returns:
passwd data, None if not found
- Return type:
PasswdEntry | None
- group(name: str | int, *, service: str | None = None) GroupEntry | None
Call
getent group $name- Parameters:
name (str | int) – Group name or id.
service (str | None) – Service used, defaults to None
- Returns:
group data, None if not found
- Return type:
PasswdEntry | None
- initgroups(name: str, *, service: str | None = None) InitgroupsEntry
Call
getent initgroups $nameIf
namedoes not exist, group list is empty. This is standard behavior ofgetent initgroups- Parameters:
name (str) – User name.
service (str | None) – Service used, defaults to None
- Returns:
Initgroups data
- Return type:
InitgroupsEntry
- netgroup(name: str, *, service: str | None = None) NetgroupEntry | None
Call
getent netgroup $name- Parameters:
name (str) – Netgroup name.
service (str | None) – Service used, defaults to None
- Returns:
Netgroup data, None if not found
- Return type:
NetgroupEntry | None
- hosts(name: str, *, service: str | None = None) HostsEntry
Call
getent hosts $name- Parameters:
name (str) – Hostname.
service (str | None) – Service used, defaults to None
- Returns:
Hosts data, None if not found
- Return type:
HostsEntry | None
- networks(name: str, *, service: str | None = None) NetworksEntry
Call
getent networks $name- Parameters:
name (str) – Network.
service (str | None) – Service used, defaults to None
- Returns:
Network data, None if not found
- Return type:
NetworksEntry | None
- services(name: str, *, service: str | None = None) ServicesEntry
Call
getent services $name- Parameters:
name (str) – Service.
service (str | None) – Service used, defaults to None
- Returns:
Service data, None if not found
- Return type:
ServicesEntry | None
- class sssd_test_framework.utils.tools.GroupEntry(name: str | None, password: str | None, gid: int | None, members: list[str])
Bases:
objectResult of
getent group- name: str | None
Group name.
- password: str | None
Group password.
- gid: int | None
Group id.
- members: list[str]
Group members.
- classmethod FromDict(d: dict[str, str | int | list[str] | None]) GroupEntry
- classmethod FromOutput(stdout: str) GroupEntry
- class sssd_test_framework.utils.tools.LinuxToolsUtils(*args, **kwargs)
Bases:
MultihostUtility[MultihostHost]Run various standard commands on remote host.
- Parameters:
host (MultihostHost) – Remote host.
- getent: GetentUtils
Run
getentcommand.
- getsubid(name: str, group: bool = False) SubIDEntry | None
Call
getsubids $name- Parameters:
name (str) – User name.
group (bool, defaults to False) – Get group range switch, optional
- Returns:
SubIDEntry data, None if not found
- Type:
SubIDEntry | None
- id(name: str | int) IdEntry | None
Run
idcommand.- Parameters:
name (str | int) – User name or id.
- Returns:
id data, None if not found
- Return type:
IdEntry | None
- grep(pattern: str, paths: str | list[str], args: list[str] | None = None) bool
Run
grepcommand.- Parameters:
pattern (str) – Pattern to match.
paths (str | list[str]) – Paths to search.
args (list[str] | None, optional) – Additional arguments to
grepcommand, defaults to None.
- Returns:
True if grep returned 0, False otherwise.
- Return type:
bool
- dnf(args: list[Any] | None = None) ProcessResult
Execute dnf commands with given arguments.
- Parameters:
args (list[Any] | None, optional) – Arguments to
dnf, defaults to None- Returns:
SSH Process result
- Return type:
ProcessResult
- faillock(args: list[Any]) ProcessResult
Execute faillock command. :param args: Arguments to
faillock:type args: list[Any] :return: SSH Process result :rtype: ProcessResult
- property sshkey: SSHKeyUtils
Execute ssh-keygen command. :return: SSHKeyUtils object. :rtype: SSHKeyUtils
- wait_for_condition(condition: str, body: str = '', timeout: int = 60) ProcessResult
Wait at maximum
timeoutseconds until theconditionis true. Executebodyafter each attempt. The condition is a bash expression, usually it is a single bash command that must succeed before a test can continue.Note
Internally, this expands to
timeout {time}s bash -c 'until {condition}; do : {body}; done'.Example usage@pytest.mark.topology(KnownTopology.LDAP) def test_just_condition(client: Client): client.sssd.domain["ldap_uri"] = "ldap://typo" client.sssd.start(debug_level=None, raise_on_error=False) assert client.sssd.default_domain r = client.tools.wait_for_condition(condition=f"sssctl domain-status {client.sssd.default_domain}") assert r.rc == 0 assert "LDAP: not connected" in r.stdout
- Parameters:
condition (str) – Command that is awaited
body (str, optional) – Body to be executed while waiting for condition, defaults to “”
timeout (int, optional) – How long should we try the command in seconds, defaults to 60
- Returns:
Proccess result
- Return type:
ProcessResult
- class sssd_test_framework.utils.tools.OpenSSLUtils(host: MultihostHost, fs: LinuxFileSystem)
Bases:
objectManage CA certificates and TLS configuration on a remote Linux host.
Provides helpers to install CA certificates into the system trust store and to configure OpenLDAP client settings for TLS. Suitable for use both from topology controllers (host-level setup) and from role methods (per-test operations).
- Parameters:
host (MultihostHost) – Remote host.
fs (LinuxFileSystem) – Filesystem utility for the host.
- DEFAULT_CACERT_PATH = '/etc/pki/ca-trust/source/anchors/test-ca.crt'
- host: MultihostHost
- fs: LinuxFileSystem
- install_ca_cert(cert_pem: str, name: str = 'test-ca.crt', cert_path: str | None = None) str
Install a PEM-encoded CA certificate into the system trust store.
Writes cert_pem to the system trust anchor directory (
/etc/pki/ca-trust/source/anchors/<name>), runsupdate-ca-trust, and configures/etc/openldap/ldap.confso that OpenLDAP clients use the system trust store.All changes made via fs are tracked by the test framework and restored automatically when the test or topology is torn down.
- Parameters:
cert_pem (str) – PEM-encoded CA certificate content.
name (str) – Certificate filename under
/etc/pki/ca-trust/source/anchors/. Ignored when cert_path is set.cert_path (str | None) – Full destination path on the client, overrides the default.
- Returns:
Path where the certificate was written on the client.
- Return type:
str
- install_ca_cert_from_server(hostname: str, port: int = 636, name: str = 'test-ca.crt', cert_path: str | None = None) str
Install a CA certificate by fetching it directly from a TLS server.
Connects to
hostname:portwithopenssl s_client, captures the last certificate in the chain (the root CA), writes it to the system trust anchor directory, runsupdate-ca-trust, and pointsTLS_CACERTin/etc/openldap/ldap.confat the system bundle. Useful when the server uses a self-signed certificate that is difficult to export from the host (e.g. AD DC with no AD CS).- Parameters:
hostname (str) – Hostname or IP of the TLS server.
port (int) – TLS port, defaults to 636.
name (str) – Certificate filename under
/etc/pki/ca-trust/source/anchors/. Ignored when cert_path is set.cert_path (str | None) – Full destination path on the client, overrides the default.
- Returns:
Path where the certificate was written on the client.
- Return type:
str
- Raises:
RuntimeError – If the certificate cannot be fetched from the server.
- class sssd_test_framework.utils.tools.PasswdEntry(name: str | None, password: str | None, uid: int | None, gid: int | None, gecos: str | None, home: str | None, shell: str | None)
Bases:
objectResult of
getent passwd- name: str | None
User name.
- password: str | None
User password.
- uid: int | None
User id.
- gid: int | None
Group id.
- gecos: str | None
GECOS.
- home: str | None
Home directory.
- shell: str | None
Login shell.
- classmethod FromDict(d: dict[str, str | int | None]) PasswdEntry
- classmethod FromOutput(stdout: str) PasswdEntry
- class sssd_test_framework.utils.tools.UnixGroup(id: int | None, name: str | None)
Bases:
UnixObjectUnix group.
- Parameters:
id (int | None) – Object ID.
name (str | None) – Object name.
- class sssd_test_framework.utils.tools.UnixObject(id: int | None, name: str | None)
Bases:
objectGeneric Unix object.
- Parameters:
id (int | None) – Object ID.
name (str | None) – Object name.
- id: int | None
ID.
- name: str | None
Name.
- class sssd_test_framework.utils.tools.UnixUser(id: int | None, name: str | None)
Bases:
UnixObjectUnix user.
- Parameters:
id (int | None) – Object ID.
name (str | None) – Object name.