Files @ e8fe43bf880e
Branch filter:

Location: majic-ansible-roles/roles/web_server/molecule/default/tests/test_client.py

branko
MAR-233: Add IPv6 connectivity tests for the web_server role.
import os

import pytest

import testinfra.utils.ansible_runner


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


@pytest.mark.parametrize('server', testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-*')
)
@pytest.mark.parametrize('port', [80, 443])
@pytest.mark.parametrize('ip_protocol', [4, 6])
def test_connectivity(host, server, port, ip_protocol):
    """
    Tests connectivity to the web server (ports that should be reachable).
    """

    with host.sudo():

        scan = host.run('nmap -%s -p %s -oG - %s', str(ip_protocol), str(port), server)
        assert scan.rc == 0
        assert "Ports: %d/open/tcp//" % port in scan.stdout