tests: Test WPS ER UPnP functionality to add Enrollees
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
c64686229f
commit
6edaee9c82
2 changed files with 151 additions and 8 deletions
|
@ -104,10 +104,7 @@ def test_ap_wps_reg_connect(dev, apdev):
|
||||||
logger.info("WPS provisioning step")
|
logger.info("WPS provisioning step")
|
||||||
dev[0].request("SET ignore_old_scan_res 1")
|
dev[0].request("SET ignore_old_scan_res 1")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
dev[0].request("WPS_REG " + apdev[0]['bssid'] + " " + appin)
|
dev[0].wps_reg(apdev[0]['bssid'], appin)
|
||||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
|
||||||
if ev is None:
|
|
||||||
raise Exception("Association with the AP timed out")
|
|
||||||
status = dev[0].get_status()
|
status = dev[0].get_status()
|
||||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||||
raise Exception("Not fully connected")
|
raise Exception("Not fully connected")
|
||||||
|
@ -130,10 +127,8 @@ def test_ap_wps_reg_config(dev, apdev):
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
new_ssid = "wps-new-ssid"
|
new_ssid = "wps-new-ssid"
|
||||||
new_passphrase = "1234567890"
|
new_passphrase = "1234567890"
|
||||||
dev[0].request("WPS_REG " + apdev[0]['bssid'] + " " + appin + " " + new_ssid.encode("hex") + " WPA2PSK CCMP " + new_passphrase.encode("hex"))
|
dev[0].wps_reg(apdev[0]['bssid'], appin, new_ssid, "WPA2PSK", "CCMP",
|
||||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
new_passphrase)
|
||||||
if ev is None:
|
|
||||||
raise Exception("Association with the AP timed out")
|
|
||||||
status = dev[0].get_status()
|
status = dev[0].get_status()
|
||||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||||
raise Exception("Not fully connected")
|
raise Exception("Not fully connected")
|
||||||
|
@ -193,3 +188,130 @@ def test_ap_wps_pbc_overlap_2sta(dev, apdev):
|
||||||
raise Exception("PBC session overlap not detected (dev1)")
|
raise Exception("PBC session overlap not detected (dev1)")
|
||||||
if "config_error=12" not in ev:
|
if "config_error=12" not in ev:
|
||||||
raise Exception("PBC session overlap not correctly reported (dev1)")
|
raise Exception("PBC session overlap not correctly reported (dev1)")
|
||||||
|
|
||||||
|
def test_ap_wps_er_add_enrollee(dev, apdev):
|
||||||
|
"""WPS ER configuring AP and adding a new enrollee using PIN"""
|
||||||
|
ssid = "wps-er-add-enrollee"
|
||||||
|
ap_pin = "12345670"
|
||||||
|
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'],
|
||||||
|
{ "ssid": ssid, "eap_server": "1", "wps_state": "1",
|
||||||
|
"device_name": "Wireless AP", "manufacturer": "Company",
|
||||||
|
"model_name": "WAP", "model_number": "123",
|
||||||
|
"serial_number": "12345", "device_type": "6-0050F204-1",
|
||||||
|
"os_version": "01020300",
|
||||||
|
"config_methods": "label push_button",
|
||||||
|
"ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
|
||||||
|
logger.info("WPS configuration step")
|
||||||
|
new_passphrase = "1234567890"
|
||||||
|
dev[0].dump_monitor()
|
||||||
|
dev[0].request("SET ignore_old_scan_res 1")
|
||||||
|
dev[0].wps_reg(apdev[0]['bssid'], ap_pin, ssid, "WPA2PSK", "CCMP",
|
||||||
|
new_passphrase)
|
||||||
|
status = dev[0].get_status()
|
||||||
|
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||||
|
raise Exception("Not fully connected")
|
||||||
|
if status['ssid'] != ssid:
|
||||||
|
raise Exception("Unexpected SSID")
|
||||||
|
if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
|
||||||
|
raise Exception("Unexpected encryption configuration")
|
||||||
|
if status['key_mgmt'] != 'WPA2-PSK':
|
||||||
|
raise Exception("Unexpected key_mgmt")
|
||||||
|
|
||||||
|
logger.info("Start ER")
|
||||||
|
dev[0].request("WPS_ER_START ifname=lo")
|
||||||
|
ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("AP discovery timed out")
|
||||||
|
if ap_uuid not in ev:
|
||||||
|
raise Exception("Expected AP UUID not found")
|
||||||
|
|
||||||
|
logger.info("Learn AP configuration through UPnP")
|
||||||
|
dev[0].dump_monitor()
|
||||||
|
dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin)
|
||||||
|
ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("AP learn timed out")
|
||||||
|
if ap_uuid not in ev:
|
||||||
|
raise Exception("Expected AP UUID not in settings")
|
||||||
|
if "ssid=" + ssid not in ev:
|
||||||
|
raise Exception("Expected SSID not in settings")
|
||||||
|
if "key=" + new_passphrase not in ev:
|
||||||
|
raise Exception("Expected passphrase not in settings")
|
||||||
|
|
||||||
|
logger.info("Add Enrollee using ER")
|
||||||
|
pin = dev[1].wps_read_pin()
|
||||||
|
dev[0].dump_monitor()
|
||||||
|
dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr())
|
||||||
|
dev[1].request("SET ignore_old_scan_res 1")
|
||||||
|
dev[1].dump_monitor()
|
||||||
|
dev[1].request("WPS_PIN any " + pin)
|
||||||
|
ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Enrollee did not report success")
|
||||||
|
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Association with the AP timed out")
|
||||||
|
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("WPS ER did not report success")
|
||||||
|
hwsim_utils.test_connectivity_sta(dev[0], dev[1])
|
||||||
|
|
||||||
|
def test_ap_wps_er_add_enrollee_pbc(dev, apdev):
|
||||||
|
"""WPS ER connected to AP and adding a new enrollee using PBC"""
|
||||||
|
ssid = "wps-er-add-enrollee-pbc"
|
||||||
|
ap_pin = "12345670"
|
||||||
|
ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'],
|
||||||
|
{ "ssid": ssid, "eap_server": "1", "wps_state": "2",
|
||||||
|
"wpa_passphrase": "12345678", "wpa": "2",
|
||||||
|
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
|
||||||
|
"device_name": "Wireless AP", "manufacturer": "Company",
|
||||||
|
"model_name": "WAP", "model_number": "123",
|
||||||
|
"serial_number": "12345", "device_type": "6-0050F204-1",
|
||||||
|
"os_version": "01020300",
|
||||||
|
"config_methods": "label push_button",
|
||||||
|
"ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
|
||||||
|
logger.info("Learn AP configuration")
|
||||||
|
dev[0].dump_monitor()
|
||||||
|
dev[0].request("SET ignore_old_scan_res 1")
|
||||||
|
dev[0].wps_reg(apdev[0]['bssid'], ap_pin)
|
||||||
|
status = dev[0].get_status()
|
||||||
|
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||||
|
raise Exception("Not fully connected")
|
||||||
|
|
||||||
|
logger.info("Start ER")
|
||||||
|
dev[0].request("WPS_ER_START ifname=lo")
|
||||||
|
ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("AP discovery timed out")
|
||||||
|
if ap_uuid not in ev:
|
||||||
|
raise Exception("Expected AP UUID not found")
|
||||||
|
|
||||||
|
logger.info("Use learned network configuration on ER")
|
||||||
|
dev[0].request("WPS_ER_SET_CONFIG " + ap_uuid + " 0")
|
||||||
|
|
||||||
|
logger.info("Add Enrollee using ER and PBC")
|
||||||
|
dev[0].dump_monitor()
|
||||||
|
enrollee = dev[1].p2p_interface_addr()
|
||||||
|
dev[1].request("SET ignore_old_scan_res 1")
|
||||||
|
dev[1].dump_monitor()
|
||||||
|
dev[1].request("WPS_PBC")
|
||||||
|
|
||||||
|
ev = dev[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Enrollee discovery timed out")
|
||||||
|
if enrollee not in ev:
|
||||||
|
raise Exception("Expected Enrollee not found")
|
||||||
|
dev[0].request("WPS_ER_PBC " + enrollee)
|
||||||
|
|
||||||
|
ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Enrollee did not report success")
|
||||||
|
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Association with the AP timed out")
|
||||||
|
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("WPS ER did not report success")
|
||||||
|
hwsim_utils.test_connectivity_sta(dev[0], dev[1])
|
||||||
|
|
|
@ -41,6 +41,7 @@ class WpaSupplicant:
|
||||||
self.request("FLUSH")
|
self.request("FLUSH")
|
||||||
self.request("SET ignore_old_scan_res 0")
|
self.request("SET ignore_old_scan_res 0")
|
||||||
self.group_ifname = None
|
self.group_ifname = None
|
||||||
|
self.dump_monitor()
|
||||||
|
|
||||||
def add_network(self):
|
def add_network(self):
|
||||||
id = self.request("ADD_NETWORK")
|
id = self.request("ADD_NETWORK")
|
||||||
|
@ -370,3 +371,23 @@ class WpaSupplicant:
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Roaming with the AP timed out")
|
raise Exception("Roaming with the AP timed out")
|
||||||
self.dump_monitor()
|
self.dump_monitor()
|
||||||
|
|
||||||
|
def wps_reg(self, bssid, pin, new_ssid=None, key_mgmt=None, cipher=None,
|
||||||
|
new_passphrase=None):
|
||||||
|
self.dump_monitor()
|
||||||
|
if new_ssid:
|
||||||
|
self.request("WPS_REG " + bssid + " " + pin + " " +
|
||||||
|
new_ssid.encode("hex") + " " + key_mgmt + " " +
|
||||||
|
cipher + " " + new_passphrase.encode("hex"))
|
||||||
|
ev = self.wait_event(["WPS-SUCCESS"], timeout=15)
|
||||||
|
else:
|
||||||
|
self.request("WPS_REG " + bssid + " " + pin)
|
||||||
|
ev = self.wait_event(["WPS-CRED-RECEIVED"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("WPS cred timed out")
|
||||||
|
ev = self.wait_event(["WPS-FAIL"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("WPS timed out")
|
||||||
|
ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Association with the AP timed out")
|
||||||
|
|
Loading…
Reference in a new issue