Skip to content

test_listening_ports failure on Focal #5635

@kushaldas

Description

@kushaldas

Description

Steps to Reproduce

  • molecule test -s libvirt-staging-focal

Expected Behavior

All tests should pass

Actual Behavior

    __________ test_listening_ports[ansible://mon-staging-ossec_service1] __________                                                                                                                      [126/1908]
    [gw1] linux -- Python 3.7.3 /root/code/securedrop/.venv/bin/python3                                                                                                                                             
                                                                                                                                                                                                                    
    host = <testinfra.host.Host ansible://mon-staging>                                                                                                                                                              
    ossec_service = {'host': '0.0.0.0', 'listening': True, 'port': 1514, 'proto': 'udp'}                                                                                                                            
                                                                                                                                                                                                                    
        @pytest.mark.skip_in_prod                                                                                                                                                                                   
        @pytest.mark.parametrize('ossec_service', [                                                                                                                                                                 
            dict(host="0.0.0.0", proto="tcp", port=22, listening=True),                                                                                                                                             
            dict(host="0.0.0.0", proto="udp", port=1514, listening=True),                                                                                                                                           
            dict(host="0.0.0.0", proto="tcp", port=1515, listening=False),                                                                                                                                          
        ])                                                                                                                                                                                                          
        def test_listening_ports(host, ossec_service):                                                                                                                                                              
            """                                                                                                                                                                                                     
            Ensure the OSSEC-related services are listening on the                                                                                                                                                  
            expected sockets. Services to check include ossec-remoted                                                                                                                                               
            and ossec-authd. Helper services such as postfix are checked                                                                                                                                            
            separately.                                                                                                                                                                                             
                                                                                                                                                                                                                    
            Note that the SSH check will fail if run against a prod host, due                                                                                                                                       
            to the SSH-over-Tor strategy. We can port the parametrized values                                                                                                                                       
            to config test YAML vars at that point.                                                                                                                                                                 
            """                                                                                                                                                                                                     
            socket = "{proto}://{host}:{port}".format(**ossec_service)                                                                                                                                              
            with host.sudo():                                                                                                                                                                                       
                # Really hacky work-around for bug found in testinfra 1.12.0                                                                                                                                        
                # https://github.com/philpep/testinfra/issues/311                                                                                                                                                   
                if "udp" in socket:                                                                                                                                                                                 
                    lsof_socket = "{proto}@{host}:{port}".format(**ossec_service)                                                                                                                                   
                    udp_check = host.run("lsof -n -i"+lsof_socket)                                                                                                                                                  
                                                                                                                                                                                                                    
                    if ossec_service['listening']:                                                                                                                                                                  
    >                   assert udp_check.rc == 0                                                                                                                                                                    
    E                   assert 1 == 0                                                                                                                                                                               
    E                     +1
    E                     -0

    ../testinfra/mon/test_mon_network.py:76: AssertionError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions