eiwd

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

timeout_test.py (2518B)


      1 import unittest
      2 import sys
      3 import os
      4 
      5 sys.path.append('../util')
      6 from iwd import IWD
      7 from iwd import PSKAgent
      8 from iwd import NetworkType
      9 
     10 class Test(unittest.TestCase):
     11     def connect_failure(self, ex):
     12         self.failure_triggered = True
     13 
     14     def test_netconfig_timeout(self):
     15         IWD.copy_to_storage('autoconnect.psk', name='ap-ns1.psk')
     16 
     17         wd = IWD(True)
     18 
     19         psk_agent = PSKAgent("secret123")
     20         wd.register_psk_agent(psk_agent)
     21 
     22         devices = wd.list_devices(1)
     23         device = devices[0]
     24 
     25         ordered_network = device.get_ordered_network('ap-ns1')
     26 
     27         self.assertEqual(ordered_network.type, NetworkType.psk)
     28 
     29         condition = 'not obj.connected'
     30         wd.wait_for_object_condition(ordered_network.network_object, condition)
     31 
     32         self.failure_triggered = False
     33 
     34         # Set our error handler here so we can check if it fails
     35         ordered_network.network_object.connect(
     36             wait=False,
     37             timeout=1000,
     38             error_handler=self.connect_failure
     39         )
     40 
     41         # IWD should attempt to try both BSS's with both failing netconfig.
     42         # Then the autoconnect list should be exhausted, and IWD should
     43         # transition to a disconnected state, then proceed to full autoconnect.
     44         device.wait_for_event("netconfig-failed", timeout=1000)
     45         device.wait_for_event("netconfig-failed", timeout=1000)
     46         device.wait_for_event("disconnected")
     47 
     48         device.wait_for_event("autoconnect_full")
     49 
     50         # The connect call should have failed
     51         self.assertTrue(self.failure_triggered)
     52 
     53         condition = "obj.scanning"
     54         wd.wait_for_object_condition(device, condition)
     55         condition = "not obj.scanning"
     56         wd.wait_for_object_condition(device, condition)
     57 
     58         # IWD should attempt to connect, but it will of course fail again.
     59         device.wait_for_event("netconfig-failed", timeout=1000)
     60 
     61         device.disconnect()
     62         condition = 'obj.state == DeviceState.disconnected'
     63         wd.wait_for_object_condition(device, condition)
     64 
     65     @classmethod
     66     def setUpClass(cls):
     67         cls.orig_path = os.environ['PATH']
     68         os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH']
     69         IWD.copy_to_storage('resolvconf', '/tmp/test-bin')
     70 
     71     @classmethod
     72     def tearDownClass(cls):
     73         IWD.clear_storage()
     74         os.system('rm -rf /tmp/radvd.conf /tmp/resolvconf.log /tmp/test-bin')
     75         os.environ['PATH'] = cls.orig_path
     76 
     77 if __name__ == '__main__':
     78     unittest.main(exit=True)