timeout_test.py (1800B)
1 #!/usr/bin/python3 2 3 import unittest 4 import sys 5 6 sys.path.append('../util') 7 import iwd 8 from iwd import IWD 9 from iwd import NetworkType 10 import testutil 11 12 import hostapd 13 from hwsim import Hwsim 14 15 class Test(unittest.TestCase): 16 17 def test_connection_success(self): 18 hwsim = Hwsim() 19 20 bss_radio0 = hwsim.get_radio('rad0') 21 bss_radio1 = hwsim.get_radio('rad1') 22 23 self.assertIsNotNone(bss_radio0) 24 25 wd = IWD() 26 27 devices = wd.list_devices(1) 28 device = devices[0] 29 30 ordered_network = device.get_ordered_network('ssidOWE') 31 32 self.assertEqual(ordered_network.type, NetworkType.open) 33 34 condition = 'not obj.connected' 35 wd.wait_for_object_condition(ordered_network.network_object, condition) 36 37 rule0 = hwsim.rules.create() 38 rule0.source = bss_radio0.addresses[0] 39 rule0.bidirectional = True 40 rule0.drop = True 41 rule0.prefix = 'b0' 42 rule0.enabled = True 43 44 rule1 = hwsim.rules.create() 45 rule1.source = bss_radio1.addresses[0] 46 rule1.bidirectional = True 47 rule1.drop = True 48 rule1.prefix = 'b0' 49 rule1.enabled = True 50 51 # Test Authenticate (b0) and Association (00) timeouts 52 53 with self.assertRaises(iwd.FailedEx): 54 ordered_network.network_object.connect() 55 56 rule0.prefix = '00' 57 rule1.prefix = '00' 58 59 with self.assertRaises(iwd.FailedEx): 60 ordered_network.network_object.connect() 61 62 def tearDown(self): 63 hwsim = Hwsim() 64 for rule in list(hwsim.rules.keys()): 65 del hwsim.rules[rule] 66 67 @classmethod 68 def setUpClass(cls): 69 pass 70 71 @classmethod 72 def tearDownClass(cls): 73 IWD.clear_storage() 74 75 if __name__ == '__main__': 76 unittest.main(exit=True)