sssd_test_framework.misc

Miscellaneous functions.

Functions

attrs_include_value(attr, value)

Include value to attribute list if it is not yet present.

attrs_parse(lines[, attrs])

Parse LDAP attributes from output.

attrs_to_hash(attrs)

Convert attributes into an Powershell hash table records.

parse_ldif(ldif)

Convert given LDIF to dictionary.

to_list(value)

Convert value into a list.

to_list_of_strings(value)

Convert given list or single value to list of strings.

to_list_without_none(r_list)

Remove all elements that are None from the list.

sssd_test_framework.misc.attrs_parse(lines: list[str], attrs: list[str] | None = None) dict[str, list[str]]

Parse LDAP attributes from output.

Parameters:
  • lines (list[str]) – Output.

  • attrs (list[str] | None, optional) – If set, only requested attributes are returned, defaults to None

Returns:

Dictionary with attribute name as a key.

Return type:

dict[str, list[str]]

sssd_test_framework.misc.attrs_include_value(attr: Any | list[Any] | None, value: Any) list[Any]

Include value to attribute list if it is not yet present.

If attr is not a list, then it is first converted into a list.

Parameters:
  • attr (Any | list[Any]) – List of attribute values or a single value.

  • value (Any) – Value to add to the list.

Returns:

New list with the value included.

Return type:

list[Any]

sssd_test_framework.misc.to_list(value: Any | list[Any] | None) list[Any]

Convert value into a list.

  • if value is None then return an empty list

  • if value is already a list then return it unchanged

  • if value is not a list then return [value]

Parameters:

value (Any | list[Any] | None) – Value that should be converted to a list.

Returns:

List with the value as an element.

Return type:

list[Any]

sssd_test_framework.misc.to_list_of_strings(value: Any | list[Any] | None) list[str]

Convert given list or single value to list of strings.

The value is first converted to a list and then str(item) is run on each of its item.

Parameters:

value (Any | list[Any] | None) – Value to convert.

Returns:

List of strings.

Return type:

list[str]

sssd_test_framework.misc.to_list_without_none(r_list: list[Any]) list[Any]

Remove all elements that are None from the list.

Parameters:

r_list (list[Any]) – List of all elements.

Returns:

New list with all values from the given list that are not None.

Return type:

list[Any]

sssd_test_framework.misc.parse_ldif(ldif: str) dict[str, dict[str, list[str]]]

Convert given LDIF to dictionary.

Parameters:

ldif (str) – Output of ldbsearch.

Returns:

Data of given ldif in format: dict[dn, dict[attribute, list[attrvalue]]].

Return type:

dict[str, dict[str, list[str]]

sssd_test_framework.misc.attrs_to_hash(attrs: dict[str, Any]) str | None

Convert attributes into an Powershell hash table records.

Parameters:

attrs (dict[str, Any]) – Attributes names and values.

Returns:

Attributes in powershell hash record format.

Return type:

str | None

Modules

sssd_test_framework.misc.errors

sssd_test_framework.misc.ssh