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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/static-code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
24 changes: 13 additions & 11 deletions pytest/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading