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


      1 #! /usr/bin/python3
      2 
      3 import unittest
      4 import sys, os
      5 
      6 sys.path.append('../util')
      7 from iwd import IWD
      8 from iwd import NetworkType
      9 from hostapd import HostapdCLI
     10 import testutil
     11 
     12 class Test(unittest.TestCase):
     13     def test_roam_success(self):
     14         wd = IWD(True)
     15 
     16         device = wd.list_devices(1)[0]
     17 
     18         ordered_network = device.get_ordered_network('TestFT')
     19 
     20         self.assertEqual(ordered_network.type, NetworkType.eap)
     21 
     22         self.assertFalse(self.bss_hostapd[0].list_sta())
     23         self.assertFalse(self.bss_hostapd[1].list_sta())
     24 
     25         device.connect_bssid(self.bss_hostapd[0].bssid)
     26 
     27         condition = 'obj.state == DeviceState.connected'
     28         wd.wait_for_object_condition(device, condition)
     29 
     30         self.bss_hostapd[0].wait_for_event('AP-STA-CONNECTED %s' % device.address)
     31         self.assertFalse(self.bss_hostapd[1].list_sta())
     32 
     33         testutil.test_iface_operstate(device.name)
     34         testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name)
     35         self.assertRaises(Exception, testutil.test_ifaces_connected,
     36                           (self.bss_hostapd[1].ifname, device.name, True, True))
     37 
     38         device.roam(self.bss_hostapd[1].bssid)
     39 
     40         # Check that iwd is on BSS 1 once out of roaming state and doesn't
     41         # go through 'disconnected', 'autoconnect', 'connecting' in between
     42         from_condition = 'obj.state == DeviceState.roaming'
     43         to_condition = 'obj.state == DeviceState.connected'
     44         wd.wait_for_object_change(device, from_condition, to_condition)
     45 
     46         self.bss_hostapd[1].wait_for_event('AP-STA-CONNECTED %s' % device.address)
     47 
     48         testutil.test_iface_operstate(device.name)
     49         testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name)
     50         self.assertRaises(Exception, testutil.test_ifaces_connected,
     51                           (self.bss_hostapd[0].ifname, device.name, True, True))
     52 
     53     def tearDown(self):
     54         os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
     55         os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
     56         os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
     57         os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
     58 
     59     @classmethod
     60     def setUpClass(cls):
     61         IWD.copy_to_storage('TestFT.8021x')
     62 
     63         cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
     64                             HostapdCLI(config='ft-eap-ccmp-2.conf') ]
     65 
     66         cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
     67         cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
     68 
     69         HostapdCLI.group_neighbors(*cls.bss_hostapd)
     70 
     71     @classmethod
     72     def tearDownClass(cls):
     73         IWD.clear_storage()
     74         cls.bss_hostapd = None
     75 
     76 if __name__ == '__main__':
     77     unittest.main(exit=True)