Пример #1
0
def test_netstat():
    """
    Test if it return information on open ports and states
    """
    ret = ("  Proto  Local Address    Foreign Address    State    PID\n"
           "  TCP    127.0.0.1:1434    0.0.0.0:0    LISTENING    1728\n"
           "  UDP    127.0.0.1:1900    *:*        4240")
    mock = MagicMock(return_value=ret)
    with patch.dict(win_network.__salt__, {"cmd.run": mock}):
        assert win_network.netstat() == [
            {
                "local-address": "127.0.0.1:1434",
                "program": "1728",
                "proto": "TCP",
                "remote-address": "0.0.0.0:0",
                "state": "LISTENING",
            },
            {
                "local-address": "127.0.0.1:1900",
                "program": "4240",
                "proto": "UDP",
                "remote-address": "*:*",
                "state": None,
            },
        ]
Пример #2
0
 def test_netstat(self):
     '''
     Test if it return information on open ports and states
     '''
     ret = ('  Proto  Local Address    Foreign Address    State    PID\n'
            '  TCP    127.0.0.1:1434    0.0.0.0:0    LISTENING    1728\n'
            '  UDP    127.0.0.1:1900    *:*        4240')
     mock = MagicMock(return_value=ret)
     with patch.dict(win_network.__salt__, {'cmd.run': mock}):
         self.assertListEqual(win_network.netstat(),
                              [{'local-address': '127.0.0.1:1434',
                                'program': '1728', 'proto': 'TCP',
                                'remote-address': '0.0.0.0:0',
                                'state': 'LISTENING'},
                               {'local-address': '127.0.0.1:1900',
                                'program': '4240', 'proto': 'UDP',
                                'remote-address': '*:*', 'state': None}])
Пример #3
0
 def test_netstat(self):
     '''
     Test if it return information on open ports and states
     '''
     ret = ('  Proto  Local Address    Foreign Address    State    PID\n'
            '  TCP    127.0.0.1:1434    0.0.0.0:0    LISTENING    1728\n'
            '  UDP    127.0.0.1:1900    *:*        4240')
     mock = MagicMock(return_value=ret)
     with patch.dict(win_network.__salt__, {'cmd.run': mock}):
         self.assertListEqual(win_network.netstat(),
                              [{'local-address': '127.0.0.1:1434',
                                'program': '1728', 'proto': 'TCP',
                                'remote-address': '0.0.0.0:0',
                                'state': 'LISTENING'},
                               {'local-address': '127.0.0.1:1900',
                                'program': '4240', 'proto': 'UDP',
                                'remote-address': '*:*', 'state': None}])