removed python tests
All checks were successful
test / Linting (push) Successful in 10s
test / Molecule tests (default, debian12) (push) Successful in 37s
test / Molecule tests (default, ubuntu2004) (push) Successful in 37s
test / Molecule tests (default, debian11) (push) Successful in 53s
test / Molecule tests (with_ssh_keys, debian11) (push) Successful in 34s
test / Molecule tests (default, ubuntu2204) (push) Successful in 39s
test / Molecule tests (with_ssh_keys, debian12) (push) Successful in 34s
test / Molecule tests (with_ssh_keys, ubuntu2004) (push) Successful in 39s
test / Molecule tests (with_ssh_keys, ubuntu2204) (push) Successful in 40s

This commit is contained in:
Bertrand Lanson 2023-07-15 00:52:40 +02:00
parent 7d74ef4c89
commit 0be5397356
4 changed files with 0 additions and 108 deletions

View File

@ -1,22 +0,0 @@
"""PyTest Fixtures."""
from __future__ import absolute_import
import os
import pytest
def pytest_runtest_setup(item):
"""Run tests only when under molecule with testinfra installed."""
try:
import testinfra
except ImportError:
pytest.skip("Test requires testinfra", allow_module_level=True)
if "MOLECULE_INVENTORY_FILE" in os.environ:
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
else:
pytest.skip(
"Test should run only from inside molecule.", allow_module_level=True
)

View File

@ -1,28 +0,0 @@
"""Role testing files using testinfra."""
def test_hosts_file(host):
"""Validate /etc/hosts file."""
etc_hosts = host.file("/etc/hosts")
assert etc_hosts.exists
assert etc_hosts.user == "root"
assert etc_hosts.group == "root"
def test_ansible_user_group(host):
"""Validate ansible user and group."""
ansible_group = host.group("ansible")
ansible_user = host.user("ansible")
assert ansible_group.exists
assert ansible_user.exists
assert ansible_user.group == "ansible"
assert ansible_user.shell == "/bin/bash"
def test_ansible_sudoer(host):
"""Validate that ansible user is not sudoer"""
etc_sudoers_d_ansible = host.file("/etc/sudoers.d/ansible")
assert not etc_sudoers_d_ansible.exists
def test_ansible_no_ssh(host):
"""Validate that ansible user has no authorized_keys"""
opt_ansible_authorized_keys = host.file("/opt/ansible/.ssh/authorized_keys")
assert not opt_ansible_authorized_keys.exists

View File

@ -1,22 +0,0 @@
"""PyTest Fixtures."""
from __future__ import absolute_import
import os
import pytest
def pytest_runtest_setup(item):
"""Run tests only when under molecule with testinfra installed."""
try:
import testinfra
except ImportError:
pytest.skip("Test requires testinfra", allow_module_level=True)
if "MOLECULE_INVENTORY_FILE" in os.environ:
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
else:
pytest.skip(
"Test should run only from inside molecule.", allow_module_level=True
)

View File

@ -1,36 +0,0 @@
"""Role testing files using testinfra."""
def test_hosts_file(host):
"""Validate /etc/hosts file."""
etc_hosts = host.file("/etc/hosts")
assert etc_hosts.exists
assert etc_hosts.user == "root"
assert etc_hosts.group == "root"
def test_ansible_user_group(host):
"""Validate ansible user and group."""
ansible_group = host.group("ansible")
ansible_user = host.user("ansible")
assert ansible_group.exists
assert ansible_user.exists
assert ansible_user.group == "ansible"
assert ansible_user.shell == "/bin/bash"
def test_ansible_sudoer(host):
"""Validate that ansible user is sudoer"""
etc_sudoers_d_ansible = host.file("/etc/sudoers.d/ansible")
assert etc_sudoers_d_ansible.exists
assert etc_sudoers_d_ansible.user == "root"
assert etc_sudoers_d_ansible.group == "root"
assert etc_sudoers_d_ansible.mode == 0o440
assert etc_sudoers_d_ansible.contains("ansible ALL=NOPASSWD:SETENV: ALL")
def test_ansible_ssh_authorized_keys(host):
"""Validate that ansible user has authorized_keys"""
opt_ansible_authorized_keys = host.file("/opt/ansible/.ssh/authorized_keys")
assert opt_ansible_authorized_keys.exists
assert opt_ansible_authorized_keys.user == "ansible"
assert opt_ansible_authorized_keys.group == "ansible"
assert opt_ansible_authorized_keys.mode == 0o600
assert opt_ansible_authorized_keys.contains("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIClfmTk73wNNL2jwvhRUmUuy80JRrz3P7cEgXUqlc5O9 ansible@instance")