This refactors to test both FT and reassociation.
---
autotests/testFT-SAE-roam/connection_test.py | 91 +++++++++++++-------
1 file changed, 61 insertions(+), 30 deletions(-)
diff --git a/autotests/testFT-SAE-roam/connection_test.py
b/autotests/testFT-SAE-roam/connection_test.py
index bea42856..16316123 100644
--- a/autotests/testFT-SAE-roam/connection_test.py
+++ b/autotests/testFT-SAE-roam/connection_test.py
@@ -14,32 +14,17 @@ import testutil
from config import ctx
class Test(unittest.TestCase):
- def test_roam_success(self):
- hwsim = Hwsim()
-
- rule0 = hwsim.rules.create()
- rule0.source = self.bss_radio[0].addresses[0]
- rule0.bidirectional = True
-
- rule1 = hwsim.rules.create()
- rule1.source = self.bss_radio[1].addresses[0]
- rule1.bidirectional = True
-
- rule2 = hwsim.rules.create()
- rule2.source = self.bss_radio[2].addresses[0]
- rule2.bidirectional = True
-
+ def validate_connection(self, wd, ft=True):
# Check that iwd selects BSS 0 first
- rule0.signal = -2000
- rule1.signal = -6900
- rule2.signal = -7200
-
- wd = IWD(True)
+ self.rule[0].signal = -2000
+ self.rule[1].signal = -6900
+ self.rule[2].signal = -7200
psk_agent = PSKAgent("EasilyGuessedPassword")
wd.register_psk_agent(psk_agent)
device = wd.list_devices(1)[0]
+ device.disconnect()
condition = 'not obj.scanning'
wd.wait_for_object_condition(device, condition)
@@ -84,7 +69,7 @@ class Test(unittest.TestCase):
# by mac80211_hwsim will not finish. If this times out then, but
# device_roam_trigger_cb has happened, it probably means that
# Neighbor Reports are broken.
- rule0.signal = -8000
+ self.rule[0].signal = -8000
condition = 'obj.state == DeviceState.roaming'
wd.wait_for_object_condition(device, condition)
@@ -95,7 +80,7 @@ class Test(unittest.TestCase):
to_condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_change(device, from_condition, to_condition)
- rule1.signal = -2000
+ self.rule[1].signal = -2000
# wait for IWD's signal levels to recover
wd.wait(5)
@@ -107,10 +92,13 @@ class Test(unittest.TestCase):
self.assertRaises(Exception, testutil.test_ifaces_connected,
(self.bss_hostapd[0].ifname, device.name))
- # test FT-PSK after FT-SAE
- rule1.signal = -8000
- rule0.signal = -8000
- rule2.signal = -1000
+ if not ft:
+ return
+
+ # test FT-PSK after FT-SAE
+ self.rule[1].signal = -8000
+ self.rule[0].signal = -8000
+ self.rule[2].signal = -1000
condition = 'obj.state == DeviceState.roaming'
wd.wait_for_object_condition(device, condition)
@@ -125,6 +113,35 @@ class Test(unittest.TestCase):
testutil.test_ifaces_connected(self.bss_hostapd[2].ifname, device.name)
self.assertRaises(Exception, testutil.test_ifaces_connected,
(self.bss_hostapd[1].ifname, device.name))
+ def test_ft_roam_success(self):
+ wd = IWD(True)
+
+ self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-SAE SAE')
+ self.bss_hostapd[0].reload()
+ self.bss_hostapd[0].wait_for_event("AP-ENABLED")
+ self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-SAE SAE')
+ self.bss_hostapd[1].reload()
+ self.bss_hostapd[1].wait_for_event("AP-ENABLED")
+ self.bss_hostapd[2].set_value('wpa_key_mgmt', 'FT-PSK')
+ self.bss_hostapd[2].reload()
+ self.bss_hostapd[2].wait_for_event("AP-ENABLED")
+
+ self.validate_connection(wd, True)
+
+ def test_reassociate_roam_success(self):
+ wd = IWD(True)
+
+ self.bss_hostapd[0].set_value('wpa_key_mgmt', 'SAE')
+ self.bss_hostapd[0].reload()
+ self.bss_hostapd[0].wait_for_event("AP-ENABLED")
+ self.bss_hostapd[1].set_value('wpa_key_mgmt', 'SAE')
+ self.bss_hostapd[1].reload()
+ self.bss_hostapd[1].wait_for_event("AP-ENABLED")
+ self.bss_hostapd[2].set_value('wpa_key_mgmt', 'WPA-PSK')
+ self.bss_hostapd[2].reload()
+ self.bss_hostapd[2].wait_for_event("AP-ENABLED")
+
+ self.validate_connection(wd, False)
def tearDown(self):
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '"
down')
@@ -134,10 +151,6 @@ class Test(unittest.TestCase):
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '"
up')
os.system('ifconfig "' + self.bss_hostapd[2].ifname + '"
up')
- hwsim = Hwsim()
- for rule in list(hwsim.rules.keys()):
- del hwsim.rules[rule]
-
@classmethod
def setUpClass(cls):
hwsim = Hwsim()
@@ -149,6 +162,19 @@ class Test(unittest.TestCase):
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
+ cls.rule = [ hwsim.rules.create(),
+ hwsim.rules.create(),
+ hwsim.rules.create() ]
+
+ cls.rule[0].source = cls.bss_radio[0].addresses[0]
+ cls.rule[0].bidirectional = True
+
+ cls.rule[1].source = cls.bss_radio[1].addresses[0]
+ cls.rule[1].bidirectional = True
+
+ cls.rule[2].source = cls.bss_radio[2].addresses[0]
+ cls.rule[2].bidirectional = True
+
ctx.start_process(['ifconfig', cls.bss_hostapd[0].ifname, 'down',
'hw', \
'ether', '12:00:00:00:00:01',
'up'], wait=True)
ctx.start_process(['ifconfig', cls.bss_hostapd[1].ifname, 'down',
'hw', \
@@ -187,6 +213,11 @@ class Test(unittest.TestCase):
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
+
+ hwsim = Hwsim()
+ for rule in list(hwsim.rules.keys()):
+ del hwsim.rules[rule]
+
cls.bss_hostapd = None
cls.bss_radio = None
--
2.31.1