eiwd

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

default_group_test.py (3129B)


      1 #!/usr/bin/python3
      2 
      3 import unittest
      4 import sys
      5 import os
      6 sys.path.append('../util')
      7 import iwd
      8 from iwd import IWD
      9 from iwd import PSKAgent
     10 from iwd import NetworkType
     11 from hostapd import HostapdCLI
     12 import testutil
     13 
     14 class Test(unittest.TestCase):
     15 
     16     def validate_connection(self, wd, hostapd, rejected=False):
     17         devices = wd.list_devices(1)
     18         self.assertIsNotNone(devices)
     19         device = devices[0]
     20 
     21         device.autoconnect = True
     22 
     23         if rejected:
     24             device.wait_for_event("ecc-group-rejected", timeout=60)
     25 
     26         condition = 'obj.state == DeviceState.connected'
     27         wd.wait_for_object_condition(device, condition)
     28 
     29         wd.wait(2)
     30 
     31         testutil.test_iface_operstate(intf=device.name)
     32         testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname)
     33 
     34         if not rejected:
     35             self.assertEqual(device.event_ocurred("ecc-group-rejected"), False)
     36 
     37         print(hostapd._get_status())
     38 
     39         sta_status = hostapd.sta_status(device.address)
     40 
     41         print(sta_status)
     42 
     43         self.assertEqual(int(sta_status["sae_group"]), 19)
     44 
     45         device.disconnect()
     46 
     47     # IWD should:
     48     #   - Connect, fail with group 20
     49     #   - Retry, succeed with group 19
     50     #   - Disconnect
     51     #   - Connect, try only group 19
     52     def test_auto_selection(self):
     53         IWD.copy_to_storage("profiles/ssidSAE.psk.default", name="ssidSAE.psk")
     54         self.validate_connection(self.wd, self.hostapd, rejected=True)
     55 
     56         self.validate_connection(self.wd, self.hostapd, rejected=False)
     57 
     58     # Try group 19 first
     59     def test_default_group_enabled(self):
     60         IWD.copy_to_storage("profiles/ssidSAE.psk.default_group", name="ssidSAE.psk")
     61         self.validate_connection(self.wd, self.hostapd)
     62 
     63     # Try group 19 first, with H2E
     64     def test_default_group_enabled_h2e(self):
     65         IWD.copy_to_storage("profiles/ssidSAE-H2E.psk.default_group", name="ssidSAE-H2E.psk")
     66         self.validate_connection(self.wd, self.hostapd_h2e)
     67 
     68     # Same as auto-selection but won't retain the default group setting
     69     def test_default_group_disabled(self):
     70         IWD.copy_to_storage("profiles/ssidSAE.psk.most_secure", name="ssidSAE.psk")
     71         self.validate_connection(self.wd, self.hostapd, rejected=True)
     72 
     73         # IWD should then retry but use only group 19
     74         self.validate_connection(self.wd, self.hostapd, rejected=True)
     75 
     76     def setUp(self):
     77         self.hostapd.default()
     78         self.hostapd.set_value('sae_groups', '19')
     79         self.hostapd.set_value('sae_pwe', '0')
     80         self.hostapd.reload()
     81         self.hostapd.wait_for_event("AP-ENABLED")
     82         self.wd = IWD(True)
     83 
     84         self.wd.clear_storage()
     85         os.system("ls /tmp/iwd")
     86 
     87     def tearDown(self):
     88         self.wd.clear_storage()
     89         self.wd = None
     90 
     91     @classmethod
     92     def setUpClass(cls):
     93         cls.hostapd = HostapdCLI(config='ssidSAE.conf')
     94         cls.hostapd.default()
     95 
     96         cls.hostapd_h2e = HostapdCLI(config='ssidSAE-H2E.conf')
     97         cls.hostapd_h2e.default()
     98 
     99     @classmethod
    100     def tearDownClass(cls):
    101         pass
    102 
    103 if __name__ == '__main__':
    104     unittest.main(exit=True)