xref: /freebsd/contrib/wpa/tests/hwsim/test_dpp3.py (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1# Test cases for Device Provisioning Protocol (DPP) version 3
2# Copyright (c) 2021, Qualcomm Innovation Center, Inc.
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
7from test_dpp import check_dpp_capab, run_dpp_auto_connect
8
9def test_dpp_network_intro_version(dev, apdev):
10    """DPP Network Introduction and protocol version"""
11    check_dpp_capab(dev[0], min_ver=3)
12
13    try:
14        id, hapd = run_dpp_auto_connect(dev, apdev, 1, stop_after_prov=True)
15        dev[0].select_network(id, freq=2412)
16        dev[0].wait_connected()
17    finally:
18        dev[0].set("dpp_config_processing", "0", allow_fail=True)
19
20def test_dpp_network_intro_version_change(dev, apdev):
21    """DPP Network Introduction and protocol version change"""
22    check_dpp_capab(dev[0], min_ver=3)
23
24    try:
25        dev[0].set("dpp_version_override", "2")
26        id, hapd = run_dpp_auto_connect(dev, apdev, 1, stop_after_prov=True)
27        dev[0].set("dpp_version_override", "3")
28        dev[0].select_network(id, freq=2412)
29        dev[0].wait_connected()
30    finally:
31        dev[0].set("dpp_config_processing", "0", allow_fail=True)
32
33def test_dpp_network_intro_version_missing_req(dev, apdev):
34    """DPP Network Introduction and protocol version missing from request"""
35    check_dpp_capab(dev[0], min_ver=3)
36
37    try:
38        dev[0].set("dpp_version_override", "2")
39        id, hapd = run_dpp_auto_connect(dev, apdev, 1, stop_after_prov=True)
40        dev[0].set("dpp_version_override", "3")
41        dev[0].set("dpp_test", "92")
42        dev[0].select_network(id, freq=2412)
43        ev = dev[0].wait_event(["DPP-INTRO"], timeout=10)
44        if ev is None:
45            raise Exception("DPP network introduction result not seen on STA")
46        if "status=8" not in ev:
47            raise Exception("Unexpected network introduction result on STA: " + ev)
48    finally:
49        dev[0].set("dpp_config_processing", "0", allow_fail=True)
50