tests: WPS operations on channel 14 and on 5 GHz band

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-04-06 13:49:05 +03:00
parent fb8d53e0bb
commit daad14ccd4
2 changed files with 104 additions and 0 deletions

View file

@ -194,6 +194,50 @@ def test_ap_wps_conf(dev, apdev):
if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A": if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A":
raise Exception("Device name not available in STA command") raise Exception("Device name not available in STA command")
def test_ap_wps_conf_5ghz(dev, apdev):
"""WPS PBC provisioning with configured AP on 5 GHz band"""
try:
ssid = "test-wps-conf"
params = { "ssid": ssid, "eap_server": "1", "wps_state": "2",
"wpa_passphrase": "12345678", "wpa": "2",
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
"country_code": "FI", "hw_mode": "a", "channel": "36" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
logger.info("WPS provisioning step")
hapd.request("WPS_PBC")
dev[0].request("WPS_PBC")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None:
raise Exception("Association with the AP timed out")
sta = hapd.get_sta(dev[0].p2p_interface_addr())
if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A":
raise Exception("Device name not available in STA command")
finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
def test_ap_wps_conf_chan14(dev, apdev):
"""WPS PBC provisioning with configured AP on channel 14"""
try:
ssid = "test-wps-conf"
params = { "ssid": ssid, "eap_server": "1", "wps_state": "2",
"wpa_passphrase": "12345678", "wpa": "2",
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
"country_code": "JP", "hw_mode": "b", "channel": "14" }
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
logger.info("WPS provisioning step")
hapd.request("WPS_PBC")
dev[0].request("WPS_PBC")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None:
raise Exception("Association with the AP timed out")
sta = hapd.get_sta(dev[0].p2p_interface_addr())
if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A":
raise Exception("Device name not available in STA command")
finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
def test_ap_wps_twice(dev, apdev): def test_ap_wps_twice(dev, apdev):
"""WPS provisioning with twice to change passphrase""" """WPS provisioning with twice to change passphrase"""
ssid = "test-wps-twice" ssid = "test-wps-twice"

View file

@ -227,6 +227,66 @@ def test_nfc_wps_handover(dev, apdev):
raise Exception("Association with the AP timed out") raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid) check_wpa2_connection(dev[0], apdev[0], ssid)
def test_nfc_wps_handover_5ghz(dev, apdev):
"""Connect to WPS AP with NFC connection handover on 5 GHz band"""
try:
ssid = "test-wps-nfc-handover"
params = ap_wps_params(ssid)
params["country_code"] = "FI"
params["hw_mode"] = "a"
params["channel"] = "36"
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
logger.info("NFC connection handover")
req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip()
if "FAIL" in req:
raise Exception("Failed to generate NFC connection handover request")
sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip()
if "FAIL" in sel:
raise Exception("Failed to generate NFC connection handover select")
res = hapd.request("NFC_REPORT_HANDOVER RESP WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to hostapd")
dev[0].dump_monitor()
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None:
raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid)
finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
def test_nfc_wps_handover_chan14(dev, apdev):
"""Connect to WPS AP with NFC connection handover on channel 14"""
try:
ssid = "test-wps-nfc-handover"
params = ap_wps_params(ssid)
params["country_code"] = "JP"
params["hw_mode"] = "b"
params["channel"] = "14"
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
logger.info("NFC connection handover")
req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip()
if "FAIL" in req:
raise Exception("Failed to generate NFC connection handover request")
sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip()
if "FAIL" in sel:
raise Exception("Failed to generate NFC connection handover select")
res = hapd.request("NFC_REPORT_HANDOVER RESP WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to hostapd")
dev[0].dump_monitor()
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
if ev is None:
raise Exception("Association with the AP timed out")
check_wpa2_connection(dev[0], apdev[0], ssid)
finally:
subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
def test_nfc_wps_handover_with_pw_token_set(dev, apdev): def test_nfc_wps_handover_with_pw_token_set(dev, apdev):
"""Connect to WPS AP with NFC connection handover (wps_nfc_* set)""" """Connect to WPS AP with NFC connection handover (wps_nfc_* set)"""
ssid = "test-wps-nfc-handover2" ssid = "test-wps-nfc-handover2"