commit a0a81c72e11aaf135d734be71386853d7a519f8f
parent a3a48da542d8060e3c789a482c26452ac5ca2916
Author: James Prestwood <james.prestwood@linux.intel.com>
Date: Wed, 28 Aug 2019 09:14:32 -0700
auto-t: add autoconnect hotspot test
Diffstat:
9 files changed, 208 insertions(+), 1 deletion(-)
diff --git a/autotests/testHotspot/autoconnect.conf b/autotests/testHotspot/autoconnect.conf
@@ -0,0 +1,11 @@
+[Security]
+EAP-Method=TTLS
+EAP-Identity=anonymous@example.com
+EAP-TTLS-Phase2-Method=Tunneled-MSCHAPv2
+
+EAP-TTLS-Phase2-Identity=domain\\user
+EAP-TTLS-Phase2-Password=testpasswd
+
+[Hotspot]
+NAIRealmNames=realm1.random.net,example.com
+Name=Autoconnect hotspot
diff --git a/autotests/testHotspot/autoconnect_test.py b/autotests/testHotspot/autoconnect_test.py
@@ -0,0 +1,123 @@
+#!/usr/bin/python3
+
+import unittest
+import sys
+import os
+
+from time import sleep
+
+sys.path.append('../util')
+import iwd
+from iwd import IWD
+from iwd import NetworkType
+from hostapd import HostapdCLI
+import testutil
+
+class Test(unittest.TestCase):
+
+ def test_connection_success(self):
+ wd = IWD(True, '/tmp')
+
+ hapd_hotspot = HostapdCLI(config='ssidHotspot.conf')
+ hapd_wpa = HostapdCLI(config='ssidWPA2-1.conf')
+
+ self.assertEqual(len(wd.list_known_networks()), 2)
+
+ devices = wd.list_devices(1)
+ device = devices[0]
+
+ condition = 'obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ wpa_network = device.get_ordered_network("ssidWPA2-1")
+ self.assertEqual(wpa_network.type, NetworkType.psk)
+
+ #
+ # First make sure we can connect to a provisioned, non-Hotspot network,
+ # while there are hotspot networks in range. This should result in
+ # autoconnect *after* ANQP is performed
+ #
+ condition = 'obj.connected'
+ wd.wait_for_object_condition(wpa_network.network_object, condition)
+
+ sleep(2)
+
+ testutil.test_iface_operstate()
+ testutil.test_ifaces_connected(device.name, hapd_wpa.ifname)
+
+ #
+ # Remove provisioning file, this should cause a disconnect.
+ #
+ os.remove("/var/lib/iwd/ssidWPA2-1.psk")
+
+ self.assertEqual(len(wd.list_known_networks()), 1)
+
+ condition = 'not obj.connected'
+ wd.wait_for_object_condition(wpa_network.network_object, condition)
+
+ condition = 'obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ hotspot_network = device.get_ordered_network("Hotspot")
+ self.assertEqual(hotspot_network.type, NetworkType.eap)
+
+ #
+ # Since there are no other provisioned networks, we should do ANQP and
+ # autoconnect to the hotspot network.
+ #
+ condition = 'obj.connected'
+ wd.wait_for_object_condition(hotspot_network.network_object, condition)
+
+ sleep(2)
+
+ testutil.test_iface_operstate()
+ testutil.test_ifaces_connected(device.name, hapd_hotspot.ifname)
+
+ os.remove('/var/lib/iwd/hotspot/autoconnect.conf')
+ IWD.copy_to_storage('ssidWPA2-1.psk')
+
+ self.assertEqual(len(wd.list_known_networks()), 1)
+
+ #
+ # make sure removal of hotspot conf file resulted in disconnect
+ #
+ condition = 'not obj.connected'
+ wd.wait_for_object_condition(wpa_network.network_object, condition)
+
+ condition = 'obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ hotspot_network = device.get_ordered_network("ssidWPA2-1")
+ self.assertEqual(hotspot_network.type, NetworkType.psk)
+
+ condition = 'obj.connected'
+ wd.wait_for_object_condition(hotspot_network.network_object, condition)
+
+ sleep(2)
+
+ testutil.test_iface_operstate()
+ testutil.test_ifaces_connected(device.name, hapd_wpa.ifname)
+
+ @classmethod
+ def setUpClass(cls):
+ IWD.copy_to_hotspot('autoconnect.conf')
+ IWD.copy_to_storage('ssidWPA2-1.psk')
+ conf = '[General]\ndisable_anqp=0\n'
+ os.system('echo "%s" > /tmp/main.conf' % conf)
+
+ @classmethod
+ def tearDownClass(cls):
+ IWD.clear_storage()
+ os.remove('/tmp/main.conf')
+
+if __name__ == '__main__':
+ unittest.main(exit=True)
diff --git a/autotests/testHotspot/hw.conf b/autotests/testHotspot/hw.conf
@@ -1,8 +1,12 @@
[SETUP]
-num_radios=2
+num_radios=6
tmpfs_extra_stuff=../misc/certs:eap_users.text:example.conf:hessid.conf
max_test_exec_interval_sec=60
start_iwd=0
[HOSTAPD]
rad0=ssidHotspot.conf
+rad1=ssidWPA2-1.conf
+rad2=ssidWPA2-2.conf
+rad3=ssidWPA2-3.conf
+rad4=ssidHotspotUnconfigured.conf
diff --git a/autotests/testHotspot/ssidHotspot.conf b/autotests/testHotspot/ssidHotspot.conf
@@ -1,3 +1,4 @@
+ctrl_interface=/var/run/hostapd
hw_mode=g
channel=1
wpa=2
diff --git a/autotests/testHotspot/ssidHotspotUnconfigured.conf b/autotests/testHotspot/ssidHotspotUnconfigured.conf
@@ -0,0 +1,45 @@
+hw_mode=g
+channel=1
+wpa=2
+ssid=Hotspot-Unconfigured
+rsn_pairwise=CCMP
+wpa_key_mgmt=WPA-EAP
+ieee80211w=1
+ieee8021x=1
+hessid=02:00:00:00:04:00
+interworking=1
+access_network_type=14
+internet=1
+asra=0
+esr=0
+uesa=0
+osen=0
+
+venue_group=7
+venue_type=1
+venue_name=P"eng:Example venue"
+venue_name=fin:Esimerkkipaikka
+roaming_consortium=112233
+roaming_consortium=1020304050
+roaming_consortium=010203040506
+roaming_consortium=fedcba
+domain_name=example.com,another.example.com
+nai_realm=1,naiexample.com,13[5:6],21[2:4][5:7]
+nai_realm=1,another.naiexample.com
+nai_realm=1,yet.another.naiexample.com
+
+hs20=1
+hs20_wan_metrics=01:8000:1000:80:240:3000
+hs20_conn_capab=1:0:2
+hs20_conn_capab=6:22:1
+hs20_conn_capab=17:5060:0
+hs20_operating_class=5173
+
+disable_dgaf=0
+network_auth_type=00
+
+eap_server=1
+eap_user_file=/tmp/eap_users.text
+ca_cert=/tmp/certs/cert-ca.pem
+server_cert=/tmp/certs/cert-server.pem
+private_key=/tmp/certs/cert-server-key.pem
diff --git a/autotests/testHotspot/ssidWPA2-1.conf b/autotests/testHotspot/ssidWPA2-1.conf
@@ -0,0 +1,7 @@
+hw_mode=g
+channel=2
+ssid=ssidWPA2-1
+
+wpa=2
+wpa_pairwise=CCMP
+wpa_passphrase=secret123
diff --git a/autotests/testHotspot/ssidWPA2-1.psk b/autotests/testHotspot/ssidWPA2-1.psk
@@ -0,0 +1,2 @@
+[Security]
+Passphrase=secret123
diff --git a/autotests/testHotspot/ssidWPA2-2.conf b/autotests/testHotspot/ssidWPA2-2.conf
@@ -0,0 +1,7 @@
+hw_mode=g
+channel=3
+ssid=ssidWPA2-2
+
+wpa=2
+wpa_pairwise=CCMP
+wpa_passphrase=secret123
diff --git a/autotests/testHotspot/ssidWPA2-3.conf b/autotests/testHotspot/ssidWPA2-3.conf
@@ -0,0 +1,7 @@
+hw_mode=g
+channel=4
+ssid=ssidWPA2-3
+
+wpa=2
+wpa_pairwise=CCMP
+wpa_passphrase=secret123