diff --git a/autotests/testSAE/clogging_test.py b/autotests/testSAE-AntiClogging/clogging_test.py similarity index 66% rename from autotests/testSAE/clogging_test.py rename to autotests/testSAE-AntiClogging/clogging_test.py index 35b9e65e..ddd1c7ab 100644 --- a/autotests/testSAE/clogging_test.py +++ b/autotests/testSAE-AntiClogging/clogging_test.py @@ -8,6 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType +from hostapd import HostapdCLI class Test(unittest.TestCase): @@ -21,20 +22,16 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) for d in devices: - condition = 'not obj.scanning' - wd.wait_for_object_condition(d, condition) - + d.disconnect() d.scan() + wd.wait_for_object_condition(d, 'obj.scanning') for d in devices: - condition = 'not obj.scanning' - wd.wait_for_object_condition(d, condition) + wd.wait_for_object_condition(d, 'not obj.scanning') for i in range(len(devices)): network = devices[i].get_ordered_network('ssidSAE-Clogging') - self.assertEqual(network.type, NetworkType.psk) - networks.append(network) condition = 'not obj.connected' @@ -47,10 +44,6 @@ class Test(unittest.TestCase): condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(d, condition) - for d in devices: - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(d, condition) - for d in devices: d.disconnect() @@ -60,14 +53,27 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) - def test_connection_success(self): + def test_SAE_H2E_Group20(self): + self.hostapd.set_value('sae_pwe', '1'); + self.hostapd.set_value('sae_groups', '20'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") wd = IWD(True) - self.validate_connection(wd) + wd.clear_storage() + + def test_SAE(self): + self.hostapd.set_value('sae_pwe', '0'); + self.hostapd.set_value('sae_groups', '19'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") + wd = IWD(True) + self.validate_connection(wd) + wd.clear_storage() @classmethod def setUpClass(cls): - pass + cls.hostapd = HostapdCLI(config='ssidSAE-Clogging.conf') @classmethod def tearDownClass(cls): diff --git a/autotests/testSAE-AntiClogging/hw.conf b/autotests/testSAE-AntiClogging/hw.conf new file mode 100644 index 00000000..38c06de6 --- /dev/null +++ b/autotests/testSAE-AntiClogging/hw.conf @@ -0,0 +1,6 @@ +[SETUP] +num_radios=5 +start_iwd=0 + +[HOSTAPD] +rad0=ssidSAE-Clogging.conf diff --git a/autotests/testSAE-AntiClogging/main.conf b/autotests/testSAE-AntiClogging/main.conf new file mode 100644 index 00000000..932eb38b --- /dev/null +++ b/autotests/testSAE-AntiClogging/main.conf @@ -0,0 +1,6 @@ +[Scan] +# +# Discovery of the hidden networks with randomization flag set works with real +# hardware, but fails when used in simulated environment with mac80211_hwsim. +# Disable MAC randomization for the tests with hidden networks. +DisableMacAddressRandomization=true diff --git a/autotests/testSAE/ssidSAE-Clogging.conf b/autotests/testSAE-AntiClogging/ssidSAE-Clogging.conf similarity index 100% rename from autotests/testSAE/ssidSAE-Clogging.conf rename to autotests/testSAE-AntiClogging/ssidSAE-Clogging.conf diff --git a/autotests/testSAE/autoconnect_test.py b/autotests/testSAE/autoconnect_test.py index 48b4b6cd..16fcd1e0 100644 --- a/autotests/testSAE/autoconnect_test.py +++ b/autotests/testSAE/autoconnect_test.py @@ -8,21 +8,16 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType +from hostapd import HostapdCLI class Test(unittest.TestCase): def validate_connection(self, wd): - devices = wd.list_devices(4) + devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] - # These devices aren't used in this test, this makes logs a bit nicer - # since these devices would presumably start autoconnecting. - devices[1].disconnect() - devices[2].disconnect() - devices[3].disconnect() - condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) @@ -38,13 +33,26 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) - def test_connection_success(self): - wd = IWD(True) + def test_SAE(self): + self.hostapd.set_value('sae_pwe', '0'); + self.hostapd.set_value('sae_groups', '19'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") + wd = IWD(True) + self.validate_connection(wd) + + def test_SAE_H2E(self): + self.hostapd.set_value('sae_pwe', '1'); + self.hostapd.set_value('sae_groups', '20'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") + wd = IWD(True) self.validate_connection(wd) @classmethod def setUpClass(cls): + cls.hostapd = HostapdCLI(config='ssidSAE.conf') IWD.copy_to_storage('ssidSAE.psk') pass diff --git a/autotests/testSAE/connection_test.py b/autotests/testSAE/connection_test.py index 520db0b1..64c53001 100644 --- a/autotests/testSAE/connection_test.py +++ b/autotests/testSAE/connection_test.py @@ -14,36 +14,26 @@ import testutil class Test(unittest.TestCase): def validate_connection(self, wd): - hostapd = HostapdCLI(config='ssidSAE.conf') - psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) - devices = wd.list_devices(4) + devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] - # These devices aren't used in this test, this makes logs a bit nicer - # since these devices would presumably start autoconnecting. - devices[1].disconnect() - devices[2].disconnect() - devices[3].disconnect() + device.disconnect() - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) + wd.wait_for_object_condition(device, 'not obj.scanning') device.scan() - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) + wd.wait_for_object_condition(device, 'obj.scanning') + wd.wait_for_object_condition(device, 'not obj.scanning') network = device.get_ordered_network('ssidSAE') self.assertEqual(network.type, NetworkType.psk) - condition = 'not obj.connected' - wd.wait_for_object_condition(network.network_object, condition) - network.network_object.connect() condition = 'obj.state == DeviceState.connected' @@ -52,7 +42,7 @@ class Test(unittest.TestCase): wd.wait(2) testutil.test_iface_operstate(intf=device.name) - testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) + testutil.test_ifaces_connected(if0=device.name, if1=self.hostapd.ifname) device.disconnect() @@ -61,18 +51,49 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) - def test_connection_success(self): + def test_SAE(self): + self.hostapd.set_value('sae_pwe', '0'); + self.hostapd.set_value('sae_groups', '19'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") wd = IWD(True) - self.validate_connection(wd) + wd.clear_storage() + + def test_SAE_Group20(self): + self.hostapd.set_value('sae_pwe', '0'); + self.hostapd.set_value('sae_groups', '20'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") + wd = IWD(True) + self.validate_connection(wd) + wd.clear_storage() + + def test_SAE_H2E(self): + self.hostapd.set_value('sae_pwe', '1'); + self.hostapd.set_value('sae_groups', '19'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") + wd = IWD(True) + self.validate_connection(wd) + wd.clear_storage() + + def test_SAE_H2E_Group20(self): + self.hostapd.set_value('sae_pwe', '1'); + self.hostapd.set_value('sae_groups', '20'); + self.hostapd.reload() + self.hostapd.wait_for_event("AP-ENABLED") + wd = IWD(True) + self.validate_connection(wd) + wd.clear_storage() @classmethod def setUpClass(cls): - pass + cls.hostapd = HostapdCLI(config='ssidSAE.conf') @classmethod def tearDownClass(cls): - IWD.clear_storage() + pass if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testSAE/failure_test.py b/autotests/testSAE/failure_test.py index fdbbf449..18c0e747 100644 --- a/autotests/testSAE/failure_test.py +++ b/autotests/testSAE/failure_test.py @@ -12,7 +12,6 @@ from iwd import NetworkType class Test(unittest.TestCase): def validate_connection(self, wd): - psk_agent = PSKAgent("InvalidSecret") wd.register_psk_agent(psk_agent) @@ -42,7 +41,6 @@ class Test(unittest.TestCase): def test_connection_success(self): wd = IWD(True) - self.validate_connection(wd) @classmethod diff --git a/autotests/testSAE/group_20_connection_test.py b/autotests/testSAE/group_20_connection_test.py deleted file mode 100644 index 8ddab8eb..00000000 --- a/autotests/testSAE/group_20_connection_test.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hostapd import HostapdCLI -import testutil - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - hostapd = HostapdCLI(config='ssidSAE-20.conf') - - psk_agent = PSKAgent("secret123") - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(4) - self.assertIsNotNone(devices) - device = devices[0] - - # These devices aren't used in this test, this makes logs a bit nicer - # since these devices would presumably start autoconnecting. - devices[1].disconnect() - devices[2].disconnect() - devices[3].disconnect() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - network = device.get_ordered_network('ssidSAE-20') - - self.assertEqual(network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(network.network_object, condition) - - network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - wd.wait(2) - - testutil.test_iface_operstate(intf=device.name) - testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - pass - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testSAE/hw.conf b/autotests/testSAE/hw.conf index 15bc3a55..c2b1ba51 100644 --- a/autotests/testSAE/hw.conf +++ b/autotests/testSAE/hw.conf @@ -1,8 +1,6 @@ [SETUP] -num_radios=7 +num_radios=2 start_iwd=0 [HOSTAPD] rad0=ssidSAE.conf -rad1=ssidSAE-Clogging.conf -rad2=ssidSAE-20.conf diff --git a/autotests/testSAE/main.conf b/autotests/testSAE/main.conf new file mode 100644 index 00000000..932eb38b --- /dev/null +++ b/autotests/testSAE/main.conf @@ -0,0 +1,6 @@ +[Scan] +# +# Discovery of the hidden networks with randomization flag set works with real +# hardware, but fails when used in simulated environment with mac80211_hwsim. +# Disable MAC randomization for the tests with hidden networks. +DisableMacAddressRandomization=true diff --git a/autotests/testSAE/ssidSAE-20.conf b/autotests/testSAE/ssidSAE-20.conf deleted file mode 100644 index 895682cf..00000000 --- a/autotests/testSAE/ssidSAE-20.conf +++ /dev/null @@ -1,10 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidSAE-20 - -wpa=2 -wpa_key_mgmt=SAE -wpa_pairwise=CCMP -sae_password=secret123|mac=ff:ff:ff:ff:ff:ff -sae_groups=20 -ieee80211w=2 diff --git a/autotests/testSAE/ssidSAE.conf b/autotests/testSAE/ssidSAE.conf index 0c6c807d..0c6be3e3 100644 --- a/autotests/testSAE/ssidSAE.conf +++ b/autotests/testSAE/ssidSAE.conf @@ -6,4 +6,5 @@ wpa=2 wpa_key_mgmt=SAE wpa_pairwise=CCMP sae_password=secret123|mac=ff:ff:ff:ff:ff:ff +sae_groups=19 ieee80211w=2 diff --git a/autotests/testSAE/ssidSAE.psk b/autotests/testSAE/ssidSAE.psk index eb855abd..abafdb66 100644 --- a/autotests/testSAE/ssidSAE.psk +++ b/autotests/testSAE/ssidSAE.psk @@ -1,3 +1,2 @@ [Security] -PreSharedKey=6d44ed0e3a2e1de04c753d66369ece3b9534094ab7ec9ce76798641a9fa68b13 Passphrase=secret123 diff --git a/autotests/testSAE/timeout_test.py b/autotests/testSAE/timeout_test.py index 70462cec..534e1ae8 100644 --- a/autotests/testSAE/timeout_test.py +++ b/autotests/testSAE/timeout_test.py @@ -19,14 +19,7 @@ class Test(unittest.TestCase): psk_agent = PSKAgent(["secret123", "secret123"]) wd.register_psk_agent(psk_agent) - devices = wd.list_devices(4) - - # These devices aren't used in this test, this makes logs a bit nicer - # since these devices would presumably start autoconnecting. - devices[1].disconnect() - devices[2].disconnect() - devices[3].disconnect() - + devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] @@ -68,7 +61,6 @@ class Test(unittest.TestCase): def test_connection_success(self): wd = IWD(True) - self.validate_connection(wd) @classmethod diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py index 277a07b0..4e694c84 100644 --- a/autotests/util/hostapd.py +++ b/autotests/util/hostapd.py @@ -129,6 +129,10 @@ class HostapdCLI: def __del__(self): self._del_hostapd() + def set_value(self, key, value): + cmd = self.cmdline + ['set', key, value] + ctx.start_process(cmd, wait=True) + def wps_push_button(self): ctx.start_process(self.cmdline + ['wps_pbc'], wait=True)