2018-11-16 23:22:56 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
import iwd
|
|
|
|
from iwd import IWD
|
|
|
|
from iwd import NetworkType
|
2019-05-02 20:27:13 +02:00
|
|
|
from hostapd import HostapdCLI
|
2018-11-16 23:22:56 +01:00
|
|
|
import testutil
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_connection_success(self):
|
2021-08-12 22:21:59 +02:00
|
|
|
hapd = HostapdCLI(config='ssidOWE-1.conf')
|
2019-05-02 20:27:13 +02:00
|
|
|
|
2018-11-16 23:22:56 +01:00
|
|
|
wd = IWD()
|
|
|
|
|
|
|
|
devices = wd.list_devices(1)
|
|
|
|
device = devices[0]
|
|
|
|
|
2021-08-12 22:38:11 +02:00
|
|
|
device.get_ordered_network('ssidOWE')
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
device.connect_bssid(hapd.bssid)
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
2018-11-16 23:22:56 +01:00
|
|
|
wd.wait_for_object_condition(device, condition)
|
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
testutil.test_iface_operstate()
|
|
|
|
testutil.test_ifaces_connected(device.name, hapd.ifname)
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
device.disconnect()
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
def test_reassociate(self):
|
|
|
|
hapd0 = HostapdCLI(config='ssidOWE-1.conf')
|
|
|
|
hapd1 = HostapdCLI(config='ssidOWE-2.conf')
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
wd = IWD()
|
|
|
|
|
|
|
|
devices = wd.list_devices(1)
|
|
|
|
device = devices[0]
|
|
|
|
|
2021-08-12 22:38:11 +02:00
|
|
|
device.get_ordered_network('ssidOWE')
|
2021-08-12 22:21:59 +02:00
|
|
|
|
|
|
|
device.connect_bssid(hapd0.bssid)
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2018-11-16 23:22:56 +01:00
|
|
|
|
|
|
|
testutil.test_iface_operstate()
|
2021-08-12 22:21:59 +02:00
|
|
|
testutil.test_ifaces_connected(device.name, hapd0.ifname)
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
device.roam(hapd1.bssid)
|
|
|
|
|
|
|
|
from_condition = 'obj.state == DeviceState.roaming'
|
|
|
|
to_condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_change(device, from_condition, to_condition)
|
|
|
|
|
2022-03-30 22:23:15 +02:00
|
|
|
hapd1.wait_for_event('AP-STA-CONNECTED %s' % device.address)
|
2018-11-16 23:22:56 +01:00
|
|
|
|
2021-08-12 22:21:59 +02:00
|
|
|
testutil.test_iface_operstate(device.name)
|
|
|
|
testutil.test_ifaces_connected(hapd1.ifname, device.name)
|
|
|
|
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
|
|
|
(hapd0.ifname, device.name, True, True))
|
2018-11-16 23:22:56 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|