iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 5/6] auto-t: add two tests for new FT behavior
Date: Wed,  5 Oct 2022 15:46:31 -0700	[thread overview]
Message-ID: <20221005224632.780575-5-prestwoj@gmail.com> (raw)
In-Reply-To: <20221005224632.780575-1-prestwoj@gmail.com>

These tests ensure proper behavior if FT fails to authenticate
---
 autotests/testPSK-roam/failed_roam_test.py | 160 +++++++++++++++++++++
 1 file changed, 160 insertions(+)
 create mode 100644 autotests/testPSK-roam/failed_roam_test.py

diff --git a/autotests/testPSK-roam/failed_roam_test.py b/autotests/testPSK-roam/failed_roam_test.py
new file mode 100644
index 00000000..cac2ff4d
--- /dev/null
+++ b/autotests/testPSK-roam/failed_roam_test.py
@@ -0,0 +1,160 @@
+#! /usr/bin/python3
+
+import unittest
+import os, sys
+
+sys.path.append('../util')
+from iwd import IWD
+from iwd import NetworkType, DeviceState
+from hwsim import Hwsim
+from hostapd import HostapdCLI
+import testutil
+
+class Test(unittest.TestCase):
+    def connect(self, wd, device, hostapd):
+        ordered_network = device.get_ordered_network('TestFT', full_scan=True)
+
+        self.assertEqual(ordered_network.type, NetworkType.psk)
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        device.connect_bssid(hostapd.bssid)
+
+        condition = 'obj.state == DeviceState.connected'
+        wd.wait_for_object_condition(device, condition)
+
+        hostapd.wait_for_event('AP-STA-CONNECTED %s' % device.address)
+
+        testutil.test_iface_operstate(device.name)
+        testutil.test_ifaces_connected(hostapd.ifname, device.name)
+
+    def verify_roam(self, wd, device, prev, new):
+        from_condition = 'obj.state == DeviceState.roaming'
+        to_condition = 'obj.state == DeviceState.connected'
+        wd.wait_for_object_change(device, from_condition, to_condition)
+
+        new.wait_for_event('AP-STA-CONNECTED %s' % device.address)
+
+        testutil.test_iface_operstate(device.name)
+        testutil.test_ifaces_connected(new.ifname, device.name)
+        self.assertRaises(Exception, testutil.test_ifaces_connected,
+                          (prev.ifname, device.name, True, True))
+
+
+    # FT-over-Air failure, should stay connected
+    def test_ft_over_air_failure(self):
+        self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK')
+        self.bss_hostapd[0].set_value('ft_over_ds', '0')
+        self.bss_hostapd[0].reload()
+        self.bss_hostapd[0].wait_for_event("AP-ENABLED")
+
+        self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK')
+        self.bss_hostapd[1].set_value('ft_over_ds', '0')
+        self.bss_hostapd[1].reload()
+        self.bss_hostapd[1].wait_for_event("AP-ENABLED")
+
+        wd = IWD(True)
+
+        device = wd.list_devices(1)[0]
+
+        self.connect(wd, device, self.bss_hostapd[0])
+
+        self.rule0.enabled = True
+
+        device.roam(self.bss_hostapd[1].bssid)
+
+        # Roam should fail...
+        device.wait_for_event('ft-over-air-roam-failed')
+        # ... but IWD should remain connected
+        self.assertTrue(device.state == DeviceState.connected)
+
+        self.rule0.enabled = False
+
+        # Try again once more
+        device.roam(self.bss_hostapd[1].bssid)
+
+        self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[1])
+
+        self.bss_hostapd[1].deauthenticate(device.address)
+        condition = 'obj.state == DeviceState.disconnected'
+        wd.wait_for_object_condition(device, condition)
+
+    # Network sets over-DS bit, but fails to authenticate. IWD should still be
+    # able to roam using FT-over-Air.
+    def test_fallback_to_over_air(self):
+        self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK')
+        self.bss_hostapd[0].set_value('ft_over_ds', '1')
+        self.bss_hostapd[0].reload()
+        self.bss_hostapd[0].wait_for_event("AP-ENABLED")
+
+        self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK')
+        self.bss_hostapd[1].set_value('ft_over_ds', '1')
+        self.bss_hostapd[1].reload()
+        self.bss_hostapd[1].wait_for_event("AP-ENABLED")
+
+        wd = IWD(True)
+
+        device = wd.list_devices(1)[0]
+
+        # Drop action frames, this will prevent FT-over-DS authentication
+        self.rule1.enabled = True
+
+        self.connect(wd, device, self.bss_hostapd[0])
+
+        device.roam(self.bss_hostapd[1].bssid)
+
+        self.rule1.enabled = False
+
+        # FT-over-DS should fail, and over-Air should take over leading to a
+        # successful roam
+        device.wait_for_event('try-ft-over-air')
+
+        self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[1])
+
+        self.bss_hostapd[1].deauthenticate(device.address)
+        condition = 'obj.state == DeviceState.disconnected'
+        wd.wait_for_object_condition(device, condition)
+
+    def tearDown(self):
+        os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
+        os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
+        os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
+        os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
+
+        self.rule0.enabled = False
+        self.rule1.enabled = False
+
+    @classmethod
+    def setUpClass(cls):
+        hwsim = Hwsim()
+
+        IWD.copy_to_storage('TestFT.psk')
+
+        cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'),
+                            HostapdCLI(config='ft-psk-ccmp-2.conf') ]
+
+        cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
+        cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
+
+        # Drop Authenticate frames
+        cls.rule0 = hwsim.rules.create()
+        cls.rule0.bidirectional = True
+        cls.rule0.prefix = 'b0'
+        cls.rule0.drop = True
+
+        # Drop Action frames
+        cls.rule1 = hwsim.rules.create()
+        cls.rule1.bidirectional = True
+        cls.rule1.prefix = 'd0'
+        cls.rule1.drop = True
+
+    @classmethod
+    def tearDownClass(cls):
+        IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.rule0.remove()
+        cls.rule1.remove()
+
+if __name__ == '__main__':
+    unittest.main(exit=True)
-- 
2.34.3


  parent reply	other threads:[~2022-10-05 22:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 22:46 [PATCH 1/6] station: add two debug events for FT James Prestwood
2022-10-05 22:46 ` [PATCH 2/6] hwsim: fix early bail out processing rules James Prestwood
2022-10-05 22:46 ` [PATCH 3/6] auto-t: remove rekey timeouts from autotests James Prestwood
2022-10-05 22:46 ` [PATCH 4/6] auto-t: remove old debug print from wpas.py James Prestwood
2022-10-05 22:46 ` James Prestwood [this message]
2022-10-05 22:46 ` [PATCH 6/6] monitor: parse DPP frame types James Prestwood
2022-10-06 14:02 ` [PATCH 1/6] station: add two debug events for FT Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221005224632.780575-5-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).