eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

connection_test.py (2245B)


      1 #!/usr/bin/python3
      2 
      3 import unittest
      4 import sys
      5 import os
      6 
      7 sys.path.append('../util')
      8 import iwd
      9 from iwd import IWD
     10 from iwd import NetworkType
     11 import testutil
     12 
     13 class Test(unittest.TestCase):
     14     def try_connection(self, wd):
     15         devices = wd.list_devices(1)
     16         device = devices[0]
     17 
     18         ordered_network = device.get_ordered_network('ssidCCMP')
     19 
     20         self.assertEqual(ordered_network.type, NetworkType.psk)
     21 
     22         condition = 'not obj.connected'
     23         wd.wait_for_object_condition(ordered_network.network_object, condition)
     24 
     25         ordered_network.network_object.connect()
     26 
     27         condition = 'obj.state == DeviceState.connected'
     28         wd.wait_for_object_condition(device, condition)
     29 
     30         testutil.test_iface_operstate()
     31         testutil.test_ifaces_connected()
     32 
     33         device.disconnect()
     34 
     35         condition = 'not obj.connected'
     36         wd.wait_for_object_condition(ordered_network.network_object, condition)
     37 
     38         return device.address
     39 
     40     def test_connection_success(self):
     41         wd = IWD()
     42 
     43         devices = wd.list_devices(1)
     44         device = devices[0]
     45 
     46         perm_addr = device.address
     47 
     48         # 1. Test per-network deterministic MAC generation
     49         IWD.copy_to_storage('pernetwork.psk', name='ssidCCMP.psk')
     50         new_addr = self.try_connection(wd)
     51         self.assertNotEqual(perm_addr, new_addr)
     52         # try again to ensure the generation was deterministic
     53         new_addr2 = self.try_connection(wd)
     54         self.assertEqual(new_addr, new_addr2)
     55 
     56         # 2. Test FullAddressRandomization
     57         IWD.copy_to_storage('full_random.psk', name='ssidCCMP.psk')
     58         new_addr = self.try_connection(wd)
     59         self.assertNotEqual(perm_addr, new_addr)
     60         # try again to make sure the generation was random
     61         new_addr2 = self.try_connection(wd)
     62         self.assertNotEqual(new_addr, new_addr2)
     63 
     64         # 3. Test AddressOverride
     65         IWD.copy_to_storage('override.psk', name='ssidCCMP.psk')
     66         new_addr = self.try_connection(wd)
     67         self.assertEqual(new_addr, 'e6:f6:38:a9:02:02')
     68 
     69     @classmethod
     70     def setUpClass(cls):
     71         pass
     72 
     73     @classmethod
     74     def tearDownClass(cls):
     75         IWD.clear_storage()
     76 
     77 if __name__ == '__main__':
     78     unittest.main(exit=True)