From: Jouni Malinen Date: Sun, 2 Dec 2018 14:37:46 +0000 (+0200) Subject: tests: DPP_BOOTSTRAP_GEN/REMOVE/GET_URI/INFO error cases X-Git-Tag: hostap_2_7~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88c08a29a2d7fd9a20298ef7c75005aaa8188df3;p=thirdparty%2Fhostap.git tests: DPP_BOOTSTRAP_GEN/REMOVE/GET_URI/INFO error cases Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index d0aa38ef7..cb3f8a3bb 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -5700,3 +5700,54 @@ def test_dpp_configurator_id_unknown(dev, apdev): run_dpp_configurator_id_unknown(dev[0]) hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) run_dpp_configurator_id_unknown(hapd) + +def run_dpp_bootstrap_gen_failures(dev, hostapd): + check_dpp_capab(dev) + + tests = [ "type=unsupported", + "type=qrcode chan=-1", + "type=qrcode mac=a", + "type=qrcode key=qq", + "type=qrcode key=", + "type=qrcode info=abc\tdef" ] + for t in tests: + if "FAIL" not in dev.request("DPP_BOOTSTRAP_GEN " + t): + raise Exception("Command accepted unexpectedly") + + id = dev.request("DPP_BOOTSTRAP_GEN type=qrcode") + if "FAIL" in id: + raise Exception("Failed to generate bootstrap info") + uri = dev.request("DPP_BOOTSTRAP_GET_URI " + id) + if not uri.startswith("DPP:"): + raise Exception("Could not get URI") + if "FAIL" not in dev.request("DPP_BOOTSTRAP_GET_URI 0"): + raise Exception("Failure not reported") + info = dev.request("DPP_BOOTSTRAP_INFO " + id) + if not info.startswith("type=QRCODE"): + raise Exception("Could not get info") + if "FAIL" not in dev.request("DPP_BOOTSTRAP_REMOVE 0"): + raise Exception("Failure not reported") + if "FAIL" in dev.request("DPP_BOOTSTRAP_REMOVE *"): + raise Exception("Failed to remove bootstrap info") + if "FAIL" not in dev.request("DPP_BOOTSTRAP_GET_URI " + id): + raise Exception("Failure not reported") + if "FAIL" not in dev.request("DPP_BOOTSTRAP_INFO " + id): + raise Exception("Failure not reported") + + func = "hostapd_dpp_bootstrap_gen" if hostapd else "wpas_dpp_bootstrap_gen" + with alloc_fail(dev, 1, "=" + func): + if "FAIL" not in dev.request("DPP_BOOTSTRAP_GEN type=qrcode"): + raise Exception("Command accepted unexpectedly") + + with alloc_fail(dev, 2, "=" + func): + if "FAIL" not in dev.request("DPP_BOOTSTRAP_GEN type=qrcode"): + raise Exception("Command accepted unexpectedly") + + with alloc_fail(dev, 1, "get_param"): + dev.request("DPP_BOOTSTRAP_GEN type=qrcode curve=foo") + +def test_dpp_bootstrap_gen_failures(dev, apdev): + """DPP_BOOTSTRAP_GEN/REMOVE/GET_URI/INFO error cases""" + run_dpp_bootstrap_gen_failures(dev[0], False) + hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + run_dpp_bootstrap_gen_failures(hapd, True)