]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Connect to WPS AP with NFC connection handover (local failure)
authorJouni Malinen <jouni@codeaurora.org>
Tue, 4 Dec 2018 18:55:20 +0000 (20:55 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 4 Dec 2018 18:55:20 +0000 (20:55 +0200)
This is a regression test case for a potential NULL pointer
dereferencing fixed in the previous commit.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
tests/hwsim/test_nfc_wps.py

index f9fa90827a83674806b0ab45d876270b6975e043..be30a99e4c10808ec69897f64820fdb6dbf90ad2 100644 (file)
@@ -635,3 +635,28 @@ def test_nfc_invalid_ndef_record(dev, apdev):
     for test in tests:
         if "FAIL" not in dev[0].request("WPS_NFC_TAG_READ " + test):
             raise Exception("Invalid tag accepted: " + test)
+
+def test_nfc_wps_handover_failure(dev, apdev):
+    """Connect to WPS AP with NFC connection handover (local failure)"""
+    ssid = "test-wps-nfc-handover"
+    params = ap_wps_params(ssid)
+    hapd = hostapd.add_ap(apdev[0], params)
+    logger.info("NFC connection handover")
+    req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip()
+    if "FAIL" in req:
+        raise Exception("Failed to generate NFC connection handover request")
+    sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip()
+    if "FAIL" in sel:
+        raise Exception("Failed to generate NFC connection handover select")
+    res = hapd.request("NFC_REPORT_HANDOVER RESP WPS " + req + " " + sel)
+    if "FAIL" in res:
+        raise Exception("Failed to report NFC connection handover to to hostapd")
+    dev[0].dump_monitor()
+
+    with alloc_fail(hapd, 1, "wpabuf_dup;wps_build_public_key"):
+        res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
+        if "FAIL" in res:
+            raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
+        ev = dev[0].wait_event(["WPS-FAIL"], timeout=10)
+        if ev is None:
+            raise Exception("WPS failure not reported")