From e8518757c9ee24002f856a15eded5682b4050d81 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 15 Mar 2014 17:11:14 +0200 Subject: [PATCH] tests: WPS PIN request file Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_wps.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index 3680f6ddd..c2723e6c8 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -1092,6 +1092,40 @@ def test_ap_wps_per_station_psk(dev, apdev): finally: os.remove(pskfile) +def test_ap_wps_pin_request_file(dev, apdev): + """WPS PIN provisioning with configured AP""" + ssid = "wps" + pinfile = "/tmp/ap_wps_pin_request_file.log" + if os.path.exists(pinfile): + subprocess.call(['sudo', 'rm', pinfile]) + hostapd.add_ap(apdev[0]['ifname'], + { "ssid": ssid, "eap_server": "1", "wps_state": "2", + "wps_pin_requests": pinfile, + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + hapd = hostapd.Hostapd(apdev[0]['ifname']) + uuid = dev[0].get_status_field("uuid") + pin = dev[0].wps_read_pin() + try: + dev[0].request("WPS_PIN any " + pin) + ev = hapd.wait_event(["WPS-PIN-NEEDED"], timeout=15) + if ev is None: + raise Exception("PIN needed event not shown") + if uuid not in ev: + raise Exception("UUID mismatch") + dev[0].request("WPS_CANCEL") + success = False + with open(pinfile, "r") as f: + lines = f.readlines() + for l in lines: + if uuid in l: + success = True + break + if not success: + raise Exception("PIN request entry not in the log file") + finally: + subprocess.call(['sudo', 'rm', pinfile]) + def add_ssdp_ap(ifname, ap_uuid): ssid = "wps-ssdp" ap_pin = "12345670"