From 686ca5c45bf45793a96963a8aa098b7d5becfe93 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 31 Jul 2018 00:21:59 +0300 Subject: [PATCH] tests: Verify T&C Server URL generation result Check that the @1@ macro gets replaced correctly both when in the middle and when in the end of the URL template. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_hs20.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 06ea885b5..8d494c026 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -5853,6 +5853,20 @@ def test_ap_hs20_terms_and_conditions_coa(dev, apdev): def test_ap_hs20_terms_and_conditions_sql(dev, apdev, params): """Hotspot 2.0 Terms and Conditions using SQLite for user DB""" + addr = dev[0].own_addr() + run_ap_hs20_terms_and_conditions_sql(dev, apdev, params, + "https://example.com/t_and_c?addr=@1@&ap=123", + "https://example.com/t_and_c?addr=" + addr + "&ap=123") + +def test_ap_hs20_terms_and_conditions_sql2(dev, apdev, params): + """Hotspot 2.0 Terms and Conditions using SQLite for user DB""" + addr = dev[0].own_addr() + run_ap_hs20_terms_and_conditions_sql(dev, apdev, params, + "https://example.com/t_and_c?addr=@1@", + "https://example.com/t_and_c?addr=" + addr) + +def run_ap_hs20_terms_and_conditions_sql(dev, apdev, params, url_template, + url_expected): check_eap_capa(dev[0], "MSCHAPV2") try: import sqlite3 @@ -5884,7 +5898,7 @@ def test_ap_hs20_terms_and_conditions_sql(dev, apdev, params): "ca_cert": "auth_serv/ca.pem", "server_cert": "auth_serv/server.pem", "private_key": "auth_serv/server.key" } - params['hs20_t_c_server_url'] = 'https://example.com/t_and_c?addr=@1@&ap=123' + params['hs20_t_c_server_url'] = url_template authsrv = hostapd.add_ap(apdev[1], params) bssid = apdev[0]['bssid'] @@ -5916,6 +5930,9 @@ def test_ap_hs20_terms_and_conditions_sql(dev, apdev, params): ev = dev[0].wait_event(["HS20-T-C-ACCEPTANCE"], timeout=5) if ev is None: raise Exception("Terms and Conditions Acceptance notification not received") + url = ev.split(' ')[1] + if url != url_expected: + raise Exception("Unexpected URL delivered to the client: %s (expected %s)" % (url, url_expected)) dev[0].dump_monitor() with con: