-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Add feature presence test suite #7597
Draft
jakub-vavra-cz
wants to merge
1
commit into
SSSD:master
Choose a base branch
from
jakub-vavra-cz:test_features
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
""" | ||
SSSD Feature presence suite | ||
|
||
:requirement: features | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import re | ||
|
||
import pytest | ||
from sssd_test_framework.roles.client import Client | ||
from sssd_test_framework.topology import KnownTopology | ||
|
||
|
||
def get_sssd_version(client: Client): | ||
""" | ||
Pull sssd version from client | ||
|
||
:return: Tuple of major, minor, patch, release of the version | ||
:rtype: tuple | ||
""" | ||
rpm = client.host.conn.run('test -f /usr/bin/rpm', raise_on_error=False) | ||
dpkg = client.host.conn.run('test -f /usr/bin/dpkg-query', raise_on_error=False) | ||
if rpm.rc == 0: | ||
ver = client.host.conn.run(r'rpm -q sssd --queryformat "%{VERSION}-%{RELEASE}"').stdout | ||
elif dpkg.rc !=0: | ||
ver = client.host.conn.run(r"dpkg-query -f '${Version}' -W sssd").stdout | ||
else: | ||
return 0, 0, 0, "unknown" | ||
|
||
v_match = re.match(r"([0-9]+)\.([0-9]+)\.([0-9]+)[.-~](.*)", ver, re.IGNORECASE) | ||
major = int(v_match.group(1)) | ||
minor = int(v_match.group(2)) | ||
patch = int(v_match.group(3)) | ||
release = v_match.group(4) | ||
|
||
return major, minor, patch, release | ||
|
||
|
||
@pytest.mark.importance("high") | ||
@pytest.mark.topology(KnownTopology.Client) | ||
def test_feature__sss_ssh_knownhosts(client: Client): | ||
""" | ||
:title: Feature sss_ssh_knownhosts presence | ||
:setup: | ||
1. Make sure sssd is installed | ||
:steps: | ||
1. Check sss_ssh_knownhosts feature presence | ||
:expectedresults: | ||
1. The feature is present in sssd 2.10 and higher | ||
:customerscenario: False | ||
:requirement: Support 'KnownHostsCommand' and deprecate 'sss_ssh_knownhostsproxy' | ||
""" | ||
major, minor, _, _ = get_sssd_version(client) | ||
if (major == 2 and minor >= 10) or major > 2: | ||
assert client.features["knownhosts"] | ||
else: | ||
assert not client.features["knownhosts"] | ||
|
||
|
||
@pytest.mark.importance("high") | ||
@pytest.mark.topology(KnownTopology.Client) | ||
def test_feature__files_provider(client: Client): | ||
""" | ||
:title: Feature files-provider presence | ||
:setup: | ||
1. Make sure sssd is installed | ||
:steps: | ||
1. Check files-provider feature presence | ||
:expectedresults: | ||
1. The feature should not be present in sssd 2.10 and higher | ||
:customerscenario: False | ||
""" | ||
major, minor, _, _ = get_sssd_version(client) | ||
if (major == 2 and minor >= 10) or major > 2: | ||
assert not client.features["files-provider"] | ||
else: | ||
assert client.features["files-provider"] | ||
|
||
|
||
@pytest.mark.importance("high") | ||
@pytest.mark.topology(KnownTopology.Client) | ||
def test_feature__passkey(client: Client): | ||
""" | ||
:title: Feature passkey presence | ||
:setup: | ||
1. Make sure sssd is installed | ||
:steps: | ||
1. Check passkey feature presence | ||
:expectedresults: | ||
1. The feature should be on RHEL 9.4+, CentOS 9+, Fedora 39+ and Ubuntu 23.10+ | ||
:customerscenario: False | ||
:requirement: passkey | ||
""" | ||
expect_passkey = False | ||
if "Fedora" in client.host.distro_name: | ||
expect_passkey = client.host.distro_major >= 39 | ||
elif "Red Hat Enterprise Linux" in client.host.distro_name: | ||
expect_passkey = expect_passkey = bool((client.host.distro_major == 9 and client.host.distro_minor >= 4) or client.host.distro_major > 9) | ||
elif "CentOS Stream" in client.distro_name: | ||
expect_passkey = client.distro_major >= 9 | ||
elif "Ubuntu" in client.host.distro_name: | ||
expect_passkey = not (client.host.distro_major <= 23 or (client.host.distro_major == 23 and client.host.distro_minor < 10)) | ||
else: | ||
pytest.skip("Unknown distro, no expectations set for passkey feature presence") | ||
|
||
assert bool( | ||
client.features["passkey"] == expect_passkey | ||
), f"Passkey does not match expectations on {client.host.distro_name} {client.host.distro_major} {client.host.distro_minor}." | ||
|
||
|
||
@pytest.mark.importance("high") | ||
@pytest.mark.topology(KnownTopology.Client) | ||
def test_feature__ldap_use_ppolicy(client: Client): | ||
""" | ||
:title: Feature ldap_use_ppolicy presence | ||
:setup: | ||
1. Make sure sssd is installed | ||
:steps: | ||
1. Check ldap_use_ppolicy feature presence | ||
:expectedresults: | ||
1. The feature should be present in sssd 2.10 and higher | ||
:customerscenario: False | ||
""" | ||
major, minor, _, _ = get_sssd_version(client) | ||
if (major == 2 and minor >= 10) or major > 2: | ||
assert client.features["ldap_use_ppolicy"] | ||
else: | ||
assert not client.features["ldap_use_ppolicy"] | ||
|
||
|
||
@pytest.mark.importance("high") | ||
@pytest.mark.topology(KnownTopology.Client) | ||
def test_feature__non_privileged(client: Client): | ||
""" | ||
:title: Feature non-privileged presence | ||
:setup: | ||
1. Make sure sssd is installed | ||
:steps: | ||
1. Check non-privileged feature presence | ||
:expectedresults: | ||
1. The feature should be present in sssd 2.10 and higher | ||
:customerscenario: False | ||
""" | ||
major, minor, _, _ = get_sssd_version(client) | ||
if (major == 2 and minor >= 10) or major > 2: | ||
assert client.features["non-privileged"] | ||
else: | ||
assert not client.features["non-privileged"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Variable defined multiple times Warning test