diff --git a/autotests/testOWE/connection_test.py b/autotests/testOWE/connection_test.py index ee1036c8..0be09263 100644 --- a/autotests/testOWE/connection_test.py +++ b/autotests/testOWE/connection_test.py @@ -13,29 +13,16 @@ import testutil class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI(config='ssidOWE.conf') + hapd = HostapdCLI(config='ssidOWE-1.conf') wd = IWD() devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) + device.get_ordered_network('ssidOWE', scan_if_needed=True) - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidOWE') - - self.assertEqual(ordered_network.type, NetworkType.open) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() + device.connect_bssid(hapd.bssid) condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) @@ -45,8 +32,40 @@ class Test(unittest.TestCase): device.disconnect() - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + def test_reassociate(self): + hapd0 = HostapdCLI(config='ssidOWE-1.conf') + hapd1 = HostapdCLI(config='ssidOWE-2.conf') + + wd = IWD() + + devices = wd.list_devices(1) + device = devices[0] + + device.get_ordered_network('ssidOWE', scan_if_needed=True) + + device.connect_bssid(hapd0.bssid) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + testutil.test_iface_operstate() + testutil.test_ifaces_connected(device.name, hapd0.ifname) + + device.roam(hapd1.bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + from_condition = 'obj.state == DeviceState.roaming' + to_condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_change(device, from_condition, to_condition) + + self.assertTrue(hapd1.list_sta()) + + 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)) @classmethod def setUpClass(cls): diff --git a/autotests/testOWE/hw.conf b/autotests/testOWE/hw.conf index 7f6d938d..fe59f389 100644 --- a/autotests/testOWE/hw.conf +++ b/autotests/testOWE/hw.conf @@ -1,6 +1,7 @@ [SETUP] -num_radios=3 +num_radios=4 [HOSTAPD] -rad0=ssidOWE.conf -rad1=ssidGroup20.conf +rad0=ssidOWE-1.conf +rad1=ssidOWE-2.conf +rad2=ssidGroup20.conf diff --git a/autotests/testOWE/main.conf b/autotests/testOWE/main.conf new file mode 100644 index 00000000..9452fb6b --- /dev/null +++ b/autotests/testOWE/main.conf @@ -0,0 +1,2 @@ +[Scan] +DisableMacAddressRandomization=true diff --git a/autotests/testOWE/ssidOWE.conf b/autotests/testOWE/ssidOWE-1.conf similarity index 100% rename from autotests/testOWE/ssidOWE.conf rename to autotests/testOWE/ssidOWE-1.conf diff --git a/autotests/testOWE/ssidOWE-2.conf b/autotests/testOWE/ssidOWE-2.conf new file mode 100644 index 00000000..d9528a36 --- /dev/null +++ b/autotests/testOWE/ssidOWE-2.conf @@ -0,0 +1,8 @@ +ctrl_interface=/var/run/hostapd +hw_mode=g +channel=2 +ssid=ssidOWE +wpa=2 +wpa_key_mgmt=OWE +rsn_pairwise=CCMP +owe_groups=19 diff --git a/autotests/testOWE/timeout_test.py b/autotests/testOWE/timeout_test.py index 39c2d429..d75bc8b9 100644 --- a/autotests/testOWE/timeout_test.py +++ b/autotests/testOWE/timeout_test.py @@ -17,9 +17,10 @@ class Test(unittest.TestCase): def test_connection_success(self): hwsim = Hwsim() - bss_radio = hwsim.get_radio('rad0') + bss_radio0 = hwsim.get_radio('rad0') + bss_radio1 = hwsim.get_radio('rad1') - self.assertIsNotNone(bss_radio) + self.assertIsNotNone(bss_radio0) wd = IWD() @@ -31,6 +32,9 @@ class Test(unittest.TestCase): device.scan() + condition = 'obj.scanning' + wd.wait_for_object_condition(device, condition) + condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) @@ -42,21 +46,33 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(ordered_network.network_object, condition) rule0 = hwsim.rules.create() - rule0.source = bss_radio.addresses[0] + rule0.source = bss_radio0.addresses[0] rule0.bidirectional = True rule0.drop = True rule0.prefix = 'b0' + rule1 = hwsim.rules.create() + rule1.source = bss_radio1.addresses[0] + rule1.bidirectional = True + rule1.drop = True + rule1.prefix = 'b0' + # Test Authenticate (b0) and Association (00) timeouts with self.assertRaises(iwd.FailedEx): ordered_network.network_object.connect() rule0.prefix = '00' + rule1.prefix = '00' with self.assertRaises(iwd.FailedEx): ordered_network.network_object.connect() + def tearDown(self): + hwsim = Hwsim() + for rule in list(hwsim.rules.keys()): + del hwsim.rules[rule] + @classmethod def setUpClass(cls): pass