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 (2793B)


      1 #!/usr/bin/python3
      2 
      3 import unittest
      4 import sys
      5 import os
      6 
      7 sys.path.append('../util')
      8 from iwd import IWD_CONFIG_DIR
      9 from iwd import IWD
     10 from iwd import PSKAgent
     11 from iwd import NetworkType
     12 from hwsim import Hwsim
     13 from hostapd import HostapdCLI
     14 import testutil
     15 
     16 class Test(unittest.TestCase):
     17     def validate(self, wd, resend_m3=False):
     18         hapd = HostapdCLI('ssidCCMP.conf')
     19 
     20         psk_agent = PSKAgent("secret123")
     21         wd.register_psk_agent(psk_agent)
     22 
     23         devices = wd.list_devices(1)
     24         device = devices[0]
     25 
     26         ordered_network = device.get_ordered_network('ssidCCMP')
     27 
     28         self.assertEqual(ordered_network.type, NetworkType.psk)
     29 
     30         condition = 'not obj.connected'
     31         wd.wait_for_object_condition(ordered_network.network_object, condition)
     32 
     33         ordered_network.network_object.connect()
     34 
     35         condition = 'obj.state == DeviceState.connected'
     36         wd.wait_for_object_condition(device, condition)
     37 
     38         testutil.test_iface_operstate()
     39         testutil.test_ifaces_connected()
     40 
     41 
     42         # Rekey 5 times just to make sure the key ID can be toggled back and
     43         # forth without causing problems.
     44         for i in range(5):
     45             hapd.rekey(device.address)
     46 
     47             if resend_m3:
     48                 hapd.resend_m3(device.address)
     49 
     50             testutil.test_iface_operstate()
     51             testutil.test_ifaces_connected()
     52 
     53         device.disconnect()
     54 
     55         condition = 'not obj.connected'
     56         wd.wait_for_object_condition(ordered_network.network_object, condition)
     57 
     58         wd.unregister_psk_agent(psk_agent)
     59 
     60     def test_ext_key_control_port(self):
     61         self.hapd.set_value('extended_key_id', '1')
     62         self.hapd.reload()
     63 
     64         self.wd = IWD(True)
     65 
     66         self.validate(self.wd)
     67 
     68     def test_ext_key_control_port_retransmit(self):
     69         self.hapd.set_value('extended_key_id', '1')
     70         self.hapd.reload()
     71 
     72         self.wd = IWD(True)
     73 
     74         self.validate(self.wd, resend_m3=True)
     75 
     76     def test_ext_key_index_1(self):
     77         self.hapd.set_value('extended_key_id', '2')
     78         self.hapd.reload()
     79 
     80         self.wd = IWD(True)
     81 
     82         self.validate(self.wd)
     83 
     84     def test_ext_key_pae(self):
     85         self.hapd.set_value('extended_key_id', '1')
     86         self.hapd.reload()
     87 
     88         IWD.copy_to_storage('main_pae.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
     89 
     90         self.wd = IWD(True)
     91 
     92         self.validate(self.wd)
     93 
     94     def tearDown(self):
     95         try:
     96             os.system('rm -rf %s/main.conf' % IWD_CONFIG_DIR)
     97         except:
     98             pass
     99 
    100         self.wd = None
    101 
    102     @classmethod
    103     def setUpClass(cls):
    104         cls.hapd = HostapdCLI()
    105 
    106     @classmethod
    107     def tearDownClass(cls):
    108         IWD.clear_storage()
    109         cls.hapd = None
    110 
    111 if __name__ == '__main__':
    112     unittest.main(exit=True)