1# Hotspot 2.0 PPS MO tests
2# Copyright (c) 2018, The Linux Foundation
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
7import logging
8logger = logging.getLogger()
9import os.path
10import subprocess
11
12import hostapd
13from utils import HwsimSkip
14from test_ap_hs20 import hs20_ap_params, interworking_select, interworking_connect, check_sp_type
15from test_ap_eap import check_eap_capa, check_domain_suffix_match
16
17def check_hs20_osu_client():
18    if not os.path.exists("../../hs20/client/hs20-osu-client"):
19        raise HwsimSkip("No hs20-osu-client available")
20
21def set_pps(pps_mo):
22    res = subprocess.check_output(["../../hs20/client/hs20-osu-client",
23                                   "set_pps", pps_mo]).decode()
24    logger.info("set_pps result: " + res)
25
26def test_hs20_pps_mo_1(dev, apdev):
27    """Hotspot 2.0 PPS MO with username/password credential"""
28    check_hs20_osu_client()
29    check_eap_capa(dev[0], "MSCHAPV2")
30    check_domain_suffix_match(dev[0])
31    bssid = apdev[0]['bssid']
32    params = hs20_ap_params()
33    params['hessid'] = bssid
34    params['nai_realm'] = ["0,w1.fi,13[5:6],21[2:4][5:7]",
35                           "0,another.example.com"]
36    params['domain_name'] = "w1.fi"
37    hapd = hostapd.add_ap(apdev[0], params)
38
39    dev[0].hs20_enable()
40    set_pps("pps-mo-1.xml")
41    interworking_select(dev[0], bssid, "home", freq="2412")
42    interworking_connect(dev[0], bssid, "TTLS")
43    check_sp_type(dev[0], "home")
44