diff mbox series

[6/6] auto-t: Add test for BasicServiceSets

Message ID 20240816125214.1162415-6-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/6] network: add __network_path_append_bss | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Aug. 16, 2024, 12:52 p.m. UTC
---
 .../basic_service_set_test.py                 | 100 ++++++++++++++++++
 autotests/testBasicServiceSet/hw.conf         |   7 ++
 autotests/testBasicServiceSet/ssidTKIP-1.conf |   7 ++
 autotests/testBasicServiceSet/ssidTKIP-2.conf |   7 ++
 autotests/testBasicServiceSet/ssidTKIP.psk    |   5 +
 5 files changed, 126 insertions(+)
 create mode 100644 autotests/testBasicServiceSet/basic_service_set_test.py
 create mode 100644 autotests/testBasicServiceSet/hw.conf
 create mode 100644 autotests/testBasicServiceSet/ssidTKIP-1.conf
 create mode 100644 autotests/testBasicServiceSet/ssidTKIP-2.conf
 create mode 100644 autotests/testBasicServiceSet/ssidTKIP.psk
diff mbox series

Patch

diff --git a/autotests/testBasicServiceSet/basic_service_set_test.py b/autotests/testBasicServiceSet/basic_service_set_test.py
new file mode 100644
index 00000000..c99f1901
--- /dev/null
+++ b/autotests/testBasicServiceSet/basic_service_set_test.py
@@ -0,0 +1,100 @@ 
+#! /usr/bin/python3
+
+import unittest
+import sys, os
+
+sys.path.append('../util')
+import iwd
+from iwd import IWD
+from iwd import PSKAgent
+from iwd import NetworkType
+from hwsim import Hwsim
+from hostapd import HostapdCLI
+import testutil
+
+class Test(unittest.TestCase):
+    def test_bss_unregister(self):
+        device = self.wd.list_devices(1)[0]
+
+        ordered_network = device.get_ordered_network('ssidTKIP', full_scan=True)
+        network = ordered_network.network_object
+
+        self.assertEqual(len(network.extended_service_set), 2)
+
+        ends = [parts.split('/')[-1] for parts in network.extended_service_set]
+
+        self.assertIn(self.bss_hostapd[0].bssid.replace(':', ''), ends)
+        self.assertIn(self.bss_hostapd[1].bssid.replace(':', ''), ends)
+
+        self.rule_bss1.enabled = True
+
+        # Even with flushing, the kernel still seems to return the scan
+        # results
+        self.wd.wait(40)
+        ordered_network = device.get_ordered_network('ssidTKIP', full_scan=True)
+        network = ordered_network.network_object
+
+        ends = [parts.split('/')[-1] for parts in network.extended_service_set]
+
+        self.assertIn(self.bss_hostapd[0].bssid.replace(':', ''), ends)
+        self.assertNotIn(self.bss_hostapd[1].bssid.replace(':', ''), ends)
+
+        self.rule_bss0.enabled = True
+
+        self.wd.wait(40)
+        ordered_networks = device.get_ordered_networks('ssidTKIP', full_scan=True)
+        self.assertIsNone(ordered_networks)
+
+        self.rule_bss0.enabled = False
+
+        ordered_networks = device.get_ordered_networks('ssidTKIP', full_scan=True)
+        ends = [parts.split('/')[-1] for parts in network.extended_service_set]
+
+        self.assertIn(self.bss_hostapd[0].bssid.replace(':', ''), ends)
+        self.assertNotIn(self.bss_hostapd[1].bssid.replace(':', ''), ends)
+
+    def tearDown(self):
+        self.rule_bss0.enabled = False
+        self.rule_bss1.enabled = False
+
+        self.wd.stop()
+        self.wd.wait(10)
+        self.wd = None
+
+    def setUp(self):
+        self.wd = IWD(True)
+
+    @classmethod
+    def setUpClass(cls):
+        hwsim = Hwsim()
+
+        IWD.copy_to_storage('ssidTKIP.psk')
+
+        cls.bss_hostapd = [ HostapdCLI(config='ssidTKIP-1.conf'),
+                            HostapdCLI(config='ssidTKIP-2.conf') ]
+
+
+        rad0 = hwsim.get_radio('rad0')
+        rad1 = hwsim.get_radio('rad1')
+
+        cls.rule_bss0 = hwsim.rules.create()
+        cls.rule_bss0.source = rad0.addresses[0]
+        cls.rule_bss0.bidirectional = True
+        cls.rule_bss0.drop = True
+
+        cls.rule_bss1 = hwsim.rules.create()
+        cls.rule_bss1.source = rad1.addresses[0]
+        cls.rule_bss1.bidirectional = True
+        cls.rule_bss1.drop = True
+
+
+
+    @classmethod
+    def tearDownClass(cls):
+        IWD.clear_storage()
+        cls.bss_hostapd = None
+        cls.rule_bss0.remove()
+        cls.rule_bss1.remove()
+
+if __name__ == '__main__':
+    unittest.main(exit=True)
diff --git a/autotests/testBasicServiceSet/hw.conf b/autotests/testBasicServiceSet/hw.conf
new file mode 100644
index 00000000..ff1075fa
--- /dev/null
+++ b/autotests/testBasicServiceSet/hw.conf
@@ -0,0 +1,7 @@ 
+[SETUP]
+num_radios=3
+hwsim_medium=yes
+
+[HOSTAPD]
+rad0=ssidTKIP-1.conf
+rad1=ssidTKIP-2.conf
diff --git a/autotests/testBasicServiceSet/ssidTKIP-1.conf b/autotests/testBasicServiceSet/ssidTKIP-1.conf
new file mode 100644
index 00000000..11ef15f0
--- /dev/null
+++ b/autotests/testBasicServiceSet/ssidTKIP-1.conf
@@ -0,0 +1,7 @@ 
+hw_mode=g
+channel=1
+ssid=ssidTKIP
+
+wpa=1
+wpa_pairwise=TKIP
+wpa_passphrase=secret123
diff --git a/autotests/testBasicServiceSet/ssidTKIP-2.conf b/autotests/testBasicServiceSet/ssidTKIP-2.conf
new file mode 100644
index 00000000..0ed132c1
--- /dev/null
+++ b/autotests/testBasicServiceSet/ssidTKIP-2.conf
@@ -0,0 +1,7 @@ 
+hw_mode=g
+channel=2
+ssid=ssidTKIP
+
+wpa=1
+wpa_pairwise=TKIP
+wpa_passphrase=secret123
diff --git a/autotests/testBasicServiceSet/ssidTKIP.psk b/autotests/testBasicServiceSet/ssidTKIP.psk
new file mode 100644
index 00000000..85d25d8d
--- /dev/null
+++ b/autotests/testBasicServiceSet/ssidTKIP.psk
@@ -0,0 +1,5 @@ 
+[Security]
+Passphrase=secret123
+
+[Settings]
+AutoConnect=False