diff --git a/molecule/default/tests/conftest.py b/molecule/default/tests/conftest.py deleted file mode 100644 index f7ddb3f..0000000 --- a/molecule/default/tests/conftest.py +++ /dev/null @@ -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 - ) diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py deleted file mode 100644 index 1bd5bb7..0000000 --- a/molecule/default/tests/test_default.py +++ /dev/null @@ -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 diff --git a/molecule/with_ssh_keys/tests/conftest.py b/molecule/with_ssh_keys/tests/conftest.py deleted file mode 100644 index f7ddb3f..0000000 --- a/molecule/with_ssh_keys/tests/conftest.py +++ /dev/null @@ -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 - ) diff --git a/molecule/with_ssh_keys/tests/test_default.py b/molecule/with_ssh_keys/tests/test_default.py deleted file mode 100644 index 7b13baa..0000000 --- a/molecule/with_ssh_keys/tests/test_default.py +++ /dev/null @@ -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")