35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import os
|
|
import testinfra.utils.ansible_runner
|
|
|
|
# Get hosts from Testinfra inventory created by Molecule
|
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|
os.environ.get('MOLECULE_INVENTORY_FILE')
|
|
).get_hosts('all')
|
|
|
|
|
|
def test_podman_package_installed(host):
|
|
pkg = host.package("podman")
|
|
assert pkg.is_installed, "podman package should be installed"
|
|
|
|
|
|
def test_podman_binary_executes(host):
|
|
cmd = host.run("podman --version")
|
|
assert cmd.rc == 0, f"podman not runnable: {cmd.stderr or cmd.stdout}"
|
|
|
|
|
|
def test_containers_conf_exists(host):
|
|
f = host.file("/etc/containers/registries.conf")
|
|
assert f.exists, "/etc/containers/registries.conf should exist"
|
|
|
|
|
|
def test_policy_json_exists(host):
|
|
f = host.file("/etc/containers/policy.json")
|
|
assert f.exists, "/etc/containers/policy.json should exist"
|
|
|
|
|
|
def test_podman_config_file_valid_json(host):
|
|
f = host.file("/etc/containers/policy.json")
|
|
assert f.exists and f.size > 0
|
|
cmd = host.run("python3 -c 'import json,sys;json.load(open(\"/etc/containers/policy.json\"))'")
|
|
assert cmd.rc == 0, "policy.json should be valid JSON"
|