Beispiel #1
0
 def test_get_nonblank_connections(self):
     """Tests that NULL addresses in procfs are removed."""
     monitor = ConnectionMonitor()
     ip = []
     for item in monitor._get_nonblank_connections(monitor._get_tcp()):
         ip.append(item['rem_address'][0])
     self.assertNotIn('0.0.0.0',ip)
Beispiel #2
0
 def test_clean_connections(self):
     """Tests the ability to remove useless data."""
     monitor = ConnectionMonitor()
     conn = monitor._get_nonblank_connections(monitor._get_tcp())
     conn = monitor._clean_connections(conn, 'tcp')
     self.assertEqual(len(conn[0]),9)
     self.assertEqual('local_address' in conn[0], True)
     self.assertEqual('local_port' in conn[0], True)
     self.assertEqual('rem_address' in conn[0], True)
     self.assertEqual('rem_port' in conn[0], True)
     self.assertEqual('domain' in conn[0], True)
     self.assertEqual('name' in conn[0], True)
     self.assertEqual('transport_layer' in conn[0], True)
     self.assertEqual('time_established' in conn[0], True)
     self.assertEqual('time_connected' in conn[0], True)
Beispiel #3
0
 def test_get_tcp(self):
     """Tests that procfs can get tcp connections"""
     monitor = ConnectionMonitor()
     self.assertIn('rem_address',monitor._get_tcp()[0])