From e6f8042d179208f42bce7637d680b3034d1db206 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 21 Jun 2018 19:18:54 +0300 Subject: [PATCH] tests: hs20-osu-client testing for PPS MO parsing This adds a mechanism to allow hs20-osu-client set_pps command to be tested with PPS MO files. Signed-off-by: Jouni Malinen --- tests/hwsim/devdetail.xml | 47 +++++++++++++++++++++++++ tests/hwsim/devinfo.xml | 7 ++++ tests/hwsim/pps-mo-1.xml | 62 +++++++++++++++++++++++++++++++++ tests/hwsim/test_hs20_pps_mo.py | 42 ++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 tests/hwsim/devdetail.xml create mode 100644 tests/hwsim/devinfo.xml create mode 100644 tests/hwsim/pps-mo-1.xml create mode 100644 tests/hwsim/test_hs20_pps_mo.py diff --git a/tests/hwsim/devdetail.xml b/tests/hwsim/devdetail.xml new file mode 100644 index 000000000..6d0389e8a --- /dev/null +++ b/tests/hwsim/devdetail.xml @@ -0,0 +1,47 @@ + + + + + + + 13 + + + 21 + MS-CHAP-V2 + + + 18 + + + 23 + + + 50 + + + false + 020102030405 + 310026000000000 + imei:490123456789012 + http://localhost:12345/ + + + + + + + + + + 0 + 0 + 0 + + MobilePhone + Manufacturer + 1.0 + 1.0 + 1.0 + false + diff --git a/tests/hwsim/devinfo.xml b/tests/hwsim/devinfo.xml new file mode 100644 index 000000000..d48a520a9 --- /dev/null +++ b/tests/hwsim/devinfo.xml @@ -0,0 +1,7 @@ + + urn:Example:HS20-station:123456 + Manufacturer + HS20-station + 1.2 + en + diff --git a/tests/hwsim/pps-mo-1.xml b/tests/hwsim/pps-mo-1.xml new file mode 100644 index 000000000..b5f818537 --- /dev/null +++ b/tests/hwsim/pps-mo-1.xml @@ -0,0 +1,62 @@ + + 1 + + + + + another.example.org,includeSubdomains + 10 + + + example.com,exactMatch + 20 + + + + 10 + SPP-ClientInitiated + Unrestricted + https://policy.example.com/run + + http://example.com/policy-root.der + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + + + 1 + + + http://example.com/cacert.der + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + + + 4294967295 + SPP-ClientInitiated + HomeSP + https://remediation.example.com/run + + http://example.com/subscription-root.der + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + + + Example Operator + w1.fi + 010203040506 + + + 2012-12-01T12:00:00Z + + hs20-test + cGFzc3dvcmQ= + TRUE + + 21 + MS-CHAP-V2 + + + w1.fi + + + diff --git a/tests/hwsim/test_hs20_pps_mo.py b/tests/hwsim/test_hs20_pps_mo.py new file mode 100644 index 000000000..5324cde1f --- /dev/null +++ b/tests/hwsim/test_hs20_pps_mo.py @@ -0,0 +1,42 @@ +# Hotspot 2.0 PPS MO tests +# Copyright (c) 2018, The Linux Foundation +# +# This software may be distributed under the terms of the BSD license. +# See README for more details. + +import logging +logger = logging.getLogger() +import os.path +import subprocess + +import hostapd +from utils import HwsimSkip +from test_ap_hs20 import hs20_ap_params, interworking_select, interworking_connect, check_sp_type +from test_ap_eap import check_eap_capa + +def check_hs20_osu_client(): + if not os.path.exists("../../hs20/client/hs20-osu-client"): + raise HwsimSkip("No hs20-osu-client available") + +def set_pps(pps_mo): + res = subprocess.check_output(["../../hs20/client/hs20-osu-client", + "set_pps", pps_mo]) + logger.info("set_pps result: " + res) + +def test_hs20_pps_mo_1(dev, apdev): + """Hotspot 2.0 PPS MO with username/password credential""" + check_hs20_osu_client() + check_eap_capa(dev[0], "MSCHAPV2") + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + params['hessid'] = bssid + params['nai_realm'] = [ "0,w1.fi,13[5:6],21[2:4][5:7]", + "0,another.example.com" ] + params['domain_name'] = "w1.fi" + hapd = hostapd.add_ap(apdev[0], params) + + dev[0].hs20_enable() + set_pps("pps-mo-1.xml") + interworking_select(dev[0], bssid, "home", freq="2412") + interworking_connect(dev[0], bssid, "TTLS") + check_sp_type(dev[0], "home")