From 7c8c2dbb3bd9a3f7e2ce2a5b9cba2d782af112cc Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Tue, 4 Oct 2016 16:44:28 -0700 Subject: [PATCH] auto-t: Add WPS test --- autotests/testWPS/hw.conf | 5 ++++ autotests/testWPS/ssidWPS.conf | 16 +++++++++++++ autotests/testWPS/wps_test.py | 42 ++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 autotests/testWPS/hw.conf create mode 100644 autotests/testWPS/ssidWPS.conf create mode 100644 autotests/testWPS/wps_test.py diff --git a/autotests/testWPS/hw.conf b/autotests/testWPS/hw.conf new file mode 100644 index 00000000..fe4e1eb4 --- /dev/null +++ b/autotests/testWPS/hw.conf @@ -0,0 +1,5 @@ +[SETUP] +num_radios=2 + +[HOSTAPD] +rad0=ssidWPS.conf diff --git a/autotests/testWPS/ssidWPS.conf b/autotests/testWPS/ssidWPS.conf new file mode 100644 index 00000000..3cb8b47e --- /dev/null +++ b/autotests/testWPS/ssidWPS.conf @@ -0,0 +1,16 @@ +hw_mode=g +channel=1 +ssid=ssidWPS + +eap_server=1 + +wps_state=2 +ap_setup_locked=1 +config_methods=virtual_push_button + +wpa=2 +wpa_key_mgmt=WPA-PSK +wpa_pairwise=CCMP +wpa_passphrase=secret123 + +ctrl_interface=/var/run/hostapd diff --git a/autotests/testWPS/wps_test.py b/autotests/testWPS/wps_test.py new file mode 100644 index 00000000..889d745e --- /dev/null +++ b/autotests/testWPS/wps_test.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 + +import unittest +import sys + +sys.path.append('../util') +import iwd +from iwd import IWD +from iwd import DeviceState + +from hostapd import HostapdCLI + +class Test(unittest.TestCase): + + def test_push_button_success(self): + wd = IWD() + + devices = wd.list_devices(); + self.assertIsNotNone(devices) + device = devices[0] + + device.wps_push_button() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + device.disconnect() + + condition = 'obj.state == DeviceState.disconnected' + wd.wait_for_object_condition(device, condition) + + + @classmethod + def setUpClass(cls): + HostapdCLI.wps_push_button() + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + +if __name__ == '__main__': + unittest.main(exit=True)