public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 2/2] auto-t: add netconfig timeout test
Date: Tue, 30 Jan 2024 09:50:38 -0800	[thread overview]
Message-ID: <20240130175038.77908-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20240130175038.77908-1-prestwoj@gmail.com>

Tests that netconfig eventually times out and that IWD disconnects
---
 autotests/testNetconfig/autoconnect.psk |  2 +
 autotests/testNetconfig/timeout_test.py | 65 +++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 autotests/testNetconfig/autoconnect.psk
 create mode 100644 autotests/testNetconfig/timeout_test.py

diff --git a/autotests/testNetconfig/autoconnect.psk b/autotests/testNetconfig/autoconnect.psk
new file mode 100644
index 00000000..c28936bf
--- /dev/null
+++ b/autotests/testNetconfig/autoconnect.psk
@@ -0,0 +1,2 @@
+[IPv4]
+SendHostname=true
diff --git a/autotests/testNetconfig/timeout_test.py b/autotests/testNetconfig/timeout_test.py
new file mode 100644
index 00000000..a15706e3
--- /dev/null
+++ b/autotests/testNetconfig/timeout_test.py
@@ -0,0 +1,65 @@
+import unittest
+import sys
+import os
+
+sys.path.append('../util')
+from iwd import IWD
+from iwd import PSKAgent
+from iwd import NetworkType
+
+class Test(unittest.TestCase):
+
+    def test_netconfig_timeout(self):
+        IWD.copy_to_storage('autoconnect.psk', name='ap-ns1.psk')
+
+        wd = IWD(True)
+
+        psk_agent = PSKAgent("secret123")
+        wd.register_psk_agent(psk_agent)
+
+        devices = wd.list_devices(1)
+        device = devices[0]
+
+        ordered_network = device.get_ordered_network('ap-ns1')
+
+        self.assertEqual(ordered_network.type, NetworkType.psk)
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        ordered_network.network_object.connect()
+
+        condition = 'obj.state == DeviceState.connecting'
+        wd.wait_for_object_condition(device, condition)
+
+        device.wait_for_event("connecting (netconfig)")
+
+        # Netconfig should fail, and IWD should disconnect
+        from_condition = 'obj.state == DeviceState.connecting'
+        to_condition = 'obj.state == DeviceState.disconnecting'
+        wd.wait_for_object_change(device, from_condition, to_condition, max_wait=60)
+
+        # Autoconnect should then try again
+        condition = 'obj.state == DeviceState.connecting'
+        wd.wait_for_object_condition(device, condition)
+
+        device.wait_for_event("connecting (netconfig)")
+
+        device.disconnect()
+        condition = 'obj.state == DeviceState.disconnected'
+        wd.wait_for_object_condition(device, condition)
+
+    @classmethod
+    def setUpClass(cls):
+        cls.orig_path = os.environ['PATH']
+        os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH']
+        IWD.copy_to_storage('resolvconf', '/tmp/test-bin')
+
+    @classmethod
+    def tearDownClass(cls):
+        IWD.clear_storage()
+        os.system('rm -rf /tmp/radvd.conf /tmp/resolvconf.log /tmp/test-bin')
+        os.environ['PATH'] = cls.orig_path
+
+if __name__ == '__main__':
+    unittest.main(exit=True)
-- 
2.34.1


  reply	other threads:[~2024-01-30 17:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 17:50 [PATCH v2 1/2] netconfig: limit DHCPv4 attempts to avoid extended netconfig times James Prestwood
2024-01-30 17:50 ` James Prestwood [this message]
2024-01-30 20:00 ` 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=20240130175038.77908-2-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