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


      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_preauth_success(self):
     14         bss_hostapd = [ HostapdCLI(config='eaptls-preauth-1.conf'),
     15                         HostapdCLI(config='eaptls-preauth-2.conf') ]
     16 
     17         bss0_addr = bss_hostapd[0].bssid
     18         bss1_addr = bss_hostapd[1].bssid
     19 
     20         HostapdCLI.group_neighbors(*bss_hostapd)
     21 
     22         wd = IWD(True)
     23 
     24         device = wd.list_devices(1)[0]
     25 
     26         ordered_network = device.get_ordered_network('TestPreauth')
     27 
     28         self.assertEqual(ordered_network.type, NetworkType.eap)
     29 
     30         condition = 'not obj.connected'
     31         wd.wait_for_object_condition(ordered_network.network_object, condition)
     32 
     33         self.assertFalse(bss_hostapd[0].list_sta())
     34         self.assertFalse(bss_hostapd[1].list_sta())
     35 
     36         device.connect_bssid(bss0_addr)
     37 
     38         condition = 'obj.state == DeviceState.connected'
     39         wd.wait_for_object_condition(device, condition)
     40 
     41         bss_hostapd[0].wait_for_event('AP-STA-CONNECTED %s' % device.address)
     42         self.assertFalse(bss_hostapd[1].list_sta())
     43 
     44         testutil.test_iface_operstate(device.name)
     45         testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name)
     46         self.assertRaises(Exception, testutil.test_ifaces_connected,
     47                           bss_hostapd[1].ifname, device.name, True, True)
     48 
     49         device.roam(bss1_addr)
     50 
     51         # TODO: verify that the PMK from preauthentication was used
     52 
     53         # Check that iwd is on BSS 1 once out of roaming state and doesn't
     54         # go through 'disconnected', 'autoconnect', 'connecting' in between
     55         from_condition = 'obj.state == DeviceState.roaming'
     56         to_condition = 'obj.state == DeviceState.connected'
     57         wd.wait_for_object_change(device, from_condition, to_condition)
     58 
     59         bss_hostapd[1].wait_for_event('AP-STA-CONNECTED %s' % device.address)
     60 
     61         testutil.test_iface_operstate(device.name)
     62         testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name)
     63         self.assertRaises(Exception, testutil.test_ifaces_connected,
     64                           (bss_hostapd[0].ifname, device.name, True, True))
     65 
     66         device.disconnect()
     67 
     68         condition = 'not obj.connected'
     69         wd.wait_for_object_condition(ordered_network.network_object, condition)
     70 
     71     @classmethod
     72     def setUpClass(cls):
     73         IWD.copy_to_storage('TestPreauth.8021x')
     74 
     75     @classmethod
     76     def tearDownClass(cls):
     77         IWD.clear_storage()
     78 
     79 if __name__ == '__main__':
     80     unittest.main(exit=True)