From d7f5d14b51c4d28bd7f4deb8e36bb17c5295c2a9 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Mon, 17 Jul 2023 23:20:40 +0200 Subject: [PATCH] remove python tests --- molecule/default/tests/conftest.py | 22 ------------ molecule/default/tests/test_default.py | 28 --------------- molecule/with_ssh_keys/tests/conftest.py | 22 ------------ molecule/with_ssh_keys/tests/test_default.py | 36 -------------------- 4 files changed, 108 deletions(-) delete mode 100644 molecule/default/tests/conftest.py delete mode 100644 molecule/default/tests/test_default.py delete mode 100644 molecule/with_ssh_keys/tests/conftest.py delete mode 100644 molecule/with_ssh_keys/tests/test_default.py diff --git a/molecule/default/tests/conftest.py b/molecule/default/tests/conftest.py deleted file mode 100644 index a11928c..0000000 --- a/molecule/default/tests/conftest.py +++ /dev/null @@ -1,22 +0,0 @@ -"""PyTest Fixtures.""" - -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 6920d95..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_ubuntu_user_group(host): - """Validate ubuntu user and group.""" - ubuntu_group = host.group("ubuntu") - ubuntu_user = host.user("ubuntu") - assert ubuntu_group.exists - assert ubuntu_user.exists - assert ubuntu_user.group == "ubuntu" - assert ubuntu_user.shell == "/bin/bash" - -def test_ubuntu_sudoer(host): - """Validate that ubuntu user is not sudoer""" - etc_sudoers_d_ubuntu = host.file("/etc/sudoers.d/ubuntu") - assert not etc_sudoers_d_ubuntu.exists - -def test_ubuntu_no_ssh(host): - """Validate that ubuntu user has no authorized_keys""" - opt_ubuntu_authorized_keys = host.file("/home/ubuntu/.ssh/authorized_keys") - assert not opt_ubuntu_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 6041e58..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_ubuntu_user_group(host): - """Validate ubuntu user and group.""" - ubuntu_group = host.group("ubuntu") - ubuntu_user = host.user("ubuntu") - assert ubuntu_group.exists - assert ubuntu_user.exists - assert ubuntu_user.group == "ubuntu" - assert ubuntu_user.shell == "/bin/bash" - -def test_ubuntu_sudoer(host): - """Validate that ubuntu user is sudoer""" - etc_sudoers_d_ubuntu = host.file("/etc/sudoers.d/ubuntu") - assert etc_sudoers_d_ubuntu.exists - assert etc_sudoers_d_ubuntu.user == "root" - assert etc_sudoers_d_ubuntu.group == "root" - assert etc_sudoers_d_ubuntu.mode == 0o440 - assert etc_sudoers_d_ubuntu.contains("ubuntu ALL=NOPASSWD:SETENV: ALL") - -def test_ubuntu_ssh_authorized_keys(host): - """Validate that ubuntu user has authorized_keys""" - opt_ubuntu_authorized_keys = host.file("/home/ubuntu/.ssh/authorized_keys") - assert opt_ubuntu_authorized_keys.exists - assert opt_ubuntu_authorized_keys.user == "ubuntu" - assert opt_ubuntu_authorized_keys.group == "ubuntu" - assert opt_ubuntu_authorized_keys.mode == 0o600 - assert opt_ubuntu_authorized_keys.contains("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIClfmTk73wNNL2jwvhRUmUuy80JRrz3P7cEgXUqlc5O9 ubuntu@instance")