Changeset - 76debadf4dae
[Not reviewed]
0 3 0
Branko Majic (branko) - 2 months ago 2024-02-17 13:36:59
branko@majic.rs
MAR-194: Switch to using nmap for testing connectivity in common role:

- Unfortunately, hping3 does not support IPv6.
3 files changed with 21 insertions and 16 deletions:
0 comments (0 inline, 0 general)
roles/common/molecule/default/prepare.yml
Show inline comments
 
@@ -57,7 +57,7 @@
 

	
 
    - name: Install tool for testing TCP connectivity
 
      apt:
 
        name: hping3
 
        name: nmap
 
        state: present
 

	
 
    - name: Set-up /etc/hosts with entries for all servers
 
@@ -77,11 +77,6 @@
 
  become: true
 
  tasks:
 

	
 
    - name: Install tool for testing TCP connectivity
 
      apt:
 
        name: hping3
 
        state: present
 

	
 
    - name: Set-up /etc/hosts with entries for all servers
 
      lineinfile:
 
        path: /etc/hosts
roles/common/molecule/default/tests/test_maintenance_from_allowed_client.py
Show inline comments
 
@@ -23,8 +23,10 @@ def test_ssh_connectivity(host, target_host):
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 22 -c 1 %s', target_host)
 
        assert ping.rc == 0
 
        scan = host.run('nmap -p 22 -oG - %s', target_host)
 

	
 
        assert scan.rc == 0
 
        assert "Ports: 22/open/tcp//ssh" in scan.stdout
 

	
 

	
 
@pytest.mark.parametrize("target_host", parameters_mandatory_hosts + parameters_optional_hosts)
 
@@ -35,5 +37,7 @@ def test_http_connectivity(host, target_host):
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 80 -c 1 %s', target_host)
 
        assert ping.rc == 0
 
        scan = host.run('nmap -p 80 -oG - %s', target_host)
 

	
 
        assert scan.rc == 0
 
        assert "Ports: 80/open/tcp//http" in scan.stdout
roles/common/molecule/default/tests/test_maintenance_from_disallowed_client.py
Show inline comments
 
@@ -23,8 +23,10 @@ def test_ssh_connectivity(host, target_host):
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 22 -c 1 %s', '%s' % target_host)
 
        assert ping.rc == 0
 
        scan = host.run('nmap -p 22 -oG - %s', target_host)
 

	
 
        assert scan.rc == 0
 
        assert "Ports: 22/open/tcp//ssh" in scan.stdout
 

	
 

	
 
@pytest.mark.parametrize("target_host", parameters_mandatory_hosts)
 
@@ -35,8 +37,10 @@ def test_http_connectivity_allowed(host, target_host):
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 80 -c 1 %s', target_host)
 
        assert ping.rc == 0
 
        scan = host.run('nmap -p 80 -oG - %s', target_host)
 

	
 
        assert scan.rc == 0
 
        assert "Ports: 80/open/tcp//http" in scan.stdout
 

	
 

	
 
@pytest.mark.parametrize("target_host", parameters_optional_hosts)
 
@@ -47,5 +51,7 @@ def test_http_connectivity_disallowed(host, target_host):
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 80 -c 1 %s', target_host)
 
        assert ping.rc == 1
 
        scan = host.run('nmap -p 80 -oG - %s', target_host)
 

	
 
        assert scan.rc == 0
 
        assert "Ports: 80/filtered/tcp//http" in scan.stdout
0 comments (0 inline, 0 general)