From 68bc64c8cdb2d18bae9ffc28604a3ee69333c24e Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Mon, 21 May 2018 13:35:01 -0700 Subject: [PATCH] auto-t: EAP-PWD 1) Removed duplicated entries form .conf 2) Refactored to start catching the exceptions and properly dispose an instance of iwd 3) Switched to list_devices with wait option --- autotests/testEAP-PWD/connection_test.py | 24 +++++++++++++---------- autotests/testEAP-PWD/frag_test.py | 25 +++++++++++++----------- autotests/testEAP-PWD/ssidEAP-PWD.conf | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/autotests/testEAP-PWD/connection_test.py b/autotests/testEAP-PWD/connection_test.py index 3de09743..02b92b81 100644 --- a/autotests/testEAP-PWD/connection_test.py +++ b/autotests/testEAP-PWD/connection_test.py @@ -11,14 +11,12 @@ from iwd import NetworkType class Test(unittest.TestCase): - def test_connection_success(self): - wd = IWD(True) - wd.wait(1) - - psk_agent = PSKAgent('eap-pwd-identity', ('eap-pwd-identity', 'secret123')) + def validate_connection(self, wd): + psk_agent = PSKAgent('eap-pwd-identity', ('eap-pwd-identity', + 'secret123')) wd.register_psk_agent(psk_agent) - devices = wd.list_devices(); + devices = wd.list_devices(True); self.assertIsNotNone(devices) device = devices[0] @@ -44,10 +42,7 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) - try: - ordered_network.network_object.connect() - except: - raise + ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) @@ -59,6 +54,15 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) + def test_connection_success(self): + wd = IWD(True) + + try: + self.validate_connection(wd) + except: + del wd + raise + del wd @classmethod diff --git a/autotests/testEAP-PWD/frag_test.py b/autotests/testEAP-PWD/frag_test.py index e66a9666..8d1e64c1 100644 --- a/autotests/testEAP-PWD/frag_test.py +++ b/autotests/testEAP-PWD/frag_test.py @@ -10,11 +10,8 @@ from iwd import NetworkType class Test(unittest.TestCase): - def test_connection_success(self): - wd = IWD(True, '/tmp/IWD-Frag') - wd.wait(1) - - devices = wd.list_devices(); + def validate_connection(self, wd): + devices = wd.list_devices(True); self.assertIsNotNone(devices) device = devices[0] @@ -30,20 +27,17 @@ class Test(unittest.TestCase): ordered_network = None for o_n in ordered_networks: - if o_n.name == "ssidEAP-PWD-frag": + if o_n.name == 'ssidEAP-PWD-frag': ordered_network = o_n break - self.assertEqual(ordered_network.name, "ssidEAP-PWD-frag") + self.assertEqual(ordered_network.name, 'ssidEAP-PWD-frag') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) - try: - ordered_network.network_object.connect() - except: - raise + ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) @@ -53,6 +47,15 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + def test_connection_success(self): + wd = IWD(True) + + try: + self.validate_connection(wd) + except: + del wd + raise + del wd @classmethod diff --git a/autotests/testEAP-PWD/ssidEAP-PWD.conf b/autotests/testEAP-PWD/ssidEAP-PWD.conf index 84f9854b..e64fe7cc 100644 --- a/autotests/testEAP-PWD/ssidEAP-PWD.conf +++ b/autotests/testEAP-PWD/ssidEAP-PWD.conf @@ -11,5 +11,5 @@ wpa_key_mgmt=WPA-EAP wpa_pairwise=TKIP CCMP rsn_pairwise=CCMP TKIP wpa_passphrase=secret123 -channel=1 + pwd_group=19