import os
import testinfra.utils.ansible_runner

inventory = os.environ['MOLECULE_INVENTORY_FILE']
ansible_runner = testinfra.utils.ansible_runner.AnsibleRunner(inventory)
testinfra_hosts = ansible_runner.get_hosts('all')


##########
# System #
##########


def test_service(host):
    s = host.service('litecoin')

    assert s.is_enabled
    assert s.is_running


###########
# Private #
###########


def test_configuration_file(host):
    f = host.file('/etc/litecoin/litecoin.conf')

    assert f.exists
    assert f.is_file
    assert f.user == 'litecoin'
Esempio n. 2
0
 def get_hosts(cls, host, **kwargs):
     return ansible_runner.get_hosts(kwargs.get("ansible_inventory"), host)
Esempio n. 3
0
 def get_hosts(cls, host, **kwargs):
     return ansible_runner.get_hosts(kwargs.get("ansible_inventory"), host)
Esempio n. 4
0
def get_testinfra_hosts():
    ansible_runner = testinfra.utils.ansible_runner.AnsibleRunner(
        os.environ['MOLECULE_INVENTORY_FILE']
    )
    return ansible_runner.get_hosts('all')
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
import json
import os
from typing import Dict

from testinfra.backend.base import CommandResult
from testinfra.host import Host
import testinfra.utils.ansible_runner
from ansible_collections.io_patricecongo.spire.plugins.module_utils.systemd import Scope

from molecule_helpers.host_utils import HostFuncsAdapter

ansible_runner = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ["MOLECULE_INVENTORY_FILE"])
testinfra_hosts = ansible_runner.get_hosts("spire_server")

from ansible_collections.io_patricecongo.spire.plugins.module_utils import (
    spire_server_info_cmd, )

import test_data


def test_server_created(host: Host) -> None:
    host_funcs = HostFuncsAdapter(host=host, user_name="spire")
    print(f"Test Infra Host: {host} -- {host_funcs}")
    server_dirs = spire_server_info_cmd.ServerDirs(
        config_dir="/home/spire/spire-server/conf",
        data_dir="/home/spire/spire-server/data",
        install_dir="/home/spire/spire-server/",
        service_dir="/home/spire/.config/systemd/user/",
Esempio n. 6
0
import json
import os
import shutil
import tempfile
from typing import Dict, Generator

import pytest
from testinfra.backend.base import CommandResult
from testinfra.host import Host
import testinfra.utils.ansible_runner

from molecule_helpers.host_utils import HostFuncsAdapter

ansible_runner = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ["MOLECULE_INVENTORY_FILE"])
testinfra_hosts = ansible_runner.get_hosts("spire_agent")

from ansible_collections.io_patricecongo.spire.plugins.module_utils import (
    spire_server_entry_cmd, )
from ansible_collections.io_patricecongo.spire.plugins.module_utils.spire_agent_info_cmd import (
    AgentDirs,
    SpireAgentInfo,
)

import test_data


@pytest.fixture
def agent_data_dir_local() -> Generator[str, None, None]:
    data_dir_local = tempfile.mkdtemp(prefix="spire-agent-data-dir-local")
    try: