84b3b7d8e8
Adds a complete pytest system test suite for the HoneyBiscuitWorkshop CI/CD system: - runner.sh: orchestrates build, Docker image creation, and test execution - Dockerfile: Arch Linux-based test image with Python venv - conftest.py: shared fixtures (baker_bin, run_baker, work_dir, llm_env) - probes/: environment probes for checking users, files, packages, processes - llm/: LLM-based log judgment system with caching for semantic test evaluation - fixtures/: test configs and scripts for prebake, bake, and finalize stages - test_prebake.py, test_bake.py, test_finalize.py: test suites for each pipeline stage Also refactors finalize.yml.tmpl notification config to use a templates system.
38 lines
968 B
Python
38 lines
968 B
Python
"""User existence and attribute probes."""
|
|
|
|
import pwd
|
|
import grp
|
|
|
|
|
|
def user_exists(username: str) -> bool:
|
|
"""Check if a system user exists."""
|
|
try:
|
|
pwd.getpwnam(username)
|
|
return True
|
|
except KeyError:
|
|
return False
|
|
|
|
|
|
def user_uid(username: str) -> int:
|
|
"""Get the UID of a user. Raises KeyError if user doesn't exist."""
|
|
return pwd.getpwnam(username).pw_uid
|
|
|
|
|
|
def user_gid(username: str) -> int:
|
|
"""Get the primary GID of a user. Raises KeyError if user doesn't exist."""
|
|
return pwd.getpwnam(username).pw_gid
|
|
|
|
|
|
def user_in_group(username: str, groupname: str) -> bool:
|
|
"""Check if a user is a member of a group."""
|
|
try:
|
|
group = grp.getgrnam(groupname)
|
|
return username in group.gr_mem
|
|
except KeyError:
|
|
return False
|
|
|
|
|
|
def user_shell(username: str) -> str:
|
|
"""Get the login shell of a user. Raises KeyError if user doesn't exist."""
|
|
return pwd.getpwnam(username).pw_shell
|