2018-03-21 07:15:31 +01:00
|
|
|
#! /usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys, os
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
from iwd import IWD
|
|
|
|
from iwd import NetworkType
|
2020-09-11 01:12:22 +02:00
|
|
|
from hostapd import HostapdCLI
|
2018-03-21 07:15:31 +01:00
|
|
|
import testutil
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
def test_roam_success(self):
|
2021-05-21 18:44:55 +02:00
|
|
|
wd = IWD(True)
|
|
|
|
|
|
|
|
device = wd.list_devices(1)[0]
|
2018-03-21 07:15:31 +01:00
|
|
|
|
2021-08-12 22:38:11 +02:00
|
|
|
ordered_network = device.get_ordered_network('TestFT')
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
self.assertEqual(ordered_network.type, NetworkType.eap)
|
|
|
|
|
|
|
|
self.assertFalse(self.bss_hostapd[0].list_sta())
|
|
|
|
self.assertFalse(self.bss_hostapd[1].list_sta())
|
|
|
|
|
2021-08-12 22:22:00 +02:00
|
|
|
device.connect_bssid(self.bss_hostapd[0].bssid)
|
2018-03-21 07:15:31 +01:00
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
self.assertTrue(self.bss_hostapd[0].list_sta())
|
|
|
|
self.assertFalse(self.bss_hostapd[1].list_sta())
|
|
|
|
|
|
|
|
testutil.test_iface_operstate(device.name)
|
|
|
|
testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name)
|
|
|
|
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
2021-08-12 22:22:00 +02:00
|
|
|
(self.bss_hostapd[1].ifname, device.name, True, True))
|
2018-03-21 07:15:31 +01:00
|
|
|
|
2021-08-12 22:22:00 +02:00
|
|
|
device.roam(self.bss_hostapd[1].bssid)
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
condition = 'obj.state == DeviceState.roaming'
|
2020-09-11 01:12:37 +02:00
|
|
|
wd.wait_for_object_condition(device, condition)
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
# Check that iwd is on BSS 1 once out of roaming state and doesn't
|
|
|
|
# go through 'disconnected', 'autoconnect', 'connecting' in between
|
2021-02-05 20:06:37 +01:00
|
|
|
from_condition = 'obj.state == DeviceState.roaming'
|
|
|
|
to_condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_change(device, from_condition, to_condition)
|
2020-09-14 23:02:33 +02:00
|
|
|
|
2018-03-21 07:15:31 +01:00
|
|
|
self.assertTrue(self.bss_hostapd[1].list_sta())
|
|
|
|
|
|
|
|
testutil.test_iface_operstate(device.name)
|
|
|
|
testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name)
|
|
|
|
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
2021-08-12 22:22:00 +02:00
|
|
|
(self.bss_hostapd[0].ifname, device.name, True, True))
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
|
|
|
|
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down')
|
|
|
|
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up')
|
|
|
|
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
IWD.copy_to_storage('TestFT.8021x')
|
|
|
|
|
2019-06-11 18:25:54 +02:00
|
|
|
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
|
|
|
|
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
# Set interface addresses to those expected by hostapd config files
|
|
|
|
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +
|
|
|
|
'" down hw ether 12:00:00:00:00:01 up')
|
|
|
|
os.system('ifconfig "' + cls.bss_hostapd[1].ifname +
|
|
|
|
'" down hw ether 12:00:00:00:00:02 up')
|
|
|
|
|
|
|
|
cls.bss_hostapd[0].reload()
|
2021-05-21 18:44:55 +02:00
|
|
|
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")
|
2018-03-21 07:15:31 +01:00
|
|
|
cls.bss_hostapd[1].reload()
|
2021-05-21 18:44:55 +02:00
|
|
|
cls.bss_hostapd[1].wait_for_event("AP-ENABLED")
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
# Fill in the neighbor AP tables in both BSSes. By default each
|
|
|
|
# instance knows only about current BSS, even inside one hostapd
|
|
|
|
# process.
|
|
|
|
# FT still works without the neighbor AP table but neighbor reports
|
|
|
|
# have to be disabled in the .conf files
|
|
|
|
cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT',
|
|
|
|
'1200000000028f0000005102060603000000')
|
|
|
|
cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT',
|
|
|
|
'1200000000018f0000005101060603000000')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
2021-02-25 23:00:54 +01:00
|
|
|
cls.bss_hostapd = None
|
2018-03-21 07:15:31 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|