Skip to contentSkip to conversation

auto-t: require a complete hostapd default config

PATCH In review James Prestwood 2 participants 3 messages Aug 29, 2023 – Aug 31, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 auto-t: require a complete hostapd default config

In many tests the hostapd configuration does not include all the values that a test uses. Its expected that each individual test will add the values required. In many cases its required each test slightly alter the configuration for each change every other test has to set the value back to either a default or its own setting. This results in a ton of duplicated code mainly setting things back to defaults.

To help with this problem the hostapd configuration is read in initially and stored as the default. Tests can then simply call .default() to set everything back. This significantly reduces or completely removes a ton of set_value() calls.

This does require that each hostapd configuration file includes all values any of the subtests will set, which is a small price for the convenience.

---
 autotests/util/hostapd.py | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
autotests/util/hostapd.py +26 -1
index bb27686f..1b1bc399 100644
@@ -64,7 +64,16 @@ class HostapdCLI(object):
         hapd = ctx.get_hapd_instance(config)
 
         self.interface = hapd.intf
-        self.config = hapd.config
+        self._config_path = "/tmp/" + hapd.config
+        self._default_config = self._get_config(self._config_path)
+
+        # The vendor_elements is somewhat of a special case because you can't
+        # set it to 'nothing' within the hostapd config. In most cases tests do
+        # not use this and we don't want to require they unset this value
+        # during initialization. Default this to '' so set_value won't throw
+        # an exception.
+        if self._default_config.get('vendor_elements', None) == None:
+            self._default_config['vendor_elements'] = ''
 
         if not self.interface:
             raise Exception('config %s not found' % config)
@@ -89,6 +98,12 @@ class HostapdCLI(object):
 
         ctrl_count = ctrl_count + 1
 
+    def _get_config(self, path):
+        f = open(path)
+        lines = f.readlines()
+        f.close()
+        return dict([[v.strip() for v in kv] for kv in [l.split('#', 1)[0].split('=', 1) for l in lines] if len(kv) == 2])
+
     def _handle_data_in(self, sock, *args):
         newdata = sock.recv(4096)
 
@@ -151,6 +166,10 @@ class HostapdCLI(object):
             pass
 
     def set_value(self, key, value):
+        # Don't allow new settings, defaults should always be in hostapd config
+        if self._default_config.get(key, None) == None:
+            raise Exception("Untracked setting '%s'! Please set default in hostapd config" % key)
+
         cmd = self.cmdline + ['set', key, value]
         ctx.start_process(cmd).wait()
 
@@ -179,6 +198,12 @@ class HostapdCLI(object):
         ctx.start_process(self.cmdline + ['disable']).wait()
         ctx.start_process(self.cmdline + ['enable']).wait()
 
+    def default(self):
+        for k, v in self._default_config.items():
+            self.set_value(k, v)
+
+        self.reload()
+
     def disable(self):
         ctx.start_process(self.cmdline + ['disable']).wait()
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 auto-t: Update tests to use hostapd.default()

---
 .../testOWE-transition/connection_test.py     | 51 ++-----------------
 autotests/testOWE-transition/ssidOWE-2.conf   |  2 +
 autotests/testOWE-transition/ssidOWE.conf     |  1 +
 autotests/testOWE-transition/ssidOpen-2.conf  |  1 +
 autotests/testOWE-transition/ssidOpen.conf    |  1 +
 autotests/testPSK-roam/connection_test.py     | 33 ++----------
 autotests/testPSK-roam/failed_roam_test.py    | 13 ++---
 autotests/testPSK-roam/ft-psk-ccmp-1.conf     |  1 +
 autotests/testPSK-roam/ft-psk-ccmp-2.conf     |  1 +
 autotests/testPSK-roam/ft-psk-ccmp-3.conf     |  1 +
 .../testSAE-AntiClogging/clogging_test.py     |  7 ++-
 .../ssidSAE-Clogging.conf                     |  2 +
 autotests/testSAE/autoconnect_test.py         |  6 +--
 autotests/testSAE/connection_test.py          |  9 +---
 autotests/testSAE/failure_test.py             |  9 ++--
 autotests/testSAE/ssidSAE.conf                |  1 +
 autotests/testSAE/timeout_test.py             | 16 +++---
 autotests/testWPA2/connection_test.py         |  4 +-
 autotests/testWPA2/ssidWPA2.conf              |  1 +
 autotests/testWPA2withMFP/connection_test.py  |  4 +-
 autotests/testWPA2withMFP/ssidWPA2.conf       |  1 +
 21 files changed, 46 insertions(+), 119 deletions(-)
autotests/testOWE-transition/connection_test.py +4 -47
index 89f97338..427e90a6 100644
@@ -47,11 +47,6 @@ class Test(unittest.TestCase):
 
     # Normal success case
     def test_owe_transition(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
         self.hapd_owe2.disable()
         self.hapd_open2.disable()
 
@@ -59,15 +54,8 @@ class Test(unittest.TestCase):
 
     # Normal success case
     def test_owe_transition_multi_network(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
-        self.hapd_open2.set_value('vendor_elements', 'dd17506f9a1c02000000f1000c6f77652d68696464656e2d32')
         self.hapd_open2.set_value('ssid', 'transition-2')
         self.hapd_open2.reload()
-        self.hapd_owe2.set_value('vendor_elements', 'dd17506f9a1c02000000f0000c7472616e736974696f6e2d32')
         self.hapd_owe2.set_value('ssid', 'owe-hidden-2')
         self.hapd_owe2.reload()
 
@@ -75,11 +63,6 @@ class Test(unittest.TestCase):
 
     # Two pairs of open/OWE BSS's (OWE BSS's have different SSIDs) */
     def test_owe_transition_multi_bss(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
         self.hapd_open2.set_value('vendor_elements', 'dd17506f9a1c02000000f3000c6f77652d68696464656e2d32')
         self.hapd_open2.set_value('ssid', 'transition')
         self.hapd_open2.reload()
@@ -91,11 +74,6 @@ class Test(unittest.TestCase):
 
     # Two pairs of open/OWE BSS's (OWE BSS's have same SSID) */
     def test_owe_transition_multi_bss_same_ssid(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
         self.hapd_open2.set_value('vendor_elements', 'dd15506f9a1c02000000f3000a6f77652d68696464656e')
         self.hapd_open2.set_value('ssid', 'transition')
         self.hapd_open2.reload()
@@ -107,11 +85,6 @@ class Test(unittest.TestCase):
 
     # Normal success autoconnect case
     def test_owe_transition_autoconnect(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
         self.hapd_owe2.disable()
         self.hapd_open2.disable()
 
@@ -124,8 +97,6 @@ class Test(unittest.TestCase):
     def test_owe_transition_invalid_open_bssid(self):
         self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000ff000a6f77652d68696464656e')
         self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
 
         self.hapd_owe2.disable()
         self.hapd_open2.disable()
@@ -135,8 +106,6 @@ class Test(unittest.TestCase):
     # OWE BSS has invalid BSSID in OWE transition element
     # Expected connection to Open BSS
     def test_owe_transition_invalid_owe_bssid(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
         self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000ff000a7472616e736974696f6e')
         self.hapd_owe.reload()
 
@@ -148,8 +117,6 @@ class Test(unittest.TestCase):
     # No OWE hidden network exists
     # Expected connection to Open BSS
     def test_owe_transition_no_hidden_found(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
         self.hapd_owe.disable()
 
         self.hapd_owe2.disable()
@@ -160,11 +127,6 @@ class Test(unittest.TestCase):
     # Directly connect to valid OWE hidden network
     # Expected connection failure
     def test_owe_transition_connect_hidden_valid(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
         self.hapd_owe2.disable()
         self.hapd_open2.disable()
 
@@ -189,7 +151,6 @@ class Test(unittest.TestCase):
     def test_owe_transition_band_info(self):
         self.hapd_open.set_value('vendor_elements', 'dd17506f9a1c02000000f1000a6f77652d68696464656e5103')
         self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
         self.hapd_owe.set_value('channel', '3')
         self.hapd_owe.reload()
 
@@ -201,7 +162,6 @@ class Test(unittest.TestCase):
     def test_owe_transition_wrong_band_info(self):
         self.hapd_open.set_value('vendor_elements', 'dd17506f9a1c02000000f1000a6f77652d68696464656e5102')
         self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
         self.hapd_owe.set_value('channel', '3')
         self.hapd_owe.reload()
 
@@ -212,11 +172,6 @@ class Test(unittest.TestCase):
 
     # OWE Transition pair + additional open network with the same SSID
     def test_owe_transition_extra_open(self):
-        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
-        self.hapd_open.reload()
-        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
-        self.hapd_owe.reload()
-
         self.hapd_open2.set_value('ssid', 'transition')
         self.hapd_open2.reload()
 
@@ -235,17 +190,19 @@ class Test(unittest.TestCase):
     def setUp(self):
         self.wd = IWD(True)
         self.hapd_owe = HostapdCLI(config='ssidOWE.conf')
+        self.hapd_owe.default()
         self.hapd_open = HostapdCLI(config='ssidOpen.conf')
+        self.hapd_open.default()
         self.hapd_owe2 = HostapdCLI(config='ssidOWE-2.conf')
+        self.hapd_owe2.default()
         self.hapd_open2 = HostapdCLI(config='ssidOpen-2.conf')
+        self.hapd_open2.default()
 
         self.hwsim = Hwsim()
 
     def tearDown(self):
         IWD.clear_storage()
 
-        self.hapd_owe.set_value('channel', '1')
-
         self.wd = None
         self.hapd_open = None
         self.hapd_owe = None
autotests/testOWE-transition/ssidOWE-2.conf +2 -0
index a8a9023c..85c51470 100644
@@ -7,3 +7,5 @@ ieee80211w=1
 wpa=2
 wpa_key_mgmt=OWE
 rsn_pairwise=CCMP
+
+vendor_elements=dd17506f9a1c02000000f0000c7472616e736974696f6e2d32
autotests/testOWE-transition/ssidOWE.conf +1 -0
index c54309ae..72809fa6 100644
@@ -7,6 +7,7 @@ ieee80211w=1
 wpa=2
 wpa_key_mgmt=OWE
 rsn_pairwise=CCMP
+vendor_elements=dd15506f9a1c02000000f0000a7472616e736974696f6e
 
 # You would conventionally use these options but hostapd does not include an
 # IE for the OWE network, hence vendor_elements must be used directly
autotests/testOWE-transition/ssidOpen-2.conf +1 -0
index 0a9f7628..5721d155 100644
@@ -1,3 +1,4 @@
 channel=1
 ssid=transition-2
 bssid=02:00:00:00:f2:00
+vendor_elements=dd17506f9a1c02000000f1000c6f77652d68696464656e2d32
autotests/testOWE-transition/ssidOpen.conf +1 -0
index 4fc68430..096b52c4 100644
@@ -1,6 +1,7 @@
 channel=1
 ssid=transition
 bssid=02:00:00:00:f0:00
+vendor_elements=dd15506f9a1c02000000f1000a6f77652d68696464656e
 
 # You would conventionally use these options but hostapd does not include an
 # IE for the OWE network, hence vendor_elements must be used directly
autotests/testPSK-roam/connection_test.py +3 -30
index 459c25cf..8db4e4cb 100644
@@ -93,32 +93,16 @@ class Test(unittest.TestCase):
     def test_ft_psk(self):
         wd = IWD(True)
 
-        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].set_value('ocv', '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', '0')
-        self.bss_hostapd[0].set_value('ocv', '1')
-        self.bss_hostapd[1].reload()
-        self.bss_hostapd[1].wait_for_event("AP-ENABLED")
-
         self.validate_connection(wd)
 
     def test_ft_psk_over_ds(self):
         wd = IWD(True)
 
-        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].set_value('ocv', '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].set_value('ocv', '1')
         self.bss_hostapd[1].reload()
         self.bss_hostapd[1].wait_for_event("AP-ENABLED")
 
@@ -128,12 +112,10 @@ class Test(unittest.TestCase):
         wd = IWD(True)
 
         self.bss_hostapd[0].set_value('wpa_key_mgmt', 'WPA-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', 'WPA-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")
 
@@ -142,18 +124,6 @@ class Test(unittest.TestCase):
     def test_roam_packet_loss(self):
         wd = IWD(True)
 
-        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].set_value('ocv', '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', '0')
-        self.bss_hostapd[0].set_value('ocv', '1')
-        self.bss_hostapd[1].reload()
-        self.bss_hostapd[1].wait_for_event("AP-ENABLED")
-
         self.validate_connection(wd, pkt_loss=True)
 
     def tearDown(self):
@@ -166,6 +136,9 @@ class Test(unittest.TestCase):
         self.rule1.enabled = False
         self.rule2.enabled = False
 
+        for hapd in self.bss_hostapd:
+            hapd.default()
+
     @classmethod
     def setUpClass(cls):
         hwsim = Hwsim()
autotests/testPSK-roam/failed_roam_test.py +3 -10
index eda2b4e2..8a3db662 100644
@@ -44,16 +44,6 @@ class Test(unittest.TestCase):
 
     # 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]
@@ -86,6 +76,9 @@ class Test(unittest.TestCase):
         self.rule1.enabled = False
         self.rule2.enabled = False
 
+        for hapd in self.bss_hostapd:
+            hapd.default()
+
     @classmethod
     def setUpClass(cls):
         hwsim = Hwsim()
autotests/testPSK-roam/ft-psk-ccmp-1.conf +1 -0
index 4a2ceba5..eec8805f 100644
@@ -37,3 +37,4 @@ ft_over_ds=0
 ap_table_expiration_time=36000
 ap_table_max_size=10
 rrm_neighbor_report=1
+ocv=1
autotests/testPSK-roam/ft-psk-ccmp-2.conf +1 -0
index a42e175d..5992461f 100644
@@ -37,3 +37,4 @@ ft_over_ds=0
 ap_table_expiration_time=36000
 ap_table_max_size=10
 rrm_neighbor_report=1
+ocv=1
autotests/testPSK-roam/ft-psk-ccmp-3.conf +1 -0
index a42e175d..5992461f 100644
@@ -37,3 +37,4 @@ ft_over_ds=0
 ap_table_expiration_time=36000
 ap_table_max_size=10
 rrm_neighbor_report=1
+ocv=1
autotests/testSAE-AntiClogging/clogging_test.py +3 -4
index 172dfecf..be98ef18 100644
@@ -55,14 +55,13 @@ class Test(unittest.TestCase):
         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()
 
+    def setUp(self):
+        self.hostapd.default()
+
     @classmethod
     def setUpClass(cls):
         cls.hostapd = HostapdCLI(config='ssidSAE-Clogging.conf')
autotests/testSAE-AntiClogging/ssidSAE-Clogging.conf +2 -0
index 1a96d152..b058f25b 100644
@@ -8,3 +8,5 @@ wpa_pairwise=CCMP
 sae_password=secret123|mac=ff:ff:ff:ff:ff:ff
 sae_anti_clogging_threshold=2
 ieee80211w=2
+sae_pwe=0
+sae_groups=19
\ No newline at end of file
autotests/testSAE/autoconnect_test.py +3 -3
index 64a60e7c..cba59274 100644
@@ -35,9 +35,6 @@ class Test(unittest.TestCase):
         wd.wait_for_object_condition(ordered_network.network_object, condition)
 
     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)
@@ -51,6 +48,9 @@ class Test(unittest.TestCase):
         wd = IWD(True)
         self.validate_connection(wd)
 
+    def setUp(self):
+        self.hostapd.default()
+
     @classmethod
     def setUpClass(cls):
         cls.hostapd = HostapdCLI(config='ssidSAE.conf')
autotests/testSAE/connection_test.py +1 -8
index c67f8c83..ecb464e2 100644
@@ -45,16 +45,10 @@ class Test(unittest.TestCase):
         wd.unregister_psk_agent(psk_agent)
 
     def test_SAE(self):
-        self.hostapd.set_value('sae_pwe', '0')
-        self.hostapd.set_value('sae_groups', '19')
-        self.hostapd.set_value('vendor_elements', '')
-        self.hostapd.reload()
         self.hostapd.wait_for_event("AP-ENABLED")
         self.validate_connection(self.wd)
 
     def test_SAE_force_group_19(self):
-        self.hostapd.set_value('sae_pwe', '0')
-        self.hostapd.set_value('sae_groups', '19')
         # Vendor data from APs which require group 19 be used first
         # TODO: (for all tests) verify the expected group was used
         self.hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000')
@@ -63,7 +57,6 @@ class Test(unittest.TestCase):
         self.validate_connection(self.wd)
 
     def test_SAE_Group20(self):
-        self.hostapd.set_value('sae_pwe', '0')
         self.hostapd.set_value('sae_groups', '20')
         self.hostapd.set_value('vendor_elements', '')
         self.hostapd.reload()
@@ -72,7 +65,6 @@ class Test(unittest.TestCase):
 
     def test_SAE_H2E(self):
         self.hostapd.set_value('sae_pwe', '1')
-        self.hostapd.set_value('sae_groups', '19')
         self.hostapd.set_value('vendor_elements', '')
         self.hostapd.reload()
         self.hostapd.wait_for_event("AP-ENABLED")
@@ -87,6 +79,7 @@ class Test(unittest.TestCase):
         self.validate_connection(self.wd)
 
     def setUp(self):
+        self.hostapd.default()
         self.wd = IWD(True)
 
     def tearDown(self):
autotests/testSAE/failure_test.py +6 -3
index e61bf585..2aac3a07 100644
@@ -37,13 +37,16 @@ class Test(unittest.TestCase):
         self.validate_connection(wd, 'InvalidSecret')
 
     def test_no_supported_groups(self):
-        hostapd = HostapdCLI(config='ssidSAE.conf')
-        hostapd.set_value('sae_groups', '1')
-        hostapd.reload()
+        self.hostapd.set_value('sae_groups', '1')
+        self.hostapd.reload()
 
         wd = IWD(True)
         self.validate_connection(wd, 'secret123')
 
+    def setUp(self):
+        self.hostapd = HostapdCLI(config='ssidSAE.conf')
+        self.hostapd.default()
+
     @classmethod
     def setUpClass(cls):
         pass
autotests/testSAE/ssidSAE.conf +1 -0
index 0c6be3e3..41f46cad 100644
@@ -8,3 +8,4 @@ wpa_pairwise=CCMP
 sae_password=secret123|mac=ff:ff:ff:ff:ff:ff
 sae_groups=19
 ieee80211w=2
+sae_pwe=0
autotests/testSAE/timeout_test.py +8 -8
index 1413bb4a..369d5b4b 100644
@@ -40,10 +40,8 @@ class Test(unittest.TestCase):
         # needed because the hwsim rule only matches once and must be matched
         # on the first commit, not during group negotiation.
         #
-        hostapd = HostapdCLI(config='ssidSAE.conf')
-        hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000')
-        hostapd.set_value('sae_groups', '19')
-        hostapd.reload()
+        self.hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000')
+        self.hostapd.reload()
 
         hwsim = Hwsim()
         bss_radio = hwsim.get_radio('rad0')
@@ -64,10 +62,8 @@ class Test(unittest.TestCase):
         rule0.remove()
 
     def test_sta_confirm_not_acked(self):
-        hostapd = HostapdCLI(config='ssidSAE.conf')
-        hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000')
-        hostapd.set_value('sae_groups', '19')
-        hostapd.reload()
+        self.hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000')
+        self.hostapd.reload()
 
         hwsim = Hwsim()
         bss_radio = hwsim.get_radio('rad0')
@@ -87,6 +83,10 @@ class Test(unittest.TestCase):
 
         rule0.remove()
 
+    def setUp(self):
+        self.hostapd = HostapdCLI(config='ssidSAE.conf')
+        self.hostapd.default()
+
     @classmethod
     def setUpClass(cls):
         pass
autotests/testWPA2/connection_test.py +1 -3
index a5a655f5..900f0b46 100644
@@ -43,9 +43,6 @@ class Test(unittest.TestCase):
         wd.unregister_psk_agent(psk_agent)
 
     def test_ccmp(self):
-        self.hostapd.set_value('rsn_pairwise', 'CCMP')
-        self.hostapd.reload()
-        self.hostapd.wait_for_event("AP-ENABLED")
         self.validate_connection_success(self.wd)
 
     def test_gcmp(self):
@@ -67,6 +64,7 @@ class Test(unittest.TestCase):
         self.validate_connection_success(self.wd)
 
     def setUp(self):
+        self.hostapd.default()
         self.wd = IWD(True)
 
     def tearDown(self):
autotests/testWPA2/ssidWPA2.conf +1 -0
index 64fd7796..b1400df3 100644
@@ -5,3 +5,4 @@ ssid=ssidWPA2
 wpa=2
 wpa_pairwise=CCMP
 wpa_passphrase=secret123
+rsn_pairwise=CCMP
autotests/testWPA2withMFP/connection_test.py +1 -3
index bdc9e96a..5de6e6ee 100644
@@ -39,9 +39,6 @@ class Test(unittest.TestCase):
         wd.unregister_psk_agent(psk_agent)
 
     def test_cmac(self):
-        self.hostapd.set_value('group_mgmt_cipher', 'AES-128-CMAC')
-        self.hostapd.reload()
-        self.hostapd.wait_for_event("AP-ENABLED")
         self.validate_connection_success(self.wd)
 
     def test_gmac(self):
@@ -63,6 +60,7 @@ class Test(unittest.TestCase):
         self.validate_connection_success(self.wd)
 
     def setUp(self):
+        self.hostapd.default()
         self.wd = IWD(True)
 
     def tearDown(self):
autotests/testWPA2withMFP/ssidWPA2.conf +1 -0
index 908915d7..6881e5aa 100644
@@ -8,3 +8,4 @@ wpa_passphrase=secret123
 
 ieee80211w=2
 wpa_key_mgmt=WPA-PSK-SHA256
+group_mgmt_cipher=AES-128-CMAC
Signature · 1 line
2.25.1
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 13 lines · James Prestwood

In many tests the hostapd configuration does not include all the values that a test uses. Its expected that each individual test will add the values required. In many cases its required each test slightly alter the configuration for each change every other test has to set the value back to either a default or its own setting. This results in a ton of duplicated code mainly setting things back to defaults.

To help with this problem the hostapd configuration is read in initially and stored as the default. Tests can then simply call .default() to set everything back. This significantly reduces or completely removes a ton of set_value() calls.

Quoted 7 lines

This does require that each hostapd configuration file includes all values any of the subtests will set, which is a small price for the convenience.

---
  autotests/util/hostapd.py | 27 ++++++++++++++++++++++++++-
  1 file changed, 26 insertions(+), 1 deletion(-)

Both applied, thanks.

Regards,
-Denis