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


      1 #! /usr/bin/python3
      2 
      3 import unittest
      4 import os
      5 
      6 from iwd import IWD
      7 from config import ctx
      8 from validation import validate, client_connect
      9 
     10 class Test(unittest.TestCase):
     11     def test_connection_success(self):
     12         IWD.copy_to_storage('TestAP1.psk')
     13 
     14         wd = IWD(True)
     15 
     16         dev1, dev2 = wd.list_devices(2)
     17 
     18         client_connect(wd, dev1, 'TestAP1')
     19 
     20         dev1.start_ap('TestAP2', 'Password2')
     21 
     22         validate(wd, dev2, dev1, 'TestAP2', 'Password2')
     23 
     24         # Finally test dev1 can go to client mode and connect again
     25         client_connect(wd, dev1, 'TestAP1')
     26 
     27     def test_client_start_ap(self):
     28         IWD.copy_to_storage('TestAP1.psk')
     29 
     30         wd = IWD(True)
     31 
     32         dev1, dev2 = wd.list_devices(2)
     33 
     34         ctx.start_process(['iwctl', 'device', dev1.name, 'set-property', 'Mode', 'ap'], check=True)
     35         ctx.start_process(['iwctl', 'ap', dev1.name, 'start', 'TestAP2', 'Password2'], check=True)
     36 
     37         iwctl = ctx.start_process(['iwctl', 'ap', 'list'], check=True)
     38 
     39         self.assertIn(dev1.name, iwctl.out)
     40 
     41         iwctl = ctx.start_process(['iwctl', 'ap', dev1.name, 'show'], check=True)
     42 
     43         self.assertIn('TestAP2', iwctl.out)
     44 
     45         validate(wd, dev2, dev1, 'TestAP2', 'Password2')
     46 
     47     def test_valid_ciphers(self):
     48         ciphers = ['TKIP', 'CCMP-128', 'GCMP-128', 'CCMP-256', 'GCMP-256']
     49 
     50         for group in ciphers:
     51             for pairwise in ciphers:
     52                 IWD.copy_to_ap('TestAP2.ap')
     53                 os.system('echo "PairwiseCiphers=%s" >> /tmp/iwd/ap/TestAP2.ap' % pairwise)
     54                 os.system('echo "GroupCipher=%s" >> /tmp/iwd/ap/TestAP2.ap' % group)
     55 
     56                 wd = IWD(True)
     57 
     58                 dev1, dev2 = wd.list_devices(2)
     59 
     60                 dev1.start_ap('TestAP2')
     61 
     62                 self.assertTrue(dev1.group_cipher == group)
     63                 self.assertIn(pairwise, dev1.pairwise_ciphers)
     64 
     65                 try:
     66                     validate(wd, dev2, dev1, 'TestAP2', 'Password2', ip_checks=False)
     67                 except:
     68                     raise Exception("Failed with pairwise=%s group=%s" % (pairwise, group))
     69                 finally:
     70                     IWD.clear_storage()
     71                     del wd
     72 
     73     def tearDown(self):
     74         IWD.clear_storage()
     75 
     76 if __name__ == '__main__':
     77     unittest.main(exit=True)