Changeset - d31ae08379b3
[Not reviewed]
0 3 0
Branko Majic (branko) - 3 months ago 2025-01-22 00:11:28
branko@majic.rs
MAR-233: Replace hping3 with nmap in mail_forwarder connectivity tests.
3 files changed with 11 insertions and 10 deletions:
0 comments (0 inline, 0 general) First comment
roles/mail_forwarder/molecule/default/prepare.yml
Show inline comments
 
@@ -77,13 +77,13 @@
 
      ansible.builtin.apt:
 
        name: swaks
 
        state: present
 

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

	
 
    - name: Deploy CA certificate
 
      ansible.builtin.copy:
 
        src: tests/data/x509/ca/level1.cert.pem
 
        dest: /usr/local/share/ca-certificates/testca.crt
 
@@ -146,13 +146,13 @@
 
        mode: "0644"
 
      notify:
 
        - Restart Postfix
 

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

	
 
    - name: Install SWAKS for testing SMTP capability
 
      ansible.builtin.apt:
 
        name: swaks
 
        state: present
roles/mail_forwarder/molecule/default/tests/test_connectivity_from_client.py
Show inline comments
 
@@ -20,9 +20,9 @@ def test_connectivity_from_client(host, server):
 
    Tests connectivity towards mail forwarder servers from client
 
    (non-relay). Connectivity should fail for both.
 
    """
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 25 -c 1 %s', server)
 
        assert ping.rc != 0
 
        assert "100% packet loss" in ping.stderr
 
        scan = host.run('nmap -4 -p 25 -oG - %s', server)
 
        assert scan.rc == 0
 
        assert "Ports: 25/filtered/tcp//smtp/" in scan.stdout
roles/mail_forwarder/molecule/default/tests/test_connectivity_from_relay.py
Show inline comments
 
@@ -18,14 +18,15 @@ def test_connectivity_from_authorised_relay(host, server):
 
    Tests connectivity towards mail forwarder servers from authorised
 
    relay.
 
    """
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 25 -c 1 %s', server)
 
        assert ping.rc == 0
 
        scan = host.run('nmap -p 25 -oG - %s', server)
 
        assert scan.rc == 0
 
        assert "Ports: 25/open/tcp//smtp/" in scan.stdout
 

	
 

	
 
@pytest.mark.parametrize("server",
 
                         sorted(
 
                             set(ansible_runner.get_hosts('parameters-mandatory')) |
 
                             set(ansible_runner.get_hosts('parameters-no-incoming'))))
 
@@ -34,15 +35,15 @@ def test_connectivity_from_unauthorised_relay(host, server):
 
    Tests connectivity towards mail forwarder servers from unauthorised
 
    relay.
 
    """
 

	
 
    with host.sudo():
 

	
 
        ping = host.run('hping3 -S -p 25 -c 1 %s', server)
 
        assert ping.rc != 0
 
        assert "100% packet loss" in ping.stderr
 
        scan = host.run('nmap -p 25 -oG - %s', server)
 
        assert scan.rc == 0
 
        assert "Ports: 25/filtered/tcp//smtp/" in scan.stdout
 

	
 

	
 
@pytest.mark.parametrize("server",
 
                         ansible_runner.get_hosts('parameters-optional'))
 
def test_mail_reception_from_authorised_relay(host, server):
 
    """
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now