3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

auto-t: SAE: Rework SAE tests

Break up the SAE tests into two parts: testSAE and testSAE-AntiClogging

testSAE is simplified to only use two radios and a single phy managed
by hostapd.  hostapd configurations are changed via the new 'set_value'
method added to hostapd utils.  This allows forcing hostapd to use a
particular sae group set, or force hostapd to use SAE H2E/Hunting and
Pecking Loop for key derivation.  A separate test for IKE Group 20 is no
longer required and is folded into connection_test.py

testSAE-AntiClogging is added with an environment for 5 radios instead
of 7, again with hostapd running on a single phy.  'sae_pwe' is used to
force hostapd to use SAE H2E or Hunting and Pecking for key derivation.
Both Anti-Clogging protocol variants are thus tested.

main.conf is added to both directories to force scan randomization off.
This seems to be required for hostapd to work properly on hwsim.
This commit is contained in:
Denis Kenzior 2021-07-14 10:42:03 -05:00
parent 38e3e72684
commit 6d76b3e21d
15 changed files with 103 additions and 146 deletions

View File

@ -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):

View File

@ -0,0 +1,6 @@
[SETUP]
num_radios=5
start_iwd=0
[HOSTAPD]
rad0=ssidSAE-Clogging.conf

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,2 @@
[Security]
PreSharedKey=6d44ed0e3a2e1de04c753d66369ece3b9534094ab7ec9ce76798641a9fa68b13
Passphrase=secret123

View File

@ -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

View File

@ -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)