From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 4/5] auto-t: add DPP tests for state change checks
Date: Wed, 24 Jul 2024 08:46:40 -0700 [thread overview]
Message-ID: <20240724154641.1461593-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20240724154641.1461593-1-prestwoj@gmail.com>
---
autotests/testDPP/pkex_test.py | 20 ++++-
autotests/testDPP/state_change_test.py | 107 +++++++++++++++++++++++++
2 files changed, 126 insertions(+), 1 deletion(-)
create mode 100644 autotests/testDPP/state_change_test.py
diff --git a/autotests/testDPP/pkex_test.py b/autotests/testDPP/pkex_test.py
index db355225..3d3ea6d1 100644
--- a/autotests/testDPP/pkex_test.py
+++ b/autotests/testDPP/pkex_test.py
@@ -4,7 +4,7 @@ import unittest
import sys
sys.path.append('../util')
-from iwd import IWD, SharedCodeAgent
+from iwd import IWD, SharedCodeAgent, DeviceState
from iwd import DeviceProvisioning
from wpas import Wpas
from hostapd import HostapdCLI
@@ -210,6 +210,24 @@ class Test(unittest.TestCase):
self.assertIn("SendHostname=true", settings)
+ def test_existing_incorrect_profile(self):
+ self.hapd.reload()
+ self.hapd.wait_for_event('AP-ENABLED')
+ IWD.copy_to_storage("existingProfile.psk", "/tmp/ns0/", "ssidCCMP.psk")
+
+ # Start connecting
+ self.device[1].autoconnect = True
+ self.wd.wait_for_object_condition(self.device[1], 'obj.state == DeviceState.connecting')
+
+ # We should be able to start DPP despite the connecting state
+ self.device[1].dpp_pkex_enroll('secret123', identifier="test")
+
+ self.start_iwd_pkex_configurator(self.device[0])
+ self.assertEqual(self.device[1].state, DeviceState.disconnected)
+
+ condition = 'obj.state == DeviceState.connected'
+ self.wd.wait_for_object_condition(self.device[1], condition)
+
def test_existing_hidden_network(self):
self.hapd_hidden.reload()
self.hapd_hidden.wait_for_event('AP-ENABLED')
diff --git a/autotests/testDPP/state_change_test.py b/autotests/testDPP/state_change_test.py
new file mode 100644
index 00000000..d52f2b12
--- /dev/null
+++ b/autotests/testDPP/state_change_test.py
@@ -0,0 +1,107 @@
+#!/usr/bin/python3
+
+import unittest
+import sys
+
+sys.path.append('../util')
+from iwd import IWD, SharedCodeAgent, DeviceState
+from iwd import DeviceProvisioning
+from wpas import Wpas
+from hostapd import HostapdCLI
+from hwsim import Hwsim
+from config import ctx
+from time import time
+import os
+
+class Test(unittest.TestCase):
+ def auto_connect(self):
+ IWD.copy_to_storage('ssidCCMP.psk')
+ self.device.autoconnect = True
+
+ condition = 'obj.state == DeviceState.connected'
+ self.wd.wait_for_object_condition(self.device, condition)
+
+ def test_configurator_stops_on_disconnect(self):
+ self.auto_connect()
+
+ self.device.dpp_start_configurator()
+
+ self.device.disconnect()
+
+ condition = 'obj.state == DeviceState.disconnected'
+ self.wd.wait_for_object_condition(self.device, condition)
+
+ self.assertEqual(self.device._device_provisioning.started, False)
+
+ def test_enrollee_stops_on_connect(self):
+ # Scan to get a list of networks
+ self.device.scan()
+ self.wd.wait_for_object_condition(self.device, 'obj.scanning == True')
+ self.wd.wait_for_object_condition(self.device, 'obj.scanning == False')
+
+ self.device.dpp_start_enrollee()
+
+ network = self.device.get_ordered_network("ssidCCMP")
+ network.network_object.connect()
+
+ condition = 'obj.state == DeviceState.connected'
+ self.wd.wait_for_object_condition(self.device, condition)
+
+ self.assertEqual(self.device._device_provisioning.started, False)
+
+ def test_enrollee_disconnects_automatically(self):
+ self.auto_connect()
+
+ self.device.dpp_start_enrollee()
+
+ condition = 'obj.state == DeviceState.disconnected'
+ self.wd.wait_for_object_condition(self.device, condition)
+
+ def test_enrollee_autoconnect_stays_on(self):
+ # Put in an autoconnecting state, no saved profile though
+ self.device.autoconnect = True
+
+ self.device.dpp_start_enrollee()
+
+ # DPP should set autoconnect false, but then re-enable after it stops
+ self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False")
+ self.wd.wait_for_object_condition(self.device._device_provisioning, "obj.started == True")
+
+ # Stop DPP
+ self.device.dpp_stop()
+ self.wd.wait_for_object_condition(self.device, "obj.autoconnect == True")
+
+ def test_enrollee_autoconnect_stays_off(self):
+ # Autoconnect should be off by default
+
+ self.device.dpp_start_enrollee()
+
+ # DPP should set autoconnect false, but stay off after it stops
+ self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False")
+ self.wd.wait_for_object_condition(self.device._device_provisioning, "obj.started == True")
+
+ # Stop DPP
+ self.device.dpp_stop()
+ self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False")
+
+ def setUp(self):
+ self.wd = IWD(True)
+ self.device = self.wd.list_devices(1)[0]
+
+ def tearDown(self):
+ self.wd.stop()
+ self.wd = None
+
+ @classmethod
+ def setUpClass(cls):
+ hapd = HostapdCLI(config="hostapd.conf")
+ hapd.reload()
+
+ hapd.wait_for_event("AP-ENABLED")
+
+ @classmethod
+ def tearDownClass(cls):
+ pass
+
+if __name__ == '__main__':
+ unittest.main(exit=True)
\ No newline at end of file
--
2.34.1
next prev parent reply other threads:[~2024-07-24 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 15:46 [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function James Prestwood
2024-07-24 15:46 ` [PATCH v2 2/5] station: add station_get_autoconnect James Prestwood
2024-07-24 15:46 ` [PATCH v2 3/5] dpp: explicitly disconnect station if enrollee is started James Prestwood
2024-07-24 15:46 ` James Prestwood [this message]
2024-07-24 15:46 ` [PATCH v2 5/5] auto-t: fix several DPP tests after station state changes James Prestwood
2024-07-24 20:27 ` [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2024-07-22 18:29 James Prestwood
2024-07-22 18:29 ` [PATCH v2 4/5] auto-t: add DPP tests for state change checks James Prestwood
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=20240724154641.1461593-4-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