From dff92ecee815fcd79c1dc271ceb0b560df28a196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20V=C3=A1vra?= Date: Thu, 14 May 2026 07:19:22 +0200 Subject: [PATCH 1/2] Minor ci fix The explicit repo/branch prevented proper execution of ci in forks. --- .github/workflows/ci.yml | 1 - .github/workflows/static-code-analysis.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04d2e7c..e374f62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,6 @@ jobs: - name: Checkout sudo-tests repository uses: actions/checkout@v6 with: - repository: RedHat-SP-Security/sudo-tests path: sudo-tests - name: Setup containers diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml index 69ae69b..4c62d96 100644 --- a/.github/workflows/static-code-analysis.yml +++ b/.github/workflows/static-code-analysis.yml @@ -23,7 +23,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 with: - repository: RedHat-SP-Security/sudo-tests path: sudo-tests - name: Setup virtual environment From f75f0c668db2190fced50ca646c8ee9351ee4f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20V=C3=A1vra?= Date: Thu, 14 May 2026 07:00:37 +0200 Subject: [PATCH 2/2] Update test_basic__hostname_hostname Changes in the test framework for dyndns result in client hostname being chaged according to enrolled backend. We need to detect hostname instead of expecting client.test. Added python-specific .gitignore file. --- .gitignore | 61 ++++++++++++++++++++++++++++++++++++++ pytest/tests/test_basic.py | 24 ++++++++------- 2 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c69a0e --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Virtual environments +.venv/ +venv/ +ENV/ +env/ + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage +.pytest_cache/ +.coverage +.coverage.* +htmlcov/ +.tox/ +.nox/ +coverage.xml +*.cover +.hypothesis/ + +# Type checkers / linters +.mypy_cache/ +.dmypy.json +dmypy.json +.ruff_cache/ + +# pyenv +.python-version + +# Environments +.env +.envrc diff --git a/pytest/tests/test_basic.py b/pytest/tests/test_basic.py index 9325d18..110c0ab 100644 --- a/pytest/tests/test_basic.py +++ b/pytest/tests/test_basic.py @@ -828,17 +828,19 @@ def test_basic__hostname_hostname(client: Client, provider: GenericProvider, nam u = provider.user("user-1").add() other_host = "other" - if name == "shortname": - allowed_host = client.host.hostname.split(".")[0] - elif name == "fqdn": - allowed_host = client.host.hostname - other_host = "other.test" - elif name == "wildcard_shortname": - allowed_host = f"*{client.host.hostname.split(".")[0][2:]}" - elif name == "wildcard_fqdn": - allowed_host = f"*{client.host.hostname[2:]}" - else: - raise ValueError(f"Invalid hostname type: {name}") + match name: + case "shortname": + allowed_host = client.hostnameutils.shortname + case "fqdn": + fqdn = client.hostnameutils.fqdn + allowed_host = fqdn + other_host = f"other.{fqdn.split('.', 1)[1]}" if "." in fqdn else "other" + case "wildcard_shortname": + allowed_host = f"*{client.hostnameutils.shortname[2:]}" + case "wildcard_fqdn": + allowed_host = f"*{client.hostnameutils.fqdn[2:]}" + case _: + raise ValueError(f"Invalid hostname type: {name}") provider.sudorule("test1").add(user=u, host=allowed_host, command="/bin/ls") provider.sudorule("test2").add(user=u, host=other_host, command="/bin/df")