Skip to contentSkip to conversation

auto-t: iwd.py: allow renaming in copy_to_storage

PATCH In review James Prestwood 2 participants 3 messages Aug 13, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 auto-t: iwd.py: allow renaming in copy_to_storage

By providing a 'name' keyword argument the file copied will be renamed to that.

---
 autotests/util/iwd.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
autotests/util/iwd.py +4 -1
index 36b8f6f9..737b2beb 100755
@@ -1152,11 +1152,14 @@ class IWD(AsyncOpAbstract):
         fo.close()
 
     @staticmethod
-    def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR):
+    def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR, name=None):
         import shutil
 
         assert not os.path.isabs(source)
 
+        if name:
+            storage_dir += '/%s' % name
+
         shutil.copy(source, storage_dir)
 
     @staticmethod
Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/2 auto-t: remove unneeded BSSs in testEAP-MSCHAPv2

Hostapd sometimes has trouble with specifying additional BSSs in a single config file, at least in the test-runner environment. Since all the BSS's specified were identical instead the test was reworked to only have a single BSS and each subtest can connect in its own unique way.

---
 autotests/testEAP-MSCHAPV2/connection_test.py | 21 ++++++++-------
 .../testEAP-MSCHAPV2/ssidEAP-MSCHAPV2.conf    | 26 +------------------
 2 files changed, 12 insertions(+), 35 deletions(-)
autotests/testEAP-MSCHAPV2/connection_test.py +11 -10
index 33ce856f..faa77918 100644
@@ -10,7 +10,7 @@ from iwd import NetworkType
 
 class Test(unittest.TestCase):
 
-    def run_connection_test(self, ssid, *secrets):
+    def run_connection_test(self, *secrets):
         wd = IWD()
 
         psk_agent = iwd.PSKAgent(*secrets)
@@ -29,7 +29,7 @@ class Test(unittest.TestCase):
             condition = 'not obj.scanning'
             wd.wait_for_object_condition(device, condition)
 
-        ordered_network = device.get_ordered_network(ssid)
+        ordered_network = device.get_ordered_network("ssidEAP-MSCHAPV2")
 
         self.assertEqual(ordered_network.type, NetworkType.eap)
 
@@ -49,23 +49,24 @@ class Test(unittest.TestCase):
         wd.wait_for_object_condition(ordered_network.network_object, condition)
 
     def test_agent_none(self):
-        self.run_connection_test('ssidEAP-MSCHAPV2-1')
+        IWD.copy_to_storage('ssidEAP-MSCHAPV2-1.8021x', name='ssidEAP-MSCHAPV2.8021x')
+        self.run_connection_test()
 
     def test_agent_none_hash(self):
-        self.run_connection_test('ssidEAP-MSCHAPV2-2')
+        IWD.copy_to_storage('ssidEAP-MSCHAPV2-2.8021x', name='ssidEAP-MSCHAPV2.8021x')
+        self.run_connection_test()
 
     def test_agent_passwd(self):
-        self.run_connection_test('ssidEAP-MSCHAPV2-3', [], ('domain\\User', 'Password'))
+        IWD.copy_to_storage('ssidEAP-MSCHAPV2-3.8021x', name='ssidEAP-MSCHAPV2.8021x')
+        self.run_connection_test([], ('domain\\User', 'Password'))
 
     def test_agent_username_and_passwd(self):
-        self.run_connection_test('ssidEAP-MSCHAPV2-4', [], ('domain\\User', 'Password'))
+        IWD.copy_to_storage('ssidEAP-MSCHAPV2-4.8021x', name='ssidEAP-MSCHAPV2.8021x')
+        self.run_connection_test([], ('domain\\User', 'Password'))
 
     @classmethod
     def setUpClass(cls):
-        IWD.copy_to_storage('ssidEAP-MSCHAPV2-1.8021x')
-        IWD.copy_to_storage('ssidEAP-MSCHAPV2-2.8021x')
-        IWD.copy_to_storage('ssidEAP-MSCHAPV2-3.8021x')
-        IWD.copy_to_storage('ssidEAP-MSCHAPV2-4.8021x')
+        pass
 
     @classmethod
     def tearDownClass(cls):
autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2.conf +1 -25
index 2a37a70c..3f33e99d 100644
@@ -1,4 +1,4 @@
-ssid=ssidEAP-MSCHAPV2-1
+ssid=ssidEAP-MSCHAPV2
 interface=wln0
 hw_mode=g
 channel=1
@@ -7,27 +7,3 @@ wpa_key_mgmt=WPA-EAP
 ieee8021x=1
 eap_server=1
 eap_user_file=/tmp/secrets/eap-user-mschapv2.text
-
-bss=wln0_1
-ssid=ssidEAP-MSCHAPV2-2
-wpa=3
-wpa_key_mgmt=WPA-EAP
-ieee8021x=1
-eap_server=1
-eap_user_file=/tmp/secrets/eap-user-mschapv2.text
-
-bss=wln0_2
-ssid=ssidEAP-MSCHAPV2-3
-wpa=3
-wpa_key_mgmt=WPA-EAP
-ieee8021x=1
-eap_server=1
-eap_user_file=/tmp/secrets/eap-user-mschapv2.text
-
-bss=wln0_3
-ssid=ssidEAP-MSCHAPV2-4
-wpa=3
-wpa_key_mgmt=WPA-EAP
-ieee8021x=1
-eap_server=1
-eap_user_file=/tmp/secrets/eap-user-mschapv2.text
Signature · 1 line
2.31.1
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 5 lines · James Prestwood

By providing a 'name' keyword argument the file copied will be renamed to that.

---
  autotests/util/iwd.py | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

Both applied, thanks.

Regards,
-Denis