From fab49f6145f44760e888b3844a9fff9440a85b27 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 15 Mar 2019 12:10:37 +0200 Subject: tests: Python coding style cleanup (pylint3 bad-whitespace) Signed-off-by: Jouni Malinen --- tests/hwsim/fst_module_aux.py | 28 +- tests/hwsim/fst_test_common.py | 20 +- tests/hwsim/hostapd.py | 68 +- tests/hwsim/hwsim.py | 24 +- tests/hwsim/hwsim_utils.py | 4 +- tests/hwsim/netlink.py | 70 +- tests/hwsim/nl80211.py | 4 +- tests/hwsim/radius_das.py | 2 +- tests/hwsim/remotehost.py | 4 +- tests/hwsim/run-tests.py | 12 +- tests/hwsim/test_ap_acs.py | 10 +- tests/hwsim/test_ap_ciphers.py | 152 +-- tests/hwsim/test_ap_config.py | 302 +++--- tests/hwsim/test_ap_csa.py | 6 +- tests/hwsim/test_ap_dynamic.py | 76 +- tests/hwsim/test_ap_eap.py | 572 +++++------ tests/hwsim/test_ap_ft.py | 370 +++---- tests/hwsim/test_ap_hs20.py | 1468 +++++++++++++-------------- tests/hwsim/test_ap_ht.py | 442 ++++----- tests/hwsim/test_ap_open.py | 136 +-- tests/hwsim/test_ap_params.py | 38 +- tests/hwsim/test_ap_psk.py | 222 ++--- tests/hwsim/test_ap_qosmap.py | 58 +- tests/hwsim/test_ap_roam.py | 14 +- tests/hwsim/test_ap_tdls.py | 102 +- tests/hwsim/test_ap_track.py | 152 +-- tests/hwsim/test_ap_vht.py | 577 ++++++----- tests/hwsim/test_ap_vlan.py | 106 +- tests/hwsim/test_ap_wps.py | 1743 +++++++++++++++++---------------- tests/hwsim/test_authsrv.py | 50 +- tests/hwsim/test_autoscan.py | 4 +- tests/hwsim/test_bgscan.py | 30 +- tests/hwsim/test_cfg80211.py | 17 +- tests/hwsim/test_connect_cmd.py | 30 +- tests/hwsim/test_dbus.py | 1047 ++++++++++---------- tests/hwsim/test_dfs.py | 8 +- tests/hwsim/test_dpp.py | 500 +++++----- tests/hwsim/test_eap_proto.py | 870 ++++++++-------- tests/hwsim/test_erp.py | 32 +- tests/hwsim/test_ext_password.py | 4 +- tests/hwsim/test_fils.py | 168 ++-- tests/hwsim/test_fst_config.py | 68 +- tests/hwsim/test_fst_module.py | 138 +-- tests/hwsim/test_gas.py | 266 ++--- tests/hwsim/test_hapd_ctrl.py | 582 +++++------ tests/hwsim/test_hostapd_oom.py | 8 +- tests/hwsim/test_hs20_filter.py | 16 +- tests/hwsim/test_hs20_pps_mo.py | 4 +- tests/hwsim/test_ibss.py | 30 +- tests/hwsim/test_ieee8021x.py | 72 +- tests/hwsim/test_kernel.py | 4 +- tests/hwsim/test_macsec.py | 73 +- tests/hwsim/test_mbo.py | 76 +- tests/hwsim/test_monitor_interface.py | 2 +- tests/hwsim/test_multi_ap.py | 70 +- tests/hwsim/test_nfc_wps.py | 72 +- tests/hwsim/test_oce.py | 20 +- tests/hwsim/test_ocv.py | 298 +++--- tests/hwsim/test_owe.py | 150 +-- tests/hwsim/test_p2p_autogo.py | 2 +- tests/hwsim/test_p2p_channel.py | 84 +- tests/hwsim/test_p2p_concurrency.py | 38 +- tests/hwsim/test_p2p_device.py | 6 +- tests/hwsim/test_p2p_discovery.py | 8 +- tests/hwsim/test_p2p_grpform.py | 22 +- tests/hwsim/test_p2p_invitation.py | 14 +- tests/hwsim/test_p2p_messages.py | 38 +- tests/hwsim/test_p2p_persistent.py | 23 +- tests/hwsim/test_p2p_service.py | 72 +- tests/hwsim/test_p2p_set.py | 50 +- tests/hwsim/test_p2ps.py | 50 +- tests/hwsim/test_pmksa_cache.py | 56 +- tests/hwsim/test_radio_work.py | 2 +- tests/hwsim/test_radius.py | 96 +- tests/hwsim/test_rfkill.py | 6 +- tests/hwsim/test_rrm.py | 334 +++---- tests/hwsim/test_sae.py | 226 ++--- tests/hwsim/test_scan.py | 296 +++--- tests/hwsim/test_sigma_dut.py | 278 +++--- tests/hwsim/test_ssid.py | 24 +- tests/hwsim/test_sta_dynamic.py | 6 +- tests/hwsim/test_suite_b.py | 194 ++-- tests/hwsim/test_tnc.py | 66 +- tests/hwsim/test_wep.py | 50 +- tests/hwsim/test_wext.py | 22 +- tests/hwsim/test_wmediumd.py | 14 +- tests/hwsim/test_wnm.py | 390 ++++---- tests/hwsim/test_wpas_ap.py | 12 +- tests/hwsim/test_wpas_config.py | 278 +++--- tests/hwsim/test_wpas_ctrl.py | 640 ++++++------ tests/hwsim/test_wpas_mesh.py | 66 +- tests/hwsim/test_wpas_wmm_ac.py | 36 +- tests/hwsim/tshark.py | 8 +- tests/hwsim/utils.py | 2 +- tests/hwsim/vm/parallel-vm.py | 131 ++- tests/hwsim/wlantest.py | 2 +- tests/hwsim/wpasupplicant.py | 96 +- tests/remote/config.py | 26 +- tests/remote/monitor.py | 20 +- tests/remote/run-tests.py | 4 +- tests/remote/rutils.py | 28 +- tests/remote/test_example.py | 4 +- 102 files changed, 7663 insertions(+), 7648 deletions(-) diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index 58aabc5..03a0bd7 100644 --- a/tests/hwsim/fst_module_aux.py +++ b/tests/hwsim/fst_module_aux.py @@ -141,7 +141,7 @@ def disconnect_external_sta(sta, ap, check_disconnect=True): sta.request("DISCONNECT") if check_disconnect: hap = ap.get_instance() - ev = hap.wait_event([ "AP-STA-DISCONNECTED" ], timeout=10) + ev = hap.wait_event(["AP-STA-DISCONNECTED"], timeout=10) if ev is None: raise Exception("No disconnection event received from %s" % ap.get_ssid()) @@ -313,7 +313,7 @@ class FstDevice: return None return res.splitlines() - def configure_session(self, sid, new_iface, old_iface = None): + def configure_session(self, sid, new_iface, old_iface=None): """Calls session_set for a number of parameters some of which are stored in "self" while others are passed to this function explicitly. If old_iface is None, current iface is used; if old_iface is an empty @@ -370,7 +370,7 @@ class FstDevice: return s def send_test_session_setup_request(self, fsts_id, - additional_parameter = None): + additional_parameter=None): request = "FST-MANAGER TEST_REQUEST SEND_SETUP_REQUEST " + fsts_id if additional_parameter is not None: request += " " + additional_parameter @@ -380,7 +380,7 @@ class FstDevice: return s def send_test_session_setup_response(self, fsts_id, - response, additional_parameter = None): + response, additional_parameter=None): request = "FST-MANAGER TEST_REQUEST SEND_SETUP_RESPONSE " + fsts_id + " " + response if additional_parameter is not None: request += " " + additional_parameter @@ -453,7 +453,7 @@ class FstDevice: s = self.grequest("FST-MANAGER SESSION_INITIATE"+ strsid) if not s.startswith('OK'): raise Exception("Cannot initiate fst session: %s" % s) - ev = self.peer_obj.wait_gevent([ "FST-EVENT-SESSION" ], timeout=5) + ev = self.peer_obj.wait_gevent(["FST-EVENT-SESSION"], timeout=5) if ev is None: raise Exception("No FST-EVENT-SESSION received") # We got FST event @@ -520,7 +520,7 @@ class FstDevice: raise Exception("Cannot transfer fst session: %s" % s) result = '' while result == '': - ev = self.peer_obj.wait_gevent([ "FST-EVENT-SESSION" ], timeout=5) + ev = self.peer_obj.wait_gevent(["FST-EVENT-SESSION"], timeout=5) if ev is None: raise Exception("Missing session transfer event") # We got FST event. We expect TRANSITION_CONFIRMED state and then @@ -536,7 +536,7 @@ class FstDevice: return result def wait_for_tear_down(self): - ev = self.wait_gevent([ "FST-EVENT-SESSION" ], timeout=5) + ev = self.wait_gevent(["FST-EVENT-SESSION"], timeout=5) if ev is None: raise Exception("No FST-EVENT-SESSION received") # We got FST event @@ -582,7 +582,7 @@ class FstDevice: # # FstAP class # -class FstAP (FstDevice): +class FstAP(FstDevice): def __init__(self, iface, ssid, mode, chan, fst_group, fst_pri, fst_llt=None, rsn=False): """If fst_group is empty, then FST parameters will not be set @@ -610,7 +610,7 @@ class FstAP (FstDevice): params['wpa_key_mgmt'] = 'WPA-PSK' params['rsn_pairwise'] = 'CCMP' params['wpa_passphrase'] = '12345678' - self.hapd=hostapd.add_ap(self.iface, params) + self.hapd = hostapd.add_ap(self.iface, params) if not self.hapd.ping(): raise Exception("Could not ping FST hostapd") self.reg_ctrl.start() @@ -660,7 +660,7 @@ class FstAP (FstDevice): # Maybe station is not connected? addr = None else: - addr=sta['addr'] + addr = sta['addr'] return addr def grequest(self, req): @@ -688,7 +688,7 @@ class FstAP (FstDevice): # # FstSTA class # -class FstSTA (FstDevice): +class FstSTA(FstDevice): def __init__(self, iface, fst_group, fst_pri, fst_llt=None, rsn=False): """If fst_group is empty, then FST parameters will not be set If fst_llt is empty, the parameter will not be set and the default value @@ -790,7 +790,7 @@ class FstSTA (FstDevice): h.connect(ssid, **kwargs) self.connected = ap if check_connection: - ev = ap.wait_event([ "AP-STA-CONNECTED" ], timeout=10) + ev = ap.wait_event(["AP-STA-CONNECTED"], timeout=10) if ev is None: self.connected = None raise Exception("No connection event received from %s" % ssid) @@ -804,7 +804,7 @@ class FstSTA (FstDevice): h.request("DISCONNECT") if check_disconnect: hap = self.connected.get_instance() - ev = hap.wait_event([ "AP-STA-DISCONNECTED" ], timeout=10) + ev = hap.wait_event(["AP-STA-DISCONNECTED"], timeout=10) if ev is None: raise Exception("No disconnection event received from %s" % self.connected.get_ssid()) h.dump_monitor() @@ -820,7 +820,7 @@ class FstSTA (FstDevice): h.request("DISCONNECT") if check_disconnect: hap = self.connected - ev = hap.wait_event([ "AP-STA-DISCONNECTED" ], timeout=10) + ev = hap.wait_event(["AP-STA-DISCONNECTED"], timeout=10) if ev is None: raise Exception("No disconnection event received from AP") h.dump_monitor() diff --git a/tests/hwsim/fst_test_common.py b/tests/hwsim/fst_test_common.py index 8fbd71f..4b6bab0 100644 --- a/tests/hwsim/fst_test_common.py +++ b/tests/hwsim/fst_test_common.py @@ -12,15 +12,15 @@ import hostapd logger = logging.getLogger() -fst_test_def_group='fstg0' -fst_test_def_freq_g='2412' # Channel 1 -fst_test_def_freq_a='5180' # Channel 36 -fst_test_def_chan_g='1' -fst_test_def_chan_a='36' -fst_test_def_prio_low='100' -fst_test_def_prio_high='110' -fst_test_def_llt='100' -fst_test_def_reg_domain='00' +fst_test_def_group = 'fstg0' +fst_test_def_freq_g = '2412' # Channel 1 +fst_test_def_freq_a = '5180' # Channel 36 +fst_test_def_chan_g = '1' +fst_test_def_chan_a = '36' +fst_test_def_prio_low = '100' +fst_test_def_prio_high = '110' +fst_test_def_llt = '100' +fst_test_def_reg_domain = '00' class HapdRegCtrl: def __init__(self): @@ -89,7 +89,7 @@ class HapdRegCtrl: logger.debug("fst hostapd: regulatory domain ready") def fst_clear_regdom(): - cmd = subprocess.Popen([ "iw", "reg", "get" ], stdout=subprocess.PIPE) + cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE) res = cmd.stdout.read().decode() cmd.stdout.close() if "country 00:" not in res: diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 7578159..2ca1e3d 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -19,7 +19,7 @@ hapd_ctrl = '/var/run/hostapd' hapd_global = '/var/run/hostapd-global' def mac2tuple(mac): - return struct.unpack('6B', binascii.unhexlify(mac.replace(':',''))) + return struct.unpack('6B', binascii.unhexlify(mac.replace(':', ''))) class HostapdGlobal: def __init__(self, apdev=None, global_ctrl_override=None): @@ -267,7 +267,7 @@ class Hostapd: lines = res.splitlines() vals = dict() for l in lines: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals @@ -282,7 +282,7 @@ class Hostapd: lines = res.splitlines() vals = dict() for l in lines: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals @@ -297,7 +297,7 @@ class Hostapd: lines = res.splitlines() vals = dict() for l in lines: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals @@ -349,7 +349,7 @@ class Hostapd: vals['addr'] = l first = False else: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals @@ -373,7 +373,7 @@ class Hostapd: if addr not in l: continue vals = dict() - [index,aa,pmkid,expiration,opportunistic] = l.split(' ') + [index, aa, pmkid, expiration, opportunistic] = l.split(' ') vals['index'] = index vals['pmkid'] = pmkid vals['expiration'] = expiration @@ -433,14 +433,14 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30, if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults() - fields = [ "ssid", "wpa_passphrase", "nas_identifier", "wpa_key_mgmt", - "wpa", - "wpa_pairwise", "rsn_pairwise", "auth_server_addr", - "acct_server_addr", "osu_server_uri" ] + fields = ["ssid", "wpa_passphrase", "nas_identifier", "wpa_key_mgmt", + "wpa", + "wpa_pairwise", "rsn_pairwise", "auth_server_addr", + "acct_server_addr", "osu_server_uri"] for field in fields: if field in params: hapd.set(field, params[field]) - for f,v in list(params.items()): + for f, v in list(params.items()): if f in fields: continue if isinstance(v, list): @@ -518,9 +518,9 @@ def terminate(apdev): hapd_global.terminate() def wpa2_params(ssid=None, passphrase=None): - params = { "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "CCMP" } + params = {"wpa": "2", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "CCMP"} if ssid: params["ssid"] = ssid if passphrase: @@ -528,9 +528,9 @@ def wpa2_params(ssid=None, passphrase=None): return params def wpa_params(ssid=None, passphrase=None): - params = { "wpa": "1", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP" } + params = {"wpa": "1", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP"} if ssid: params["ssid"] = ssid if passphrase: @@ -538,10 +538,10 @@ def wpa_params(ssid=None, passphrase=None): return params def wpa_mixed_params(ssid=None, passphrase=None): - params = { "wpa": "3", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP", - "rsn_pairwise": "CCMP" } + params = {"wpa": "3", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP", + "rsn_pairwise": "CCMP"} if ssid: params["ssid"] = ssid if passphrase: @@ -549,10 +549,10 @@ def wpa_mixed_params(ssid=None, passphrase=None): return params def radius_params(): - params = { "auth_server_addr": "127.0.0.1", - "auth_server_port": "1812", - "auth_server_shared_secret": "radius", - "nas_identifier": "nas.w1.fi" } + params = {"auth_server_addr": "127.0.0.1", + "auth_server_port": "1812", + "auth_server_shared_secret": "radius", + "nas_identifier": "nas.w1.fi"} return params def wpa_eap_params(ssid=None): @@ -576,8 +576,8 @@ def wpa2_eap_params(ssid=None): return params def b_only_params(channel="1", ssid=None, country=None): - params = { "hw_mode" : "b", - "channel" : channel } + params = {"hw_mode": "b", + "channel": channel} if ssid: params["ssid"] = ssid if country: @@ -585,8 +585,8 @@ def b_only_params(channel="1", ssid=None, country=None): return params def g_only_params(channel="1", ssid=None, country=None): - params = { "hw_mode" : "g", - "channel" : channel } + params = {"hw_mode": "g", + "channel": channel} if ssid: params["ssid"] = ssid if country: @@ -594,8 +594,8 @@ def g_only_params(channel="1", ssid=None, country=None): return params def a_only_params(channel="36", ssid=None, country=None): - params = { "hw_mode" : "a", - "channel" : channel } + params = {"hw_mode": "a", + "channel": channel} if ssid: params["ssid"] = ssid if country: @@ -603,9 +603,9 @@ def a_only_params(channel="36", ssid=None, country=None): return params def ht20_params(channel="1", ssid=None, country=None): - params = { "ieee80211n" : "1", - "channel" : channel, - "hw_mode" : "g" } + params = {"ieee80211n": "1", + "channel": channel, + "hw_mode": "g"} if int(channel) > 14: params["hw_mode"] = "a" if ssid: diff --git a/tests/hwsim/hwsim.py b/tests/hwsim/hwsim.py index bc1be85..bc8aabd 100644 --- a/tests/hwsim/hwsim.py +++ b/tests/hwsim/hwsim.py @@ -10,13 +10,13 @@ import netlink, os # constants -HWSIM_CMD_CREATE_RADIO = 4 -HWSIM_CMD_DESTROY_RADIO = 5 +HWSIM_CMD_CREATE_RADIO = 4 +HWSIM_CMD_DESTROY_RADIO = 5 -HWSIM_ATTR_CHANNELS = 9 -HWSIM_ATTR_RADIO_ID = 10 -HWSIM_ATTR_SUPPORT_P2P_DEVICE = 14 -HWSIM_ATTR_USE_CHANCTX = 15 +HWSIM_ATTR_CHANNELS = 9 +HWSIM_ATTR_RADIO_ID = 10 +HWSIM_ATTR_SUPPORT_P2P_DEVICE = 14 +HWSIM_ATTR_USE_CHANCTX = 15 # the controller class class HWSimController(object): @@ -35,17 +35,17 @@ class HWSimController(object): attrs.append(netlink.FlagAttr(HWSIM_ATTR_SUPPORT_P2P_DEVICE)) msg = netlink.GenlMessage(self._fid, HWSIM_CMD_CREATE_RADIO, - flags = netlink.NLM_F_REQUEST | - netlink.NLM_F_ACK, - attrs = attrs) + flags=netlink.NLM_F_REQUEST | + netlink.NLM_F_ACK, + attrs=attrs) return msg.send_and_recv(self._conn).ret def destroy_radio(self, radio_id): attrs = [netlink.U32Attr(HWSIM_ATTR_RADIO_ID, radio_id)] msg = netlink.GenlMessage(self._fid, HWSIM_CMD_DESTROY_RADIO, - flags = netlink.NLM_F_REQUEST | - netlink.NLM_F_ACK, - attrs = attrs) + flags=netlink.NLM_F_REQUEST | + netlink.NLM_F_ACK, + attrs=attrs) msg.send_and_recv(self._conn) class HWSimRadio(object): diff --git a/tests/hwsim/hwsim_utils.py b/tests/hwsim/hwsim_utils.py index cf49b13..dccdefc 100644 --- a/tests/hwsim/hwsim_utils.py +++ b/tests/hwsim/hwsim_utils.py @@ -248,8 +248,8 @@ def set_rx_rssi(dev, val): """ tx_power = (val + 50) * 100 ifname = dev.get_driver_status_field("ifname") - (res, data) = dev.cmd_execute([ 'iw', ifname, 'set', 'txpower', - 'fixed', str(tx_power)] ) + (res, data) = dev.cmd_execute(['iw', ifname, 'set', 'txpower', + 'fixed', str(tx_power)]) if res != 0: raise Exception("Failed to set RSSI to %d" % val) diff --git a/tests/hwsim/netlink.py b/tests/hwsim/netlink.py index eba6102..7e6327a 100644 --- a/tests/hwsim/netlink.py +++ b/tests/hwsim/netlink.py @@ -32,7 +32,7 @@ class Attr(object): def _dump(self): hdr = struct.pack("HH", len(self._data) + 4, self._type) length = len(self._data) - pad = ((length + 4 - 1) & ~3 ) - length + pad = ((length + 4 - 1) & ~3) - length return hdr + self._data + b'\x00' * pad def __repr__(self): @@ -87,23 +87,23 @@ class Nested(Attr): hdr = struct.pack("HH", length+4, self.type) return hdr + contents -NETLINK_ROUTE = 0 -NETLINK_UNUSED = 1 -NETLINK_USERSOCK = 2 -NETLINK_FIREWALL = 3 -NETLINK_INET_DIAG = 4 -NETLINK_NFLOG = 5 -NETLINK_XFRM = 6 -NETLINK_SELINUX = 7 -NETLINK_ISCSI = 8 -NETLINK_AUDIT = 9 -NETLINK_FIB_LOOKUP = 10 -NETLINK_CONNECTOR = 11 -NETLINK_NETFILTER = 12 -NETLINK_IP6_FW = 13 -NETLINK_DNRTMSG = 14 -NETLINK_KOBJECT_UEVENT = 15 -NETLINK_GENERIC = 16 +NETLINK_ROUTE = 0 +NETLINK_UNUSED = 1 +NETLINK_USERSOCK = 2 +NETLINK_FIREWALL = 3 +NETLINK_INET_DIAG = 4 +NETLINK_NFLOG = 5 +NETLINK_XFRM = 6 +NETLINK_SELINUX = 7 +NETLINK_ISCSI = 8 +NETLINK_AUDIT = 9 +NETLINK_FIB_LOOKUP = 10 +NETLINK_CONNECTOR = 11 +NETLINK_NETFILTER = 12 +NETLINK_IP6_FW = 13 +NETLINK_DNRTMSG = 14 +NETLINK_KOBJECT_UEVENT = 15 +NETLINK_GENERIC = 16 class Message(object): def __init__(self, msg_type, flags=0, seq=-1, payload=None): @@ -184,30 +184,30 @@ def parse_attributes(data): while len(data): attr_len, attr_type = struct.unpack("HH", data[:4]) attrs[attr_type] = Attr(attr_type, data[4:attr_len]) - attr_len = ((attr_len + 4 - 1) & ~3 ) + attr_len = ((attr_len + 4 - 1) & ~3) data = data[attr_len:] return attrs -CTRL_CMD_UNSPEC = 0 -CTRL_CMD_NEWFAMILY = 1 -CTRL_CMD_DELFAMILY = 2 -CTRL_CMD_GETFAMILY = 3 -CTRL_CMD_NEWOPS = 4 -CTRL_CMD_DELOPS = 5 -CTRL_CMD_GETOPS = 6 +CTRL_CMD_UNSPEC = 0 +CTRL_CMD_NEWFAMILY = 1 +CTRL_CMD_DELFAMILY = 2 +CTRL_CMD_GETFAMILY = 3 +CTRL_CMD_NEWOPS = 4 +CTRL_CMD_DELOPS = 5 +CTRL_CMD_GETOPS = 6 -CTRL_ATTR_UNSPEC = 0 -CTRL_ATTR_FAMILY_ID = 1 -CTRL_ATTR_FAMILY_NAME = 2 -CTRL_ATTR_VERSION = 3 -CTRL_ATTR_HDRSIZE = 4 -CTRL_ATTR_MAXATTR = 5 -CTRL_ATTR_OPS = 6 +CTRL_ATTR_UNSPEC = 0 +CTRL_ATTR_FAMILY_ID = 1 +CTRL_ATTR_FAMILY_NAME = 2 +CTRL_ATTR_VERSION = 3 +CTRL_ATTR_HDRSIZE = 4 +CTRL_ATTR_MAXATTR = 5 +CTRL_ATTR_OPS = 6 class GenlHdr(object): - def __init__(self, cmd, version = 0): + def __init__(self, cmd, version=0): self.cmd = cmd self.version = version def _dump(self): @@ -216,7 +216,7 @@ class GenlHdr(object): def _genl_hdr_parse(data): return GenlHdr(*struct.unpack("BBxx", data)) -GENL_ID_CTRL = NLMSG_MIN_TYPE +GENL_ID_CTRL = NLMSG_MIN_TYPE class GenlMessage(Message): def __init__(self, family, cmd, attrs=[], flags=0): diff --git a/tests/hwsim/nl80211.py b/tests/hwsim/nl80211.py index 08fae83..55642c0 100644 --- a/tests/hwsim/nl80211.py +++ b/tests/hwsim/nl80211.py @@ -338,14 +338,14 @@ def build_nl80211_attr_flag(id): return build_nl80211_attr(id, b'') def build_nl80211_attr_mac(id, val): - addr = struct.unpack('6B', binascii.unhexlify(val.replace(':',''))) + addr = struct.unpack('6B', binascii.unhexlify(val.replace(':', ''))) aval = struct.pack('<6B', *addr) return build_nl80211_attr(id, aval) def parse_nl80211_attrs(msg): attrs = {} while len(msg) >= 4: - alen,attr = struct.unpack("@HH", msg[0:4]) + alen, attr = struct.unpack("@HH", msg[0:4]) if alen < 4: raise Exception("Too short nl80211 attribute") alen -= 4 diff --git a/tests/hwsim/radius_das.py b/tests/hwsim/radius_das.py index 58dc9d6..4a43da4 100644 --- a/tests/hwsim/radius_das.py +++ b/tests/hwsim/radius_das.py @@ -17,7 +17,7 @@ class DisconnectPacket(pyrad.packet.Packet): def RequestPacket(self): attr = b'' - for code,datalst in sorted(self.items()): + for code, datalst in sorted(self.items()): for data in datalst: attr += self._PktEncodeAttribute(code, data) diff --git a/tests/hwsim/remotehost.py b/tests/hwsim/remotehost.py index aa83c1d..50f46c3 100644 --- a/tests/hwsim/remotehost.py +++ b/tests/hwsim/remotehost.py @@ -80,10 +80,10 @@ class Host(): if self.host is None: cmd = command else: - cmd = ["ssh", self.user + "@" + self.host, ' '.join(command)] + cmd = ["ssh", self.user + "@" + self.host, ' '.join(command)] _cmd = self.name + " execute_run: " + ' '.join(cmd) logger.debug(_cmd) - t = threading.Thread(target = execute_thread, args=(cmd, res)) + t = threading.Thread(target=execute_thread, args=(cmd, res)) t.start() return t diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index dbc0292..2627c57 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -117,8 +117,8 @@ def report(conn, prefill, build, commit, run, test, result, duration, logdir, print("sql: %r" % (params, )) if result == "FAIL": - for log in [ "log", "log0", "log1", "log2", "log3", "log5", - "hostapd", "dmesg", "hwsim0", "hwsim0.pcapng" ]: + for log in ["log", "log0", "log1", "log2", "log3", "log5", + "hostapd", "dmesg", "hwsim0", "hwsim0.pcapng"]: add_log_file(conn, test, run, log, logdir + "/" + test + "." + log) @@ -194,7 +194,7 @@ def main(): logger.debug("Import test cases from " + t) mod = __import__(m.group(1)) test_modules.append(mod.__name__.replace('test_', '', 1)) - for key,val in mod.__dict__.items(): + for key, val in mod.__dict__.items(): if key.startswith("test_"): tests.append(val) test_names = list(set([t.__name__.replace('test_', '', 1) for t in tests])) @@ -343,8 +343,8 @@ def main(): dev0 = WpaSupplicant('wlan0', '/tmp/wpas-wlan0') dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') dev2 = WpaSupplicant('wlan2', '/tmp/wpas-wlan2') - dev = [ dev0, dev1, dev2 ] - apdev = [ ] + dev = [dev0, dev1, dev2] + apdev = [] apdev.append({"ifname": 'wlan3', "bssid": "02:00:00:00:03:00"}) apdev.append({"ifname": 'wlan4', "bssid": "02:00:00:00:04:00"}) @@ -385,7 +385,7 @@ def main(): logger.info("Parallel execution - %d/%d" % (split_server, split_total)) split_server -= 1 tests_to_run.sort(key=lambda t: t.__name__) - tests_to_run = [x for i,x in enumerate(tests_to_run) if i % split_total == split_server] + tests_to_run = [x for i, x in enumerate(tests_to_run) if i % split_total == split_server] if args.shuffle_tests: from random import shuffle diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py index ec126e6..0046000 100644 --- a/tests/hwsim/test_ap_acs.py +++ b/tests/hwsim/test_ap_acs.py @@ -16,15 +16,15 @@ from test_dfs import wait_dfs_event def force_prev_ap_on_24g(ap): # For now, make sure the last operating channel was on 2.4 GHz band to get # sufficient survey data from mac80211_hwsim. - hostapd.add_ap(ap, { "ssid": "open" }) + hostapd.add_ap(ap, {"ssid": "open"}) time.sleep(0.1) hostapd.remove_bss(ap) def force_prev_ap_on_5g(ap): # For now, make sure the last operating channel was on 5 GHz band to get # sufficient survey data from mac80211_hwsim. - hostapd.add_ap(ap, { "ssid": "open", "hw_mode": "a", - "channel": "36", "country_code": "US" }) + hostapd.add_ap(ap, {"ssid": "open", "hw_mode": "a", + "channel": "36", "country_code": "US"}) time.sleep(0.1) hostapd.remove_bss(ap) @@ -424,7 +424,7 @@ def test_ap_acs_dfs(dev, apdev, params): raise Exception("Unexpected interface state") freq = int(hapd.get_status_field("freq")) - if freq not in [ 5260, 5280, 5300, 5320 ]: + if freq not in [5260, 5280, 5300, 5320]: raise Exception("Unexpected frequency: %d" % freq) dev[0].connect("test-acs", psk="12345678", scan_freq=str(freq)) @@ -473,7 +473,7 @@ def test_ap_acs_vht160_dfs(dev, apdev, params): raise Exception("Unexpected interface state") freq = int(hapd.get_status_field("freq")) - if freq not in [ 5180, 5500 ]: + if freq not in [5180, 5500]: raise Exception("Unexpected frequency: %d" % freq) dev[0].connect("test-acs", psk="12345678", scan_freq=str(freq)) diff --git a/tests/hwsim/test_ap_ciphers.py b/tests/hwsim/test_ap_ciphers.py index 8e5b2d6..59fb651 100644 --- a/tests/hwsim/test_ap_ciphers.py +++ b/tests/hwsim/test_ap_ciphers.py @@ -22,11 +22,11 @@ def check_cipher(dev, ap, cipher, group_cipher=None): raise HwsimSkip("Cipher %s not supported" % cipher) if group_cipher and group_cipher not in dev.get_capability("group"): raise HwsimSkip("Cipher %s not supported" % group_cipher) - params = { "ssid": "test-wpa2-psk", - "wpa_passphrase": "12345678", - "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": cipher } + params = {"ssid": "test-wpa2-psk", + "wpa_passphrase": "12345678", + "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": cipher} if group_cipher: params["group_cipher"] = group_cipher else: @@ -39,13 +39,13 @@ def check_cipher(dev, ap, cipher, group_cipher=None): def check_group_mgmt_cipher(dev, ap, cipher, sta_req_cipher=None): if cipher not in dev.get_capability("group_mgmt"): raise HwsimSkip("Cipher %s not supported" % cipher) - params = { "ssid": "test-wpa2-psk-pmf", - "wpa_passphrase": "12345678", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "WPA-PSK-SHA256", - "rsn_pairwise": "CCMP", - "group_mgmt_cipher": cipher } + params = {"ssid": "test-wpa2-psk-pmf", + "wpa_passphrase": "12345678", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "WPA-PSK-SHA256", + "rsn_pairwise": "CCMP", + "group_mgmt_cipher": cipher} hapd = hostapd.add_ap(ap, params) Wlantest.setup(hapd) @@ -68,7 +68,7 @@ def check_group_mgmt_cipher(dev, ap, cipher, sta_req_cipher=None): group_mgmt = "BIP" else: group_mgmt = cipher - res = wt.info_bss('group_mgmt', ap['bssid']).strip() + res = wt.info_bss('group_mgmt', ap['bssid']).strip() if res != group_mgmt: raise Exception("Unexpected group mgmt cipher: " + res) @@ -83,27 +83,27 @@ def test_ap_cipher_tkip_countermeasures_ap(dev, apdev): """WPA-PSK/TKIP countermeasures (detected by AP)""" skip_with_fips(dev[0]) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (dev[0].get_driver_status_field("phyname"), dev[0].ifname) - if dev[0].cmd_execute([ "ls", testfile ])[0] != 0: + if dev[0].cmd_execute(["ls", testfile])[0] != 0: raise HwsimSkip("tkip_mic_test not supported in mac80211") - params = { "ssid": "tkip-countermeasures", - "wpa_passphrase": "12345678", - "wpa": "1", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP" } + params = {"ssid": "tkip-countermeasures", + "wpa_passphrase": "12345678", + "wpa": "1", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("tkip-countermeasures", psk="12345678", pairwise="TKIP", group="TKIP", scan_freq="2412") dev[0].dump_monitor() - dev[0].cmd_execute([ "echo", "-n", apdev[0]['bssid'], ">", testfile ], + dev[0].cmd_execute(["echo", "-n", apdev[0]['bssid'], ">", testfile], shell=True) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected disconnection on first Michael MIC failure") - dev[0].cmd_execute([ "echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile ], + dev[0].cmd_execute(["echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile], shell=True) ev = dev[0].wait_disconnected(timeout=10, error="No disconnection after two Michael MIC failures") @@ -117,15 +117,15 @@ def test_ap_cipher_tkip_countermeasures_ap_mixed_mode(dev, apdev): """WPA+WPA2-PSK/TKIP countermeasures (detected by mixed mode AP)""" skip_with_fips(dev[0]) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (dev[0].get_driver_status_field("phyname"), dev[0].ifname) - if dev[0].cmd_execute([ "ls", testfile ])[0] != 0: + if dev[0].cmd_execute(["ls", testfile])[0] != 0: raise HwsimSkip("tkip_mic_test not supported in mac80211") - params = { "ssid": "tkip-countermeasures", - "wpa_passphrase": "12345678", - "wpa": "3", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP", - "rsn_pairwise": "CCMP" } + params = {"ssid": "tkip-countermeasures", + "wpa_passphrase": "12345678", + "wpa": "3", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP", + "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("tkip-countermeasures", psk="12345678", @@ -134,13 +134,13 @@ def test_ap_cipher_tkip_countermeasures_ap_mixed_mode(dev, apdev): pairwise="CCMP", scan_freq="2412") dev[0].dump_monitor() - dev[0].cmd_execute([ "echo", "-n", apdev[0]['bssid'], ">", testfile ], + dev[0].cmd_execute(["echo", "-n", apdev[0]['bssid'], ">", testfile], shell=True) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected disconnection on first Michael MIC failure") - dev[0].cmd_execute([ "echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile ], + dev[0].cmd_execute(["echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile], shell=True) ev = dev[0].wait_disconnected(timeout=10, @@ -164,28 +164,28 @@ def test_ap_cipher_tkip_countermeasures_ap_mixed_mode(dev, apdev): def test_ap_cipher_tkip_countermeasures_sta(dev, apdev): """WPA-PSK/TKIP countermeasures (detected by STA)""" skip_with_fips(dev[0]) - params = { "ssid": "tkip-countermeasures", - "wpa_passphrase": "12345678", - "wpa": "1", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP" } + params = {"ssid": "tkip-countermeasures", + "wpa_passphrase": "12345678", + "wpa": "1", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP"} hapd = hostapd.add_ap(apdev[0], params) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname']) - if hapd.cmd_execute([ "ls", testfile ])[0] != 0: + if hapd.cmd_execute(["ls", testfile])[0] != 0: raise HwsimSkip("tkip_mic_test not supported in mac80211") dev[0].connect("tkip-countermeasures", psk="12345678", pairwise="TKIP", group="TKIP", scan_freq="2412") dev[0].dump_monitor() - hapd.cmd_execute([ "echo", "-n", dev[0].own_addr(), ">", testfile ], + hapd.cmd_execute(["echo", "-n", dev[0].own_addr(), ">", testfile], shell=True) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected disconnection on first Michael MIC failure") - hapd.cmd_execute([ "echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile ], + hapd.cmd_execute(["echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile], shell=True) ev = dev[0].wait_disconnected(timeout=10, error="No disconnection after two Michael MIC failures") @@ -200,15 +200,15 @@ def test_ap_cipher_tkip_countermeasures_sta2(dev, apdev, params): if not params['long']: raise HwsimSkip("Skip test case with long duration due to --long not specified") skip_with_fips(dev[0]) - params = { "ssid": "tkip-countermeasures", - "wpa_passphrase": "12345678", - "wpa": "1", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP" } + params = {"ssid": "tkip-countermeasures", + "wpa_passphrase": "12345678", + "wpa": "1", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP"} hapd = hostapd.add_ap(apdev[0], params) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname']) - if hapd.cmd_execute([ "ls", testfile ])[0] != 0: + if hapd.cmd_execute(["ls", testfile])[0] != 0: raise HwsimSkip("tkip_mic_test not supported in mac80211") dev[0].connect("tkip-countermeasures", psk="12345678", @@ -218,7 +218,7 @@ def test_ap_cipher_tkip_countermeasures_sta2(dev, apdev, params): pairwise="TKIP", group="TKIP", scan_freq="2412") dev[1].dump_monitor() - hapd.cmd_execute([ "echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile ], + hapd.cmd_execute(["echo", "-n", "ff:ff:ff:ff:ff:ff", ">", testfile], shell=True) ev = dev[0].wait_disconnected(timeout=10, error="No disconnection after two Michael MIC failure") @@ -305,21 +305,21 @@ def test_ap_cipher_gcmp_ccmp(dev, apdev, params): """WPA2-PSK/GCMP/CCMP ciphers""" config = os.path.join(params['logdir'], 'ap_cipher_gcmp_ccmp.conf') - for cipher in [ "CCMP", "GCMP", "CCMP-256", "GCMP-256" ]: + for cipher in ["CCMP", "GCMP", "CCMP-256", "GCMP-256"]: if cipher not in dev[0].get_capability("pairwise"): raise HwsimSkip("Cipher %s not supported" % cipher) if cipher not in dev[0].get_capability("group"): raise HwsimSkip("Group cipher %s not supported" % cipher) - params = { "ssid": "test-wpa2-psk", - "wpa_passphrase": "12345678", - "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "CCMP GCMP CCMP-256 GCMP-256" } + params = {"ssid": "test-wpa2-psk", + "wpa_passphrase": "12345678", + "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "CCMP GCMP CCMP-256 GCMP-256"} hapd = hostapd.add_ap(apdev[0], params) - for cipher in [ "CCMP", "GCMP", "CCMP-256", "GCMP-256" ]: + for cipher in ["CCMP", "GCMP", "CCMP-256", "GCMP-256"]: dev[0].connect("test-wpa2-psk", psk="12345678", pairwise=cipher, group="CCMP", scan_freq="2412") if dev[0].get_status_field("group_cipher") != "CCMP": @@ -365,12 +365,12 @@ def test_ap_cipher_mixed_wpa_wpa2(dev, apdev): skip_with_fips(dev[0]) ssid = "test-wpa-wpa2-psk" passphrase = "12345678" - params = { "ssid": ssid, - "wpa_passphrase": passphrase, - "wpa": "3", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "CCMP", - "wpa_pairwise": "TKIP" } + params = {"ssid": ssid, + "wpa_passphrase": passphrase, + "wpa": "3", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "CCMP", + "wpa_pairwise": "TKIP"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect(ssid, psk=passphrase, proto="WPA2", pairwise="CCMP", group="TKIP", scan_freq="2412") @@ -443,17 +443,17 @@ def test_ap_cipher_bip_cmac_256_req(dev, apdev): def test_ap_cipher_bip_req_mismatch(dev, apdev): """WPA2-PSK with BIP cipher mismatch""" group_mgmt = dev[0].get_capability("group_mgmt") - for cipher in [ "AES-128-CMAC", "BIP-GMAC-256" ]: + for cipher in ["AES-128-CMAC", "BIP-GMAC-256"]: if cipher not in group_mgmt: raise HwsimSkip("Cipher %s not supported" % cipher) - params = { "ssid": "test-wpa2-psk-pmf", - "wpa_passphrase": "12345678", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "WPA-PSK-SHA256", - "rsn_pairwise": "CCMP", - "group_mgmt_cipher": "AES-128-CMAC" } + params = {"ssid": "test-wpa2-psk-pmf", + "wpa_passphrase": "12345678", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "WPA-PSK-SHA256", + "rsn_pairwise": "CCMP", + "group_mgmt_cipher": "AES-128-CMAC"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(hapd.own_addr(), 2412) @@ -520,11 +520,11 @@ def test_ap_cipher_replay_protection_ap_gcmp(dev, apdev): run_ap_cipher_replay_protection_ap(dev, apdev, "GCMP") def run_ap_cipher_replay_protection_ap(dev, apdev, cipher): - params = { "ssid": "test-wpa2-psk", - "wpa_passphrase": "12345678", - "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": cipher } + params = {"ssid": "test-wpa2-psk", + "wpa_passphrase": "12345678", + "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": cipher} hapd = hostapd.add_ap(apdev[0], params) phy = hapd.get_driver_status_field("phyname") @@ -589,11 +589,11 @@ def test_ap_cipher_replay_protection_sta_gtk_gcmp(dev, apdev): run_ap_cipher_replay_protection_sta(dev, apdev, "GCMP", gtk=True) def run_ap_cipher_replay_protection_sta(dev, apdev, cipher, gtk=False): - params = { "ssid": "test-wpa2-psk", - "wpa_passphrase": "12345678", - "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": cipher } + params = {"ssid": "test-wpa2-psk", + "wpa_passphrase": "12345678", + "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": cipher} hapd = hostapd.add_ap(apdev[0], params) Wlantest.setup(hapd) diff --git a/tests/hwsim/test_ap_config.py b/tests/hwsim/test_ap_config.py index cede63c..412a821 100644 --- a/tests/hwsim/test_ap_config.py +++ b/tests/hwsim/test_ap_config.py @@ -20,35 +20,35 @@ def test_ap_config_errors(dev, apdev): """Various hostapd configuration errors""" # IEEE 802.11d without country code - params = { "ssid": "foo", "ieee80211d": "1" } + params = {"ssid": "foo", "ieee80211d": "1"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (ieee80211d without country_code)") hostapd.remove_bss(apdev[0]) # IEEE 802.11h without IEEE 802.11d - params = { "ssid": "foo", "ieee80211h": "1" } + params = {"ssid": "foo", "ieee80211h": "1"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d") hostapd.remove_bss(apdev[0]) # Power Constraint without IEEE 802.11d - params = { "ssid": "foo", "local_pwr_constraint": "1" } + params = {"ssid": "foo", "local_pwr_constraint": "1"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)") hostapd.remove_bss(apdev[0]) # Spectrum management without Power Constraint - params = { "ssid": "foo", "spectrum_mgmt_required": "1" } + params = {"ssid": "foo", "spectrum_mgmt_required": "1"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)") hostapd.remove_bss(apdev[0]) # IEEE 802.1X without authentication server - params = { "ssid": "foo", "ieee8021x": "1" } + params = {"ssid": "foo", "ieee8021x": "1"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (ieee8021x)") @@ -63,10 +63,10 @@ def test_ap_config_errors(dev, apdev): hostapd.remove_bss(apdev[0]) # FT without NAS-Identifier - params = { "wpa": "2", - "wpa_key_mgmt": "FT-PSK", - "rsn_pairwise": "CCMP", - "wpa_passphrase": "12345678" } + params = {"wpa": "2", + "wpa_key_mgmt": "FT-PSK", + "rsn_pairwise": "CCMP", + "wpa_passphrase": "12345678"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success (FT without nas_identifier)") @@ -89,7 +89,7 @@ def test_ap_config_errors(dev, apdev): def test_ap_config_reload(dev, apdev, params): """hostapd configuration reload""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "foo" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "foo"}) hapd.set("ssid", "foobar") with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: pid = int(f.read()) @@ -169,7 +169,7 @@ def run_ap_config_reload_on_sighup(dev, apdev, params, ht=True): if not os.path.exists(prg): prg = '../../hostapd/hostapd' write_hostapd_config(conffile, apdev[0]['ifname'], "test-1", ht=ht) - cmd = [ prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, conffile ] + cmd = [prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, conffile] res = subprocess.check_call(cmd) if res != 0: raise Exception("Could not start hostapd: %s" % str(res)) @@ -217,7 +217,7 @@ def test_ap_config_reload_on_sighup_bss_changes(dev, apdev, params): if not os.path.exists(prg): prg = '../../hostapd/hostapd' write_hostapd_config(conffile, apdev[0]['ifname'], "test", bss2=True) - cmd = [ prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, conffile ] + cmd = [prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, conffile] res = subprocess.check_call(cmd) if res != 0: raise Exception("Could not start hostapd: %s" % str(res)) @@ -276,7 +276,7 @@ def test_ap_config_reload_before_enable(dev, apdev, params): def test_ap_config_sigusr1(dev, apdev, params): """hostapd SIGUSR1""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "foobar" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "foobar"}) with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: pid = int(f.read()) os.kill(pid, signal.SIGUSR1) @@ -285,45 +285,45 @@ def test_ap_config_sigusr1(dev, apdev, params): def test_ap_config_invalid_value(dev, apdev, params): """Ignoring invalid hostapd configuration parameter updates""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test" }, no_enable=True) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test"}, no_enable=True) not_exist = "/tmp/hostapd-test/does-not-exist" - tests = [ ("driver", "foobar"), - ("ssid2", "Q"), - ("macaddr_acl", "255"), - ("accept_mac_file", not_exist), - ("deny_mac_file", not_exist), - ("eapol_version", "255"), - ("eap_user_file", not_exist), - ("wep_key_len_broadcast", "-1"), - ("wep_key_len_unicast", "-1"), - ("wep_rekey_period", "-1"), - ("eap_rekey_period", "-1"), - ("radius_client_addr", "foo"), - ("acs_chan_bias", "-1:0.8"), - ("acs_chan_bias", "1"), - ("acs_chan_bias", "1:p"), - ("acs_chan_bias", "1:-0.8"), - ("acs_chan_bias", "1:0.8p"), - ("dtim_period", "0"), - ("bss_load_update_period", "-1"), - ("send_probe_response", "255"), - ("beacon_rate", "ht:-1"), - ("beacon_rate", "ht:32"), - ("beacon_rate", "vht:-1"), - ("beacon_rate", "vht:10"), - ("beacon_rate", "9"), - ("beacon_rate", "10001"), - ("vlan_file", not_exist), - ("bss", ""), - ("bssid", "foo"), - ("extra_cred", not_exist), - ("anqp_elem", "265"), - ("anqp_elem", "265"), - ("anqp_elem", "265:1"), - ("anqp_elem", "265:1q"), - ("fst_priority", ""), - ("fils_cache_id", "q"), - ("unknown-item", "foo") ] + tests = [("driver", "foobar"), + ("ssid2", "Q"), + ("macaddr_acl", "255"), + ("accept_mac_file", not_exist), + ("deny_mac_file", not_exist), + ("eapol_version", "255"), + ("eap_user_file", not_exist), + ("wep_key_len_broadcast", "-1"), + ("wep_key_len_unicast", "-1"), + ("wep_rekey_period", "-1"), + ("eap_rekey_period", "-1"), + ("radius_client_addr", "foo"), + ("acs_chan_bias", "-1:0.8"), + ("acs_chan_bias", "1"), + ("acs_chan_bias", "1:p"), + ("acs_chan_bias", "1:-0.8"), + ("acs_chan_bias", "1:0.8p"), + ("dtim_period", "0"), + ("bss_load_update_period", "-1"), + ("send_probe_response", "255"), + ("beacon_rate", "ht:-1"), + ("beacon_rate", "ht:32"), + ("beacon_rate", "vht:-1"), + ("beacon_rate", "vht:10"), + ("beacon_rate", "9"), + ("beacon_rate", "10001"), + ("vlan_file", not_exist), + ("bss", ""), + ("bssid", "foo"), + ("extra_cred", not_exist), + ("anqp_elem", "265"), + ("anqp_elem", "265"), + ("anqp_elem", "265:1"), + ("anqp_elem", "265:1q"), + ("fst_priority", ""), + ("fils_cache_id", "q"), + ("unknown-item", "foo")] for field, val in tests: if "FAIL" not in hapd.request("SET %s %s" % (field, val)): raise Exception("Invalid %s accepted" % field) @@ -333,49 +333,49 @@ def test_ap_config_invalid_value(dev, apdev, params): def test_ap_config_eap_user_file_parsing(dev, apdev, params): """hostapd eap_user_file parsing""" tmp = os.path.join(params['logdir'], 'ap_vlan_file_parsing.tmp') - hapd = hostapd.add_ap(apdev[0], { "ssid": "foobar" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "foobar"}) for i in range(2): if "OK" not in hapd.request("SET eap_user_file auth_serv/eap_user.conf"): raise Exception("eap_user_file rejected") - tests = [ "#\n\n*\tTLS\nradius_accept_attr=:", - "foo\n", - "\"foo\n", - "\"foo\"\n", - "\"foo\" FOOBAR\n", - "\"foo\" " + 10*"TLS," + "TLS \"\n", - "\"foo\" TLS \nfoo\n", - "\"foo\" PEAP hash:foo\n", - "\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b7586q\n", - "\"foo\" PEAP 01020\n", - "\"foo\" PEAP 010q\n", - "\"foo\" TLS\nradius_accept_attr=123:x:012\n", - "\"foo\" TLS\nradius_accept_attr=123:x:012q\n", - "\"foo\" TLS\nradius_accept_attr=123:Q:01\n", - "\"foo\" TLS\nradius_accept_attr=123\nfoo\n" ] + tests = ["#\n\n*\tTLS\nradius_accept_attr=:", + "foo\n", + "\"foo\n", + "\"foo\"\n", + "\"foo\" FOOBAR\n", + "\"foo\" " + 10*"TLS," + "TLS \"\n", + "\"foo\" TLS \nfoo\n", + "\"foo\" PEAP hash:foo\n", + "\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b7586q\n", + "\"foo\" PEAP 01020\n", + "\"foo\" PEAP 010q\n", + "\"foo\" TLS\nradius_accept_attr=123:x:012\n", + "\"foo\" TLS\nradius_accept_attr=123:x:012q\n", + "\"foo\" TLS\nradius_accept_attr=123:Q:01\n", + "\"foo\" TLS\nradius_accept_attr=123\nfoo\n"] for t in tests: with open(tmp, "w") as f: f.write(t) if "FAIL" not in hapd.request("SET eap_user_file " + tmp): raise Exception("Invalid eap_user_file accepted") - tests = [ ("\"foo\" TLS\n", 2, "hostapd_config_read_eap_user"), - ("\"foo\" PEAP \"foo\"\n", 3, "hostapd_config_read_eap_user"), - ("\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b75861\n", 3, - "hostapd_config_read_eap_user"), - ("\"foo\" PEAP 0102\n", 3, "hostapd_config_read_eap_user"), - ("\"foo\" TLS\nradius_accept_attr=123\n", 1, - "=hostapd_parse_radius_attr"), - ("\"foo\" TLS\nradius_accept_attr=123\n", 1, - "wpabuf_alloc;hostapd_parse_radius_attr"), - ("\"foo\" TLS\nradius_accept_attr=123:s:foo\n", 2, - "hostapd_parse_radius_attr"), - ("\"foo\" TLS\nradius_accept_attr=123:x:0102\n", 2, - "hostapd_parse_radius_attr"), - ("\"foo\" TLS\nradius_accept_attr=123:d:1\n", 2, - "hostapd_parse_radius_attr"), - ("* TLS\n", 1, "hostapd_config_read_eap_user") ] + tests = [("\"foo\" TLS\n", 2, "hostapd_config_read_eap_user"), + ("\"foo\" PEAP \"foo\"\n", 3, "hostapd_config_read_eap_user"), + ("\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b75861\n", 3, + "hostapd_config_read_eap_user"), + ("\"foo\" PEAP 0102\n", 3, "hostapd_config_read_eap_user"), + ("\"foo\" TLS\nradius_accept_attr=123\n", 1, + "=hostapd_parse_radius_attr"), + ("\"foo\" TLS\nradius_accept_attr=123\n", 1, + "wpabuf_alloc;hostapd_parse_radius_attr"), + ("\"foo\" TLS\nradius_accept_attr=123:s:foo\n", 2, + "hostapd_parse_radius_attr"), + ("\"foo\" TLS\nradius_accept_attr=123:x:0102\n", 2, + "hostapd_parse_radius_attr"), + ("\"foo\" TLS\nradius_accept_attr=123:d:1\n", 2, + "hostapd_parse_radius_attr"), + ("* TLS\n", 1, "hostapd_config_read_eap_user")] for t, count, func in tests: with alloc_fail(hapd, count, func): with open(tmp, "w") as f: @@ -385,55 +385,55 @@ def test_ap_config_eap_user_file_parsing(dev, apdev, params): def test_ap_config_set_oom(dev, apdev): """hostapd configuration parsing OOM""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "foobar" }) - - tests = [ (1, "hostapd_parse_das_client", - "SET radius_das_client 192.168.1.123 pw"), - (1, "hostapd_config_read_wep", "SET wep_key0 \"hello\""), - (1, "hostapd_config_read_wep", "SET wep_key0 0102030405"), - (1, "hostapd_parse_chanlist", "SET chanlist 1 6 11-13"), - (1, "hostapd_config_bss", "SET bss foo"), - (2, "hostapd_config_bss", "SET bss foo"), - (3, "hostapd_config_bss", "SET bss foo"), - (1, "add_r0kh", - "SET r0kh 02:01:02:03:04:05 r0kh-1.example.com 000102030405060708090a0b0c0d0e0f"), - (1, "add_r1kh", - "SET r1kh 02:01:02:03:04:05 02:11:22:33:44:55 000102030405060708090a0b0c0d0e0f"), - (1, "parse_roaming_consortium", "SET roaming_consortium 021122"), - (1, "parse_lang_string", "SET venue_name eng:Example venue"), - (1, "parse_3gpp_cell_net", - "SET anqp_3gpp_cell_net 244,91;310,026;234,56"), - (1, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), - (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), - (1, "parse_anqp_elem", "SET anqp_elem 265:0000"), - (2, "parse_anqp_elem", "SET anqp_elem 266:000000"), - (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2"), - (1, "hs20_parse_wan_metrics", - "SET hs20_wan_metrics 01:8000:1000:80:240:3000"), - (1, "hs20_parse_icon", - "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"), - (1, "hs20_parse_osu_server_uri", - "SET osu_server_uri https://example.com/osu/"), - (1, "hostapd_config_parse_acs_chan_bias", - "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"), - (2, "hostapd_config_parse_acs_chan_bias", - "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"), - (1, "parse_wpabuf_hex", "SET vendor_elements 01020304"), - (1, "parse_fils_realm", "SET fils_realm example.com"), - (1, "hostapd_config_fill", - "SET pac_opaque_encr_key 000102030405060708090a0b0c0d0e0f"), - (1, "hostapd_config_fill", "SET eap_message hello"), - (1, "hostapd_config_fill", - "SET wpa_psk 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"), - (1, "hostapd_config_fill", "SET time_zone EST5"), - (1, "hostapd_config_fill", - "SET network_auth_type 02http://www.example.com/redirect/"), - (1, "hostapd_config_fill", "SET domain_name example.com"), - (1, "hostapd_config_fill", "SET hs20_operating_class 5173"), - (1, "hostapd_config_fill", "SET own_ie_override 11223344"), - (1, "hostapd_parse_intlist", "SET sae_groups 19 25"), - (1, "hostapd_parse_intlist", "SET basic_rates 10 20 55 110"), - (1, "hostapd_parse_intlist", "SET supported_rates 10 20 55 110") ] + hapd = hostapd.add_ap(apdev[0], {"ssid": "foobar"}) + + tests = [(1, "hostapd_parse_das_client", + "SET radius_das_client 192.168.1.123 pw"), + (1, "hostapd_config_read_wep", "SET wep_key0 \"hello\""), + (1, "hostapd_config_read_wep", "SET wep_key0 0102030405"), + (1, "hostapd_parse_chanlist", "SET chanlist 1 6 11-13"), + (1, "hostapd_config_bss", "SET bss foo"), + (2, "hostapd_config_bss", "SET bss foo"), + (3, "hostapd_config_bss", "SET bss foo"), + (1, "add_r0kh", + "SET r0kh 02:01:02:03:04:05 r0kh-1.example.com 000102030405060708090a0b0c0d0e0f"), + (1, "add_r1kh", + "SET r1kh 02:01:02:03:04:05 02:11:22:33:44:55 000102030405060708090a0b0c0d0e0f"), + (1, "parse_roaming_consortium", "SET roaming_consortium 021122"), + (1, "parse_lang_string", "SET venue_name eng:Example venue"), + (1, "parse_3gpp_cell_net", + "SET anqp_3gpp_cell_net 244,91;310,026;234,56"), + (1, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), + (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), + (1, "parse_anqp_elem", "SET anqp_elem 265:0000"), + (2, "parse_anqp_elem", "SET anqp_elem 266:000000"), + (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2"), + (1, "hs20_parse_wan_metrics", + "SET hs20_wan_metrics 01:8000:1000:80:240:3000"), + (1, "hs20_parse_icon", + "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"), + (1, "hs20_parse_osu_server_uri", + "SET osu_server_uri https://example.com/osu/"), + (1, "hostapd_config_parse_acs_chan_bias", + "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"), + (2, "hostapd_config_parse_acs_chan_bias", + "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"), + (1, "parse_wpabuf_hex", "SET vendor_elements 01020304"), + (1, "parse_fils_realm", "SET fils_realm example.com"), + (1, "hostapd_config_fill", + "SET pac_opaque_encr_key 000102030405060708090a0b0c0d0e0f"), + (1, "hostapd_config_fill", "SET eap_message hello"), + (1, "hostapd_config_fill", + "SET wpa_psk 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"), + (1, "hostapd_config_fill", "SET time_zone EST5"), + (1, "hostapd_config_fill", + "SET network_auth_type 02http://www.example.com/redirect/"), + (1, "hostapd_config_fill", "SET domain_name example.com"), + (1, "hostapd_config_fill", "SET hs20_operating_class 5173"), + (1, "hostapd_config_fill", "SET own_ie_override 11223344"), + (1, "hostapd_parse_intlist", "SET sae_groups 19 25"), + (1, "hostapd_parse_intlist", "SET basic_rates 10 20 55 110"), + (1, "hostapd_parse_intlist", "SET supported_rates 10 20 55 110")] for count, func, cmd in tests: with alloc_fail(hapd, count, func): if "FAIL" not in hapd.request(cmd): @@ -453,25 +453,25 @@ def test_ap_config_set_oom(dev, apdev): hapd.set("lci", "") hapd.set("civic", "") - tests = [ (1, "hs20_parse_icon", - "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"), - (1, "parse_roaming_consortium", "SET roaming_consortium 021122"), - (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), - (1, "parse_lang_string", "SET venue_name eng:Example venue"), - (1, "hs20_parse_osu_server_uri", - "SET osu_server_uri https://example.com/osu/"), - (1, "hs20_parse_osu_nai", "SET osu_nai anonymous@example.com"), - (1, "hostapd_parse_intlist", "SET osu_method_list 1 0"), - (1, "hs20_parse_osu_icon", "SET osu_icon icon32"), - (2, "hs20_parse_osu_icon", "SET osu_icon icon32"), - (2, "hs20_parse_osu_icon", "SET osu_icon icon32"), - (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2") ] + tests = [(1, "hs20_parse_icon", + "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"), + (1, "parse_roaming_consortium", "SET roaming_consortium 021122"), + (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), + (1, "parse_lang_string", "SET venue_name eng:Example venue"), + (1, "hs20_parse_osu_server_uri", + "SET osu_server_uri https://example.com/osu/"), + (1, "hs20_parse_osu_nai", "SET osu_nai anonymous@example.com"), + (1, "hostapd_parse_intlist", "SET osu_method_list 1 0"), + (1, "hs20_parse_osu_icon", "SET osu_icon icon32"), + (2, "hs20_parse_osu_icon", "SET osu_icon icon32"), + (2, "hs20_parse_osu_icon", "SET osu_icon icon32"), + (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2")] for count, func, cmd in tests: with alloc_fail(hapd, count, func): if "FAIL" not in hapd.request(cmd): raise Exception("Command accepted during OOM (2): " + cmd) - tests = [ (1, "parse_fils_realm", "SET fils_realm example.com") ] + tests = [(1, "parse_fils_realm", "SET fils_realm example.com")] for count, func, cmd in tests: with fail_test(hapd, count, func): if "FAIL" not in hapd.request(cmd): @@ -479,7 +479,7 @@ def test_ap_config_set_oom(dev, apdev): def test_ap_config_set_errors(dev, apdev): """hostapd configuration parsing errors""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "foobar" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "foobar"}) hapd.set("wep_key0", '"hello"') hapd.set("wep_key1", '"hello"') hapd.set("wep_key0", '') @@ -492,10 +492,10 @@ def test_ap_config_set_errors(dev, apdev): hapd.set("auth_server_addr", "127.0.0.1") hapd.set("acct_server_addr", "127.0.0.1") - tests = [ "SET eap_reauth_period -1", - "SET fst_llt ", - "SET auth_server_addr_replace foo", - "SET acct_server_addr_replace foo" ] + tests = ["SET eap_reauth_period -1", + "SET fst_llt ", + "SET auth_server_addr_replace foo", + "SET acct_server_addr_replace foo"] for t in tests: if "FAIL" not in hapd.request(t): raise Exception("Invalid command accepted: " + t) diff --git a/tests/hwsim/test_ap_csa.py b/tests/hwsim/test_ap_csa.py index 76c5d78..07ae4a8 100644 --- a/tests/hwsim/test_ap_csa.py +++ b/tests/hwsim/test_ap_csa.py @@ -14,8 +14,8 @@ import hostapd from utils import HwsimSkip def connect(dev, apdev, **kwargs): - params = { "ssid": "ap-csa", - "channel": "1" } + params = {"ssid": "ap-csa", + "channel": "1"} params.update(kwargs) ap = hostapd.add_ap(apdev[0], params) dev.connect("ap-csa", key_mgmt="NONE", scan_freq="2412") @@ -146,7 +146,7 @@ def test_ap_csa_invalid(dev, apdev): csa_supported(dev[0]) ap = connect(dev[0], apdev) - vals = [ 2461, 4900, 4901, 5181, 5746, 5699, 5895, 5899 ] + vals = [2461, 4900, 4901, 5181, 5746, 5699, 5895, 5899] for val in vals: if "FAIL" not in ap.request("CHAN_SWITCH 1 %d" % val): raise Exception("Invalid channel accepted: %d" % val) diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py index 9b6ba11..225f3ab 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -59,7 +59,7 @@ def multi_check(dev, check, scan_opt=True): first = True for i in range(num_bss): if not check[i]: - timeout=0.2 if first else 0.01 + timeout = 0.2 if first else 0.01 first = False ev = dev[i].wait_event(["CTRL-EVENT-CONNECTED"], timeout=timeout) if ev: @@ -98,59 +98,59 @@ def _test_ap_bss_add_remove(dev, apdev): ifname3 = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes one by one") hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') - multi_check(dev, [ True, False, False ]) + multi_check(dev, [True, False, False]) hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') - multi_check(dev, [ True, True, False ]) + multi_check(dev, [True, True, False]) hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) logger.info("Remove the last BSS and re-add it") hostapd.remove_bss(apdev[0], ifname3) - multi_check(dev, [ True, True, False ]) + multi_check(dev, [True, True, False]) hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) logger.info("Remove the middle BSS and re-add it") hostapd.remove_bss(apdev[0], ifname2) - multi_check(dev, [ True, False, True ]) + multi_check(dev, [True, False, True]) hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) logger.info("Remove the first BSS and re-add it and other BSSs") hostapd.remove_bss(apdev[0], ifname1) - multi_check(dev, [ False, False, False ]) + multi_check(dev, [False, False, False]) hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) logger.info("Remove two BSSes and re-add them") hostapd.remove_bss(apdev[0], ifname2) - multi_check(dev, [ True, False, True ]) + multi_check(dev, [True, False, True]) hostapd.remove_bss(apdev[0], ifname3) - multi_check(dev, [ True, False, False ]) + multi_check(dev, [True, False, False]) hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') - multi_check(dev, [ True, True, False ]) + multi_check(dev, [True, True, False]) hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) logger.info("Remove three BSSes in and re-add them") hostapd.remove_bss(apdev[0], ifname3) - multi_check(dev, [ True, True, False ]) + multi_check(dev, [True, True, False]) hostapd.remove_bss(apdev[0], ifname2) - multi_check(dev, [ True, False, False ]) + multi_check(dev, [True, False, False]) hostapd.remove_bss(apdev[0], ifname1) - multi_check(dev, [ False, False, False ]) + multi_check(dev, [False, False, False]) hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf') - multi_check(dev, [ True, False, False ]) + multi_check(dev, [True, False, False]) hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') - multi_check(dev, [ True, True, False ]) + multi_check(dev, [True, True, False]) hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) logger.info("Test error handling if a duplicate ifname is tried") hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf', ignore_error=True) - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) def test_ap_bss_add_remove_during_ht_scan(dev, apdev): """Dynamic BSS add during HT40 co-ex scan""" @@ -160,20 +160,20 @@ def test_ap_bss_add_remove_during_ht_scan(dev, apdev): ifname2 = apdev[0]['ifname'] + '-2' hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf') hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf') - multi_check(dev, [ True, True ], scan_opt=False) + multi_check(dev, [True, True], scan_opt=False) hostapd.remove_bss(apdev[0], ifname2) hostapd.remove_bss(apdev[0], ifname1) hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf') hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf') hostapd.remove_bss(apdev[0], ifname2) - multi_check(dev, [ True, False ], scan_opt=False) + multi_check(dev, [True, False], scan_opt=False) hostapd.remove_bss(apdev[0], ifname1) hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf') hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf') hostapd.remove_bss(apdev[0], ifname1) - multi_check(dev, [ False, False ]) + multi_check(dev, [False, False]) def test_ap_multi_bss_config(dev, apdev): """hostapd start with a multi-BSS configuration file""" @@ -185,18 +185,18 @@ def test_ap_multi_bss_config(dev, apdev): logger.info("Set up three BSSes with one configuration file") hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf') hapd.enable() - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) hostapd.remove_bss(apdev[0], ifname2) - multi_check(dev, [ True, False, True ]) + multi_check(dev, [True, False, True]) hostapd.remove_bss(apdev[0], ifname3) - multi_check(dev, [ True, False, False ]) + multi_check(dev, [True, False, False]) hostapd.remove_bss(apdev[0], ifname1) - multi_check(dev, [ False, False, False ]) + multi_check(dev, [False, False, False]) hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf') hapd.enable() hostapd.remove_bss(apdev[0], ifname1) - multi_check(dev, [ False, False, False ]) + multi_check(dev, [False, False, False]) def invalid_ap(ap): logger.info("Trying to start AP " + ap['ifname'] + " with invalid configuration") @@ -399,7 +399,7 @@ def hapd_bss_out_of_mem(hapd, phy, confname, count, func): def test_ap_bss_add_out_of_memory(dev, apdev): """Running out of memory while adding a BSS""" - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "open"}) ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' @@ -483,9 +483,9 @@ def _test_ap_iapp(dev, apdev): subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'up']) subprocess.call(['ip', 'route', 'add', '224.0.0.0/4', 'dev', br_ifname]) - params = { "ssid": "test-1", - "bridge": br_ifname, - "iapp_interface": br_ifname } + params = {"ssid": "test-1", + "bridge": br_ifname, + "iapp_interface": br_ifname} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -507,7 +507,7 @@ def _test_ap_iapp(dev, apdev): def test_ap_duplicate_bssid(dev, apdev): """Duplicate BSSID""" - params = { "ssid": "test" } + params = {"ssid": "test"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd.enable() ifname2 = apdev[0]['ifname'] + '-2' @@ -542,13 +542,13 @@ def test_ap_bss_config_file(dev, apdev, params): if not os.path.exists(prg): prg = '../../hostapd/hostapd' phy = get_phy(apdev[0]) - cmd = [ prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, '-S', '-T', - '-b', phy + ':bss-1.conf', '-b', phy + ':bss-2.conf', - '-b', phy + ':bss-3.conf' ] + cmd = [prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, '-S', '-T', + '-b', phy + ':bss-1.conf', '-b', phy + ':bss-2.conf', + '-b', phy + ':bss-3.conf'] res = subprocess.check_call(cmd) if res != 0: raise Exception("Could not start hostapd: %s" % str(res)) - multi_check(dev, [ True, True, True ]) + multi_check(dev, [True, True, True]) for i in range(0, 3): dev[i].request("DISCONNECT") diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 64cb267..32bafdc 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -149,7 +149,7 @@ def eap_connect(dev, hapd, method, identity, expect_cert_error=expect_cert_error) if expect_failure: return id - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") return id @@ -843,18 +843,18 @@ def test_ap_wpa2_eap_sim_oom(dev, apdev): """EAP-SIM and OOM""" params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ (1, "milenage_f2345"), - (2, "milenage_f2345"), - (3, "milenage_f2345"), - (4, "milenage_f2345"), - (5, "milenage_f2345"), - (6, "milenage_f2345"), - (7, "milenage_f2345"), - (8, "milenage_f2345"), - (9, "milenage_f2345"), - (10, "milenage_f2345"), - (11, "milenage_f2345"), - (12, "milenage_f2345") ] + tests = [(1, "milenage_f2345"), + (2, "milenage_f2345"), + (3, "milenage_f2345"), + (4, "milenage_f2345"), + (5, "milenage_f2345"), + (6, "milenage_f2345"), + (7, "milenage_f2345"), + (8, "milenage_f2345"), + (9, "milenage_f2345"), + (10, "milenage_f2345"), + (11, "milenage_f2345"), + (12, "milenage_f2345")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="SIM", @@ -1056,13 +1056,13 @@ def _test_ap_wpa2_eap_aka_ext(dev, apdev): time.sleep(0.1) dev[0].dump_monitor() - tests = [ ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:0011223344", - ":UMTS-AUTH:34", - ":UMTS-AUTH:00112233445566778899aabbccddeeff.00112233445566778899aabbccddeeff:0011223344", - ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddee:0011223344", - ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff.0011223344", - ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff0011223344", - ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:001122334q" ] + tests = [":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:0011223344", + ":UMTS-AUTH:34", + ":UMTS-AUTH:00112233445566778899aabbccddeeff.00112233445566778899aabbccddeeff:0011223344", + ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddee:0011223344", + ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff.0011223344", + ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff0011223344", + ":UMTS-AUTH:00112233445566778899aabbccddeeff:00112233445566778899aabbccddeeff:001122334q"] for t in tests: dev[0].select_network(id, freq="2412") ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15) @@ -1266,8 +1266,8 @@ def test_ap_wpa2_eap_ttls_pap(dev, apdev): ca_cert="auth_serv/ca.pem", phase2="auth=PAP") hwsim_utils.test_connectivity(dev[0], hapd) eap_reauth(dev[0], "TTLS") - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-1"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-1") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-1"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-1")]) def test_ap_wpa2_eap_ttls_pap_subject_match(dev, apdev): """WPA2-Enterprise connection using EAP-TTLS/PAP and (alt)subject_match""" @@ -1287,15 +1287,15 @@ def test_ap_wpa2_eap_ttls_pap_check_cert_subject(dev, apdev): check_check_cert_subject_support(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - tests = [ "C=FI/O=w1.fi/CN=server.w1.fi", - "C=FI/O=w1.fi", - "C=FI/CN=server.w1.fi", - "O=w1.fi/CN=server.w1.fi", - "C=FI", - "O=w1.fi", - "O=w1.*", - "CN=server.w1.fi", - "*" ] + tests = ["C=FI/O=w1.fi/CN=server.w1.fi", + "C=FI/O=w1.fi", + "C=FI/CN=server.w1.fi", + "O=w1.fi/CN=server.w1.fi", + "C=FI", + "O=w1.fi", + "O=w1.*", + "CN=server.w1.fi", + "*"] for test in tests: eap_connect(dev[0], hapd, "TTLS", "pap user", anonymous_identity="ttls", password="password", @@ -1310,14 +1310,14 @@ def test_ap_wpa2_eap_ttls_pap_check_cert_subject_neg(dev, apdev): check_check_cert_subject_support(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - tests = [ "C=US", - "C", - "C=FI1*", - "O=w1.f", - "O=w1.fi1", - "O=w1.fi/O=foo", - "O=foo/O=w1.fi", - "O=w1.fi/O=w1.fi" ] + tests = ["C=US", + "C", + "C=FI1*", + "O=w1.f", + "O=w1.fi1", + "O=w1.fi/O=foo", + "O=foo/O=w1.fi", + "O=w1.fi/O=w1.fi"] for test in tests: eap_connect(dev[0], hapd, "TTLS", "pap user", anonymous_identity="ttls", password="password", @@ -1453,9 +1453,9 @@ def test_ap_wpa2_eap_ttls_invalid_phase2(dev, apdev): """EAP-TTLS with invalid phase2 parameter values""" params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ "auth=MSCHAPv2", "auth=MSCHAPV2 autheap=MD5", - "autheap=MD5 auth=MSCHAPV2", "auth=PAP auth=CHAP", - "autheap=MD5 autheap=FOO autheap=MSCHAPV2" ] + tests = ["auth=MSCHAPv2", "auth=MSCHAPV2 autheap=MD5", + "autheap=MD5 auth=MSCHAPV2", "auth=PAP auth=CHAP", + "autheap=MD5 autheap=FOO autheap=MSCHAPV2"] for t in tests: dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS", identity="DOMAIN\mschapv2 user", @@ -1525,7 +1525,7 @@ def test_ap_wpa2_eap_ttls_mschapv2_utf8(dev, apdev): anonymous_identity="ttls", password_hex="hash:bd5844fad2489992da7fe8c5a01559cf", ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2") - for p in [ "80", "41c041e04141e041", 257*"41" ]: + for p in ["80", "41c041e04141e041", 257*"41"]: dev[2].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS", identity="utf8-user-hash", anonymous_identity="ttls", password_hex=p, @@ -1594,8 +1594,8 @@ def test_ap_wpa2_eap_ttls_eap_gtc_oom(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - tests = [ "eap_gtc_init", - "eap_msg_alloc;eap_gtc_process" ] + tests = ["eap_gtc_init", + "eap_msg_alloc;eap_gtc_process"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -2036,11 +2036,11 @@ def test_ap_wpa2_eap_peap_params(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].request("ABORT_SCAN") - tests = [ ("peap-ver0", ""), - ("peap-ver1", ""), - ("peap-ver0", "peapver=0"), - ("peap-ver1", "peapver=1") ] - for anon,phase1 in tests: + tests = [("peap-ver0", ""), + ("peap-ver1", ""), + ("peap-ver0", "peapver=0"), + ("peap-ver1", "peapver=1")] + for anon, phase1 in tests: dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="PEAP", identity="user", anonymous_identity=anon, password="password", phase1=phase1, @@ -2049,9 +2049,9 @@ def test_ap_wpa2_eap_peap_params(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ ("peap-ver0", "peapver=1"), - ("peap-ver1", "peapver=0") ] - for anon,phase1 in tests: + tests = [("peap-ver0", "peapver=1"), + ("peap-ver1", "peapver=0")] + for anon, phase1 in tests: dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="PEAP", identity="user", anonymous_identity=anon, password="password", phase1=phase1, @@ -2521,10 +2521,10 @@ def test_ap_wpa2_eap_tls_neg_altsubject_match(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ "incorrect.example.com", - "DNS:incorrect.example.com", - "DNS:w1.fi", - "DNS:erver.w1.fi" ] + tests = ["incorrect.example.com", + "DNS:incorrect.example.com", + "DNS:w1.fi", + "DNS:erver.w1.fi"] for match in tests: _test_ap_wpa2_eap_tls_neg_altsubject_match(dev, apdev, match) @@ -2733,16 +2733,16 @@ def test_ap_wpa2_eap_pwd_groups(dev, apdev): """WPA2-Enterprise connection using various EAP-pwd groups""" check_eap_capa(dev[0], "PWD") tls = dev[0].request("GET tls_library") - params = { "ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf" } - groups = [ 19, 20, 21, 25, 26 ] + params = {"ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf"} + groups = [19, 20, 21, 25, 26] if tls.startswith("OpenSSL") and "build=OpenSSL 1.0.2" in tls and "run=OpenSSL 1.0.2" in tls: logger.info("Add Brainpool EC groups since OpenSSL is new enough") - groups += [ 27, 28, 29, 30 ] + groups += [27, 28, 29, 30] if tls.startswith("OpenSSL") and "build=OpenSSL 1.1" in tls and "run=OpenSSL 1.1" in tls: logger.info("Add Brainpool EC groups since OpenSSL is new enough") - groups += [ 27, 28, 29, 30 ] + groups += [27, 28, 29, 30] for i in groups: logger.info("Group %d" % i) params['pwd_group'] = str(i) @@ -2754,7 +2754,7 @@ def test_ap_wpa2_eap_pwd_groups(dev, apdev): dev[0].wait_disconnected() dev[0].dump_monitor() except: - if "BoringSSL" in tls and i in [ 25 ]: + if "BoringSSL" in tls and i in [25]: logger.info("Ignore connection failure with group %d with BoringSSL" % i) dev[0].request("DISCONNECT") time.sleep(0.1) @@ -2766,9 +2766,9 @@ def test_ap_wpa2_eap_pwd_groups(dev, apdev): def test_ap_wpa2_eap_pwd_invalid_group(dev, apdev): """WPA2-Enterprise connection using invalid EAP-pwd group""" check_eap_capa(dev[0], "PWD") - params = { "ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf" } + params = {"ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf"} params['pwd_group'] = "0" hostapd.add_ap(apdev[0], params) dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="PWD", @@ -2782,10 +2782,10 @@ def test_ap_wpa2_eap_pwd_as_frag(dev, apdev): """WPA2-Enterprise connection using EAP-pwd with server fragmentation""" check_eap_capa(dev[0], "PWD") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") - params = { "ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", - "pwd_group": "19", "fragment_size": "40" } + params = {"ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", + "pwd_group": "19", "fragment_size": "40"} hapd = hostapd.add_ap(apdev[0], params) eap_connect(dev[0], hapd, "PWD", "pwd user", password="secret password") @@ -2798,7 +2798,7 @@ def test_ap_wpa2_eap_gpsk(dev, apdev): eap_reauth(dev[0], "GPSK") logger.info("Test forced algorithm selection") - for phase1 in [ "cipher=1", "cipher=2" ]: + for phase1 in ["cipher=1", "cipher=2"]: dev[0].set_network_quoted(id, "phase1", phase1) ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10) if ev is None: @@ -2839,10 +2839,10 @@ def test_ap_wpa2_eap_eke(dev, apdev): eap_reauth(dev[0], "EKE") logger.info("Test forced algorithm selection") - for phase1 in [ "dhgroup=5 encr=1 prf=2 mac=2", - "dhgroup=4 encr=1 prf=2 mac=2", - "dhgroup=3 encr=1 prf=2 mac=2", - "dhgroup=3 encr=1 prf=1 mac=1" ]: + for phase1 in ["dhgroup=5 encr=1 prf=2 mac=2", + "dhgroup=4 encr=1 prf=2 mac=2", + "dhgroup=3 encr=1 prf=2 mac=2", + "dhgroup=3 encr=1 prf=1 mac=1"]: dev[0].set_network_quoted(id, "phase1", phase1) ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10) if ev is None: @@ -2907,7 +2907,7 @@ def test_ap_wpa2_eap_eke_server_oom(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) - for count,func in [ (1, "eap_eke_build_commit"), + for count, func in [(1, "eap_eke_build_commit"), (2, "eap_eke_build_commit"), (3, "eap_eke_build_commit"), (1, "eap_eke_build_confirm"), @@ -2918,19 +2918,19 @@ def test_ap_wpa2_eap_eke_server_oom(dev, apdev): (1, "eap_eke_process_identity"), (2, "eap_eke_process_identity"), (3, "eap_eke_process_identity"), - (4, "eap_eke_process_identity") ]: + (4, "eap_eke_process_identity")]: with alloc_fail(hapd, count, func): eap_connect(dev[0], hapd, "EKE", "eke user", password="hello", expect_failure=True) dev[0].request("REMOVE_NETWORK all") - for count,func,pw in [ (1, "eap_eke_init", "hello"), - (1, "eap_eke_get_session_id", "hello"), - (1, "eap_eke_getKey", "hello"), - (1, "eap_eke_build_msg", "hello"), - (1, "eap_eke_build_failure", "wrong"), - (1, "eap_eke_build_identity", "hello"), - (2, "eap_eke_build_identity", "hello") ]: + for count, func, pw in [(1, "eap_eke_init", "hello"), + (1, "eap_eke_get_session_id", "hello"), + (1, "eap_eke_getKey", "hello"), + (1, "eap_eke_build_msg", "hello"), + (1, "eap_eke_build_failure", "wrong"), + (1, "eap_eke_build_identity", "hello"), + (2, "eap_eke_build_identity", "hello")]: with alloc_fail(hapd, count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP WPA-EAP-SHA256", eap="EKE", identity="eke user", password=pw, @@ -2992,10 +2992,10 @@ def test_ap_wpa2_eap_ikev2_as_frag(dev, apdev): """WPA2-Enterprise connection using EAP-IKEv2 with server fragmentation""" check_eap_capa(dev[0], "IKEV2") params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") - params = { "ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", - "fragment_size": "50" } + params = {"ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", + "fragment_size": "50"} hapd = hostapd.add_ap(apdev[0], params) eap_connect(dev[0], hapd, "IKEV2", "ikev2 user", password="ike password") @@ -3007,9 +3007,9 @@ def test_ap_wpa2_eap_ikev2_oom(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ (1, "dh_init"), - (2, "dh_init"), - (1, "dh_derive_shared") ] + tests = [(1, "dh_init"), + (2, "dh_init"), + (1, "dh_derive_shared")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="IKEV2", @@ -3026,9 +3026,9 @@ def test_ap_wpa2_eap_ikev2_oom(dev, apdev): tls = dev[0].request("GET tls_library") if not tls.startswith("wolfSSL"): - tests = [ (1, "os_get_random;dh_init") ] + tests = [(1, "os_get_random;dh_init")] else: - tests = [ (1, "crypto_dh_init;dh_init") ] + tests = [(1, "crypto_dh_init;dh_init")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="IKEV2", @@ -3066,8 +3066,8 @@ def test_ap_wpa2_eap_psk(dev, apdev): eap_connect(dev[0], hapd, "PSK", "psk.user@example.com", password_hex="0123456789abcdef0123456789abcdef", sha256=True) eap_reauth(dev[0], "PSK", sha256=True) - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-5"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-5") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-5"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-5")]) bss = dev[0].get_bss(apdev[0]['bssid']) if 'flags' not in bss: @@ -3086,8 +3086,8 @@ def test_ap_wpa2_eap_psk_oom(dev, apdev): skip_with_fips(dev[0]) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ (1, "=aes_128_eax_encrypt"), - (1, "=aes_128_eax_decrypt") ] + tests = [(1, "=aes_128_eax_encrypt"), + (1, "=aes_128_eax_decrypt")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="PSK", @@ -3102,15 +3102,15 @@ def test_ap_wpa2_eap_psk_oom(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "aes_ctr_encrypt;aes_128_eax_encrypt"), - (1, "omac1_aes_128;aes_128_eax_encrypt"), - (2, "omac1_aes_128;aes_128_eax_encrypt"), - (3, "omac1_aes_128;aes_128_eax_encrypt"), - (1, "omac1_aes_vector"), - (1, "omac1_aes_128;aes_128_eax_decrypt"), - (2, "omac1_aes_128;aes_128_eax_decrypt"), - (3, "omac1_aes_128;aes_128_eax_decrypt"), - (1, "aes_ctr_encrypt;aes_128_eax_decrypt") ] + tests = [(1, "aes_ctr_encrypt;aes_128_eax_encrypt"), + (1, "omac1_aes_128;aes_128_eax_encrypt"), + (2, "omac1_aes_128;aes_128_eax_encrypt"), + (3, "omac1_aes_128;aes_128_eax_encrypt"), + (1, "omac1_aes_vector"), + (1, "omac1_aes_128;aes_128_eax_decrypt"), + (2, "omac1_aes_128;aes_128_eax_decrypt"), + (3, "omac1_aes_128;aes_128_eax_decrypt"), + (1, "aes_ctr_encrypt;aes_128_eax_decrypt")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="PSK", @@ -3148,8 +3148,8 @@ def test_ap_wpa_eap_peap_eap_mschapv2(dev, apdev): eap_check_auth(dev[0], "PEAP", True, rsn=False) hwsim_utils.test_connectivity(dev[0], hapd) eap_reauth(dev[0], "PEAP", rsn=False) - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-50-f2-1"), - ("dot11RSNAAuthenticationSuiteSelected", "00-50-f2-1") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-50-f2-1"), + ("dot11RSNAAuthenticationSuiteSelected", "00-50-f2-1")]) status = dev[0].get_status(extra="VERBOSE") if 'portControl' not in status: raise Exception("portControl missing from STATUS-VERBOSE") @@ -3166,21 +3166,21 @@ def test_ap_wpa2_eap_interactive(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - tests = [ ("Connection with dynamic TTLS/MSCHAPv2 password entry", - "TTLS", "ttls", "DOMAIN\mschapv2 user", "auth=MSCHAPV2", - None, "password"), - ("Connection with dynamic TTLS/MSCHAPv2 identity and password entry", - "TTLS", "ttls", None, "auth=MSCHAPV2", - "DOMAIN\mschapv2 user", "password"), - ("Connection with dynamic TTLS/EAP-MSCHAPv2 password entry", - "TTLS", "ttls", "user", "autheap=MSCHAPV2", None, "password"), - ("Connection with dynamic TTLS/EAP-MD5 password entry", - "TTLS", "ttls", "user", "autheap=MD5", None, "password"), - ("Connection with dynamic PEAP/EAP-MSCHAPv2 password entry", - "PEAP", None, "user", "auth=MSCHAPV2", None, "password"), - ("Connection with dynamic PEAP/EAP-GTC password entry", - "PEAP", None, "user", "auth=GTC", None, "password") ] - for [desc,eap,anon,identity,phase2,req_id,req_pw] in tests: + tests = [("Connection with dynamic TTLS/MSCHAPv2 password entry", + "TTLS", "ttls", "DOMAIN\mschapv2 user", "auth=MSCHAPV2", + None, "password"), + ("Connection with dynamic TTLS/MSCHAPv2 identity and password entry", + "TTLS", "ttls", None, "auth=MSCHAPV2", + "DOMAIN\mschapv2 user", "password"), + ("Connection with dynamic TTLS/EAP-MSCHAPv2 password entry", + "TTLS", "ttls", "user", "autheap=MSCHAPV2", None, "password"), + ("Connection with dynamic TTLS/EAP-MD5 password entry", + "TTLS", "ttls", "user", "autheap=MD5", None, "password"), + ("Connection with dynamic PEAP/EAP-MSCHAPv2 password entry", + "PEAP", None, "user", "auth=MSCHAPV2", None, "password"), + ("Connection with dynamic PEAP/EAP-GTC password entry", + "PEAP", None, "user", "auth=GTC", None, "password")] + for [desc, eap, anon, identity, phase2, req_id, req_pw] in tests: logger.info(desc) dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap=eap, anonymous_identity=anon, identity=identity, @@ -3192,7 +3192,7 @@ def test_ap_wpa2_eap_interactive(dev, apdev): raise Exception("Request for identity timed out") id = ev.split(':')[0].split('-')[-1] dev[0].request("CTRL-RSP-IDENTITY-" + id + ":" + req_id) - ev = dev[0].wait_event(["CTRL-REQ-PASSWORD","CTRL-REQ-OTP"]) + ev = dev[0].wait_event(["CTRL-REQ-PASSWORD", "CTRL-REQ-OTP"]) if ev is None: raise Exception("Request for password timed out") id = ev.split(':')[0].split('-')[-1] @@ -3244,9 +3244,9 @@ def test_ap_wpa2_eap_vendor_test_oom(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ "eap_vendor_test_init", - "eap_msg_alloc;eap_vendor_test_process", - "eap_vendor_test_getKey" ] + tests = ["eap_vendor_test_init", + "eap_msg_alloc;eap_vendor_test_process", + "eap_vendor_test_getKey"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -3372,9 +3372,9 @@ def test_ap_wpa2_eap_fast_binary_pac_errors(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - tests = [ (1, "=eap_fast_save_pac_bin"), - (1, "eap_fast_write_pac"), - (2, "eap_fast_write_pac"), ] + tests = [(1, "=eap_fast_save_pac_bin"), + (1, "eap_fast_write_pac"), + (2, "eap_fast_write_pac"),] for count, func in tests: if "OK" not in dev[0].request("SET blob fast_pac_bin_errors "): raise Exception("Could not set blob") @@ -3388,12 +3388,12 @@ def test_ap_wpa2_eap_fast_binary_pac_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ "00", "000000000000", "6ae4920c0001", - "6ae4920c000000", - "6ae4920c0000" + "0000" + 32*"00" + "ffff" + "0000", - "6ae4920c0000" + "0000" + 32*"00" + "0001" + "0000", - "6ae4920c0000" + "0000" + 32*"00" + "0000" + "0001", - "6ae4920c0000" + "0000" + 32*"00" + "0000" + "0008" + "00040000" + "0007000100"] + tests = ["00", "000000000000", "6ae4920c0001", + "6ae4920c000000", + "6ae4920c0000" + "0000" + 32*"00" + "ffff" + "0000", + "6ae4920c0000" + "0000" + 32*"00" + "0001" + "0000", + "6ae4920c0000" + "0000" + 32*"00" + "0000" + "0001", + "6ae4920c0000" + "0000" + 32*"00" + "0000" + "0008" + "00040000" + "0007000100"] for t in tests: if "OK" not in dev[0].request("SET blob fast_pac_bin_errors " + t): raise Exception("Could not set blob") @@ -3413,9 +3413,9 @@ def test_ap_wpa2_eap_fast_binary_pac_errors(dev, apdev): dev[0].wait_disconnected() pac = "6ae4920c0000" + "0000" + 32*"00" + "0000" + "0000" - tests = [ (1, "eap_fast_load_pac_bin"), - (2, "eap_fast_load_pac_bin"), - (3, "eap_fast_load_pac_bin") ] + tests = [(1, "eap_fast_load_pac_bin"), + (2, "eap_fast_load_pac_bin"), + (3, "eap_fast_load_pac_bin")] for count, func in tests: if "OK" not in dev[0].request("SET blob fast_pac_bin_errors " + pac): raise Exception("Could not set blob") @@ -3448,8 +3448,8 @@ def test_ap_wpa2_eap_fast_binary_pac_errors(dev, apdev): dev[0].wait_disconnected() pac = "6ae4920c0000" + "0000" + 32*"00" + "0000" + "0009" + "00040000" + "0007000100" - tests = [ (1, "eap_fast_pac_get_a_id"), - (2, "eap_fast_pac_get_a_id") ] + tests = [(1, "eap_fast_pac_get_a_id"), + (2, "eap_fast_pac_get_a_id")] for count, func in tests: if "OK" not in dev[0].request("SET blob fast_pac_bin_errors " + pac): raise Exception("Could not set blob") @@ -3468,11 +3468,11 @@ def test_ap_wpa2_eap_fast_text_pac_errors(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ (1, "eap_fast_parse_hex;eap_fast_parse_pac_key"), - (1, "eap_fast_parse_hex;eap_fast_parse_pac_opaque"), - (1, "eap_fast_parse_hex;eap_fast_parse_a_id"), - (1, "eap_fast_parse_start"), - (1, "eap_fast_save_pac") ] + tests = [(1, "eap_fast_parse_hex;eap_fast_parse_pac_key"), + (1, "eap_fast_parse_hex;eap_fast_parse_pac_opaque"), + (1, "eap_fast_parse_hex;eap_fast_parse_a_id"), + (1, "eap_fast_parse_start"), + (1, "eap_fast_save_pac")] for count, func in tests: dev[0].request("FLUSH") if "OK" not in dev[0].request("SET blob fast_pac_text_errors "): @@ -3760,11 +3760,11 @@ def test_ap_wpa2_eap_fast_cipher_suites(dev, apdev): if res != "DHE-RSA-AES256-SHA": raise Exception("Unexpected cipher suite for provisioning: " + res) - tests = [ "DHE-RSA-AES128-SHA", - "RC4-SHA", - "AES128-SHA", - "AES256-SHA", - "DHE-RSA-AES256-SHA" ] + tests = ["DHE-RSA-AES128-SHA", + "RC4-SHA", + "AES128-SHA", + "AES256-SHA", + "DHE-RSA-AES256-SHA"] for cipher in tests: dev[0].dump_monitor() logger.info("Testing " + cipher) @@ -3938,13 +3938,13 @@ def test_ap_wpa2_eap_tls_ocsp_multi(dev, apdev): private_key_passwd="whatever", ocsp=2) def int_eap_server_params(): - params = { "ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key", - "dh_file": "auth_serv/dh.conf" } + params = {"ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key", + "dh_file": "auth_serv/dh.conf"} return params def test_ap_wpa2_eap_tls_ocsp_key_id(dev, apdev, params): @@ -4253,8 +4253,8 @@ def root_ocsp(cert): fd2, fn2 = tempfile.mkstemp() os.close(fd2) - arg = [ "openssl", "ocsp", "-reqout", fn2, "-issuer", ca, "-sha256", - "-cert", cert, "-no_nonce", "-text" ] + arg = ["openssl", "ocsp", "-reqout", fn2, "-issuer", ca, "-sha256", + "-cert", cert, "-no_nonce", "-text"] logger.info(' '.join(arg)) cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -4268,11 +4268,11 @@ def root_ocsp(cert): fd, fn = tempfile.mkstemp() os.close(fd) - arg = [ "openssl", "ocsp", "-index", "auth_serv/rootCA/index.txt", - "-rsigner", ca, "-rkey", "auth_serv/ca-key.pem", - "-CA", ca, "-issuer", ca, "-verify_other", ca, "-trust_other", - "-ndays", "7", "-reqin", fn2, "-resp_no_certs", "-respout", fn, - "-text" ] + arg = ["openssl", "ocsp", "-index", "auth_serv/rootCA/index.txt", + "-rsigner", ca, "-rkey", "auth_serv/ca-key.pem", + "-CA", ca, "-issuer", ca, "-verify_other", ca, "-trust_other", + "-ndays", "7", "-reqin", fn2, "-resp_no_certs", "-respout", fn, + "-text"] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = cmd.stdout.read().decode() + "\n" + cmd.stderr.read().decode() @@ -4293,8 +4293,8 @@ def ica_ocsp(cert, md="-sha256"): fd2, fn2 = tempfile.mkstemp() os.close(fd2) - arg = [ "openssl", "ocsp", "-reqout", fn2, "-issuer", ca, md, - "-cert", cert, "-no_nonce", "-text" ] + arg = ["openssl", "ocsp", "-reqout", fn2, "-issuer", ca, md, + "-cert", cert, "-no_nonce", "-text"] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = cmd.stdout.read().decode() + "\n" + cmd.stderr.read().decode() @@ -4307,11 +4307,11 @@ def ica_ocsp(cert, md="-sha256"): fd, fn = tempfile.mkstemp() os.close(fd) - arg = [ "openssl", "ocsp", "-index", prefix + "index.txt", - "-rsigner", ca, "-rkey", prefix + "private/cakey.pem", - "-CA", ca, "-issuer", ca, "-verify_other", ca, "-trust_other", - "-ndays", "7", "-reqin", fn2, "-resp_no_certs", "-respout", fn, - "-text" ] + arg = ["openssl", "ocsp", "-index", prefix + "index.txt", + "-rsigner", ca, "-rkey", prefix + "private/cakey.pem", + "-CA", ca, "-issuer", ca, "-verify_other", ca, "-trust_other", + "-ndays", "7", "-reqin", fn2, "-resp_no_certs", "-respout", fn, + "-text"] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = cmd.stdout.read().decode() + "\n" + cmd.stderr.read().decode() @@ -4955,8 +4955,8 @@ def test_ap_wpa2_eap_sim_zero_db_timeout(dev, apdev): identity="1232010000000000", password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581", wait_connect=False, scan_freq="2412") - ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED", - "CTRL-EVENT-DISCONNECTED" ], + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", + "CTRL-EVENT-DISCONNECTED"], timeout=15) if ev is None: raise Exception("No connection result") @@ -5290,8 +5290,8 @@ def test_ap_wpa2_eap_unexpected_wep_eapol_key(dev, apdev): def test_ap_wpa2_eap_in_bridge(dev, apdev): """WPA2-EAP and wpas interface in a bridge""" - br_ifname='sta-br0' - ifname='wlan5' + br_ifname = 'sta-br0' + ifname = 'wlan5' try: _test_ap_wpa2_eap_in_bridge(dev, apdev) finally: @@ -5304,8 +5304,8 @@ def _test_ap_wpa2_eap_in_bridge(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - br_ifname='sta-br0' - ifname='wlan5' + br_ifname = 'sta-br0' + ifname = 'wlan5' wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') subprocess.call(['brctl', 'addbr', br_ifname]) subprocess.call(['brctl', 'setfd', br_ifname, '0']) @@ -5454,10 +5454,10 @@ def test_ap_wpa2_eap_tls_oom(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hostapd.add_ap(apdev[0], params) - tests = [ (1, "tls_connection_set_subject_match"), - (2, "tls_connection_set_subject_match"), - (3, "tls_connection_set_subject_match"), - (4, "tls_connection_set_subject_match") ] + tests = [(1, "tls_connection_set_subject_match"), + (2, "tls_connection_set_subject_match"), + (3, "tls_connection_set_subject_match"), + (4, "tls_connection_set_subject_match")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TLS", @@ -5573,15 +5573,15 @@ def test_rsn_ie_proto_eap_sta(dev, apdev): password="abcdefghijklmnop0123456789abcdef", scan_freq="2412") - tests = [ ('No RSN Capabilities field', - '30120100000fac040100000fac040100000fac01'), - ('No AKM Suite fields', - '300c0100000fac040100000fac04'), - ('No Pairwise Cipher Suite fields', - '30060100000fac04'), - ('No Group Data Cipher Suite field', - '30020100') ] - for txt,ie in tests: + tests = [('No RSN Capabilities field', + '30120100000fac040100000fac040100000fac01'), + ('No AKM Suite fields', + '300c0100000fac040100000fac04'), + ('No Pairwise Cipher Suite fields', + '30060100000fac04'), + ('No Group Data Cipher Suite field', + '30020100')] + for txt, ie in tests: dev[0].request("DISCONNECT") dev[0].wait_disconnected() logger.info(txt) @@ -5894,15 +5894,15 @@ def test_eap_tls_no_session_resumption(dev, apdev): def test_eap_tls_session_resumption_radius(dev, apdev): """EAP-TLS session resumption (RADIUS)""" - params = { "ssid": "as", "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key", - "tls_session_lifetime": "60" } + params = {"ssid": "as", "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key", + "tls_session_lifetime": "60"} authsrv = hostapd.add_ap(apdev[1], params) check_tls_session_resumption_capa(dev[0], authsrv) @@ -5927,15 +5927,15 @@ def test_eap_tls_session_resumption_radius(dev, apdev): def test_eap_tls_no_session_resumption_radius(dev, apdev): """EAP-TLS session resumption disabled (RADIUS)""" - params = { "ssid": "as", "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key", - "tls_session_lifetime": "0" } + params = {"ssid": "as", "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key", + "tls_session_lifetime": "0"} hostapd.add_ap(apdev[1], params) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") @@ -5970,14 +5970,14 @@ def test_eap_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "hash_nt_password_hash;mschapv2_derive_response"), - (1, "nt_password_hash;mschapv2_derive_response"), - (1, "nt_password_hash;=mschapv2_derive_response"), - (1, "generate_nt_response;mschapv2_derive_response"), - (1, "generate_authenticator_response;mschapv2_derive_response"), - (1, "nt_password_hash;=mschapv2_derive_response"), - (1, "get_master_key;mschapv2_derive_response"), - (1, "os_get_random;eap_mschapv2_challenge_reply") ] + tests = [(1, "hash_nt_password_hash;mschapv2_derive_response"), + (1, "nt_password_hash;mschapv2_derive_response"), + (1, "nt_password_hash;=mschapv2_derive_response"), + (1, "generate_nt_response;mschapv2_derive_response"), + (1, "generate_authenticator_response;mschapv2_derive_response"), + (1, "nt_password_hash;=mschapv2_derive_response"), + (1, "get_master_key;mschapv2_derive_response"), + (1, "os_get_random;eap_mschapv2_challenge_reply")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="MSCHAPV2", @@ -5987,10 +5987,10 @@ def test_eap_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "hash_nt_password_hash;mschapv2_derive_response"), - (1, "hash_nt_password_hash;=mschapv2_derive_response"), - (1, "generate_nt_response_pwhash;mschapv2_derive_response"), - (1, "generate_authenticator_response_pwhash;mschapv2_derive_response") ] + tests = [(1, "hash_nt_password_hash;mschapv2_derive_response"), + (1, "hash_nt_password_hash;=mschapv2_derive_response"), + (1, "generate_nt_response_pwhash;mschapv2_derive_response"), + (1, "generate_authenticator_response_pwhash;mschapv2_derive_response")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="MSCHAPV2", @@ -6001,10 +6001,10 @@ def test_eap_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_mschapv2_init"), - (1, "eap_msg_alloc;eap_mschapv2_challenge_reply"), - (1, "eap_msg_alloc;eap_mschapv2_success"), - (1, "eap_mschapv2_getKey") ] + tests = [(1, "eap_mschapv2_init"), + (1, "eap_msg_alloc;eap_mschapv2_challenge_reply"), + (1, "eap_msg_alloc;eap_mschapv2_success"), + (1, "eap_mschapv2_getKey")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="MSCHAPV2", @@ -6014,7 +6014,7 @@ def test_eap_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_msg_alloc;eap_mschapv2_failure") ] + tests = [(1, "eap_msg_alloc;eap_mschapv2_failure")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="MSCHAPV2", @@ -6024,8 +6024,8 @@ def test_eap_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (2, "eap_mschapv2_init"), - (3, "eap_mschapv2_init") ] + tests = [(2, "eap_mschapv2_init"), + (3, "eap_mschapv2_init")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="FAST", @@ -6050,20 +6050,20 @@ def test_eap_gpsk_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "os_get_random;eap_gpsk_send_gpsk_2", None), - (1, "eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2", - "cipher=1"), - (1, "eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2", - "cipher=2"), - (1, "eap_gpsk_derive_keys_helper", None), - (2, "eap_gpsk_derive_keys_helper", None), - (1, "eap_gpsk_compute_mic_aes;eap_gpsk_compute_mic;eap_gpsk_send_gpsk_2", - "cipher=1"), - (1, "hmac_sha256;eap_gpsk_compute_mic;eap_gpsk_send_gpsk_2", - "cipher=2"), - (1, "eap_gpsk_compute_mic;eap_gpsk_validate_gpsk_3_mic", None), - (1, "eap_gpsk_compute_mic;eap_gpsk_send_gpsk_4", None), - (1, "eap_gpsk_derive_mid_helper", None) ] + tests = [(1, "os_get_random;eap_gpsk_send_gpsk_2", None), + (1, "eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2", + "cipher=1"), + (1, "eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2", + "cipher=2"), + (1, "eap_gpsk_derive_keys_helper", None), + (2, "eap_gpsk_derive_keys_helper", None), + (1, "eap_gpsk_compute_mic_aes;eap_gpsk_compute_mic;eap_gpsk_send_gpsk_2", + "cipher=1"), + (1, "hmac_sha256;eap_gpsk_compute_mic;eap_gpsk_send_gpsk_2", + "cipher=2"), + (1, "eap_gpsk_compute_mic;eap_gpsk_validate_gpsk_3_mic", None), + (1, "eap_gpsk_compute_mic;eap_gpsk_send_gpsk_4", None), + (1, "eap_gpsk_derive_mid_helper", None)] for count, func, phase1 in tests: with fail_test(dev[0], count, func): dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="GPSK", @@ -6075,19 +6075,19 @@ def test_eap_gpsk_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_gpsk_init"), - (2, "eap_gpsk_init"), - (3, "eap_gpsk_init"), - (1, "eap_gpsk_process_id_server"), - (1, "eap_msg_alloc;eap_gpsk_send_gpsk_2"), - (1, "eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2"), - (1, "eap_gpsk_derive_mid_helper;eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2"), - (1, "eap_gpsk_derive_keys"), - (1, "eap_gpsk_derive_keys_helper"), - (1, "eap_msg_alloc;eap_gpsk_send_gpsk_4"), - (1, "eap_gpsk_getKey"), - (1, "eap_gpsk_get_emsk"), - (1, "eap_gpsk_get_session_id") ] + tests = [(1, "eap_gpsk_init"), + (2, "eap_gpsk_init"), + (3, "eap_gpsk_init"), + (1, "eap_gpsk_process_id_server"), + (1, "eap_msg_alloc;eap_gpsk_send_gpsk_2"), + (1, "eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2"), + (1, "eap_gpsk_derive_mid_helper;eap_gpsk_derive_session_id;eap_gpsk_send_gpsk_2"), + (1, "eap_gpsk_derive_keys"), + (1, "eap_gpsk_derive_keys_helper"), + (1, "eap_msg_alloc;eap_gpsk_send_gpsk_4"), + (1, "eap_gpsk_getKey"), + (1, "eap_gpsk_get_emsk"), + (1, "eap_gpsk_get_session_id")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].request("ERP_FLUSH") @@ -6229,19 +6229,19 @@ def test_ap_wpa2_eap_assoc_rsn(dev, apdev): hostapd.add_ap(apdev[1], params) # Success cases with optional RSN IE fields removed one by one - tests = [ ("Normal wpa_supplicant assoc req RSN IE", - "30140100000fac040100000fac040100000fac010000"), - ("Extra PMKIDCount field in RSN IE", - "30160100000fac040100000fac040100000fac0100000000"), - ("Extra Group Management Cipher Suite in RSN IE", - "301a0100000fac040100000fac040100000fac0100000000000fac06"), - ("Extra undefined extension field in RSN IE", - "301c0100000fac040100000fac040100000fac0100000000000fac061122"), - ("RSN IE without RSN Capabilities", - "30120100000fac040100000fac040100000fac01"), - ("RSN IE without AKM", "300c0100000fac040100000fac04"), - ("RSN IE without pairwise", "30060100000fac04"), - ("RSN IE without group", "30020100") ] + tests = [("Normal wpa_supplicant assoc req RSN IE", + "30140100000fac040100000fac040100000fac010000"), + ("Extra PMKIDCount field in RSN IE", + "30160100000fac040100000fac040100000fac0100000000"), + ("Extra Group Management Cipher Suite in RSN IE", + "301a0100000fac040100000fac040100000fac0100000000000fac06"), + ("Extra undefined extension field in RSN IE", + "301c0100000fac040100000fac040100000fac0100000000000fac061122"), + ("RSN IE without RSN Capabilities", + "30120100000fac040100000fac040100000fac01"), + ("RSN IE without AKM", "300c0100000fac040100000fac04"), + ("RSN IE without pairwise", "30060100000fac04"), + ("RSN IE without group", "30020100")] for title, ie in tests: logger.info(title) set_test_assoc_ie(dev[0], ie) @@ -6252,10 +6252,10 @@ def test_ap_wpa2_eap_assoc_rsn(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ ("Normal wpa_supplicant assoc req RSN IE", - "30140100000fac040100000fac040100000fac01cc00"), - ("Group management cipher included in assoc req RSN IE", - "301a0100000fac040100000fac040100000fac01cc000000000fac06") ] + tests = [("Normal wpa_supplicant assoc req RSN IE", + "30140100000fac040100000fac040100000fac01cc00"), + ("Group management cipher included in assoc req RSN IE", + "301a0100000fac040100000fac040100000fac01cc000000000fac06")] for title, ie in tests: logger.info(title) set_test_assoc_ie(dev[0], ie) @@ -6266,8 +6266,8 @@ def test_ap_wpa2_eap_assoc_rsn(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ ("Invalid group cipher", "30060100000fac02", 41), - ("Invalid pairwise cipher", "300c0100000fac040100000fac02", 42) ] + tests = [("Invalid group cipher", "30060100000fac02", 41), + ("Invalid pairwise cipher", "300c0100000fac040100000fac02", 42)] for title, ie, status in tests: logger.info(title) set_test_assoc_ie(dev[0], ie) @@ -6283,10 +6283,10 @@ def test_ap_wpa2_eap_assoc_rsn(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ ("Management frame protection not enabled", - "30140100000fac040100000fac040100000fac010000", 31), - ("Unsupported management group cipher", - "301a0100000fac040100000fac040100000fac01cc000000000fac0b", 46) ] + tests = [("Management frame protection not enabled", + "30140100000fac040100000fac040100000fac010000", 31), + ("Unsupported management group cipher", + "301a0100000fac040100000fac040100000fac01cc000000000fac0b", 46)] for title, ie, status in tests: logger.info(title) set_test_assoc_ie(dev[0], ie) @@ -6467,11 +6467,11 @@ def test_eap_tls_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ "eap_peer_tls_derive_key;eap_tls_success", - "eap_peer_tls_derive_session_id;eap_tls_success", - "eap_tls_getKey", - "eap_tls_get_emsk", - "eap_tls_get_session_id" ] + tests = ["eap_peer_tls_derive_key;eap_tls_success", + "eap_peer_tls_derive_session_id;eap_tls_success", + "eap_tls_getKey", + "eap_tls_get_emsk", + "eap_tls_get_session_id"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TLS", @@ -6724,8 +6724,8 @@ def run_openssl_systemwide_policy(iface, apdev, test_params): 'alt-wpa_supplicant/wpa_supplicant/wpa_supplicant') if not os.path.exists(prg): prg = '../../wpa_supplicant/wpa_supplicant' - arg = [ prg, '-BddtK', '-P', pidfile, '-f', logfile, - '-Dnl80211', '-c', conffile, '-i', iface ] + arg = [prg, '-BddtK', '-P', pidfile, '-f', logfile, + '-Dnl80211', '-c', conffile, '-i', iface] logger.info("Start wpa_supplicant: " + str(arg)) subprocess.call(arg, env={'OPENSSL_CONF': openssl_cnf}) wpas = WpaSupplicant(ifname=iface) diff --git a/tests/hwsim/test_ap_ft.py b/tests/hwsim/test_ap_ft.py index 71ef74f..556ea46 100644 --- a/tests/hwsim/test_ap_ft.py +++ b/tests/hwsim/test_ap_ft.py @@ -24,16 +24,16 @@ from test_ap_psk import check_mib, find_wpas_process, read_process_memory, verif from test_rrm import check_beacon_req def ft_base_rsn(): - params = { "wpa": "2", - "wpa_key_mgmt": "FT-PSK", - "rsn_pairwise": "CCMP" } + params = {"wpa": "2", + "wpa_key_mgmt": "FT-PSK", + "rsn_pairwise": "CCMP"} return params def ft_base_mixed(): - params = { "wpa": "3", - "wpa_key_mgmt": "WPA-PSK FT-PSK", - "wpa_pairwise": "TKIP", - "rsn_pairwise": "CCMP" } + params = {"wpa": "3", + "wpa_key_mgmt": "WPA-PSK FT-PSK", + "wpa_pairwise": "TKIP", + "rsn_pairwise": "CCMP"} return params def ft_params(rsn=True, ssid=None, passphrase=None): @@ -64,15 +64,15 @@ def ft_params1(rsn=True, ssid=None, passphrase=None, discovery=False): params['r0kh'] = "ff:ff:ff:ff:ff:ff * 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f" params['r1kh'] = "00:00:00:00:00:00 00:00:00:00:00:00 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f" else: - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f300102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f300102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f" return params def ft_params1_old_key(rsn=True, ssid=None, passphrase=None): params = ft_params1a(rsn, ssid, passphrase) - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f" return params @@ -88,15 +88,15 @@ def ft_params2(rsn=True, ssid=None, passphrase=None, discovery=False): params['r0kh'] = "ff:ff:ff:ff:ff:ff * 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f" params['r1kh'] = "00:00:00:00:00:00 00:00:00:00:00:00 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f" else: - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f300102030405060708090a0b0c0d0e0f" return params def ft_params2_old_key(rsn=True, ssid=None, passphrase=None): params = ft_params2a(rsn, ssid, passphrase) - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f" return params @@ -104,8 +104,8 @@ def ft_params1_r0kh_mismatch(rsn=True, ssid=None, passphrase=None): params = ft_params(rsn, ssid, passphrase) params['nas_identifier'] = "nas1.w1.fi" params['r1_key_holder'] = "000102030405" - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f", - "12:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f300102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f", + "12:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f300102030405060708090a0b0c0d0e0f"] params['r1kh'] = "12:00:00:00:04:00 10:01:02:03:04:06 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f" return params @@ -113,8 +113,8 @@ def ft_params2_incorrect_rrb_key(rsn=True, ssid=None, passphrase=None): params = ft_params(rsn, ssid, passphrase) params['nas_identifier'] = "nas2.w1.fi" params['r1_key_holder'] = "000102030406" - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0ef1200102030405060708090a0b0c0d0ef1", - "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0ef2000102030405060708090a0b0c0d0ef2" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0ef1200102030405060708090a0b0c0d0ef1", + "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0ef2000102030405060708090a0b0c0d0ef2"] params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0ef3300102030405060708090a0b0c0d0ef3" return params @@ -122,8 +122,8 @@ def ft_params2_r0kh_mismatch(rsn=True, ssid=None, passphrase=None): params = ft_params(rsn, ssid, passphrase) params['nas_identifier'] = "nas2.w1.fi" params['r1_key_holder'] = "000102030406" - params['r0kh'] = [ "12:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["12:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f200102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"] params['r1kh'] = "12:00:00:00:03:00 10:01:02:03:04:05 300102030405060708090a0b0c0d0e0f300102030405060708090a0b0c0d0e0f" return params @@ -141,7 +141,7 @@ def run_roams(dev, apdev, hapd0, hapd1, ssid, passphrase, over_ds=False, copts["ieee80211w"] = "1" copts["scan_freq"] = "2412" copts["pairwise"] = pairwise_cipher - copts["group"] = group_cipher + copts["group"] = group_cipher copts["wpa_ptk_rekey"] = ptk_rekey if group_mgmt: copts["group_mgmt"] = group_mgmt @@ -223,7 +223,7 @@ def run_roams(dev, apdev, hapd0, hapd1, ssid, passphrase, over_ds=False, def test_ap_ft(dev, apdev): """WPA2-PSK-FT AP""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -237,7 +237,7 @@ def test_ap_ft(dev, apdev): def test_ap_ft_old_key(dev, apdev): """WPA2-PSK-FT AP (old key)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1_old_key(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -249,7 +249,7 @@ def test_ap_ft_old_key(dev, apdev): def test_ap_ft_multi_akm(dev, apdev): """WPA2-PSK-FT AP with non-FT AKMs enabled""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["wpa_key_mgmt"] = "FT-PSK WPA-PSK WPA-PSK-SHA256" @@ -273,7 +273,7 @@ def test_ap_ft_multi_akm(dev, apdev): def test_ap_ft_local_key_gen(dev, apdev): """WPA2-PSK-FT AP with local key generation (without pull/push)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1a(ssid=ssid, passphrase=passphrase) params['ft_psk_generate_local'] = "1" @@ -291,7 +291,7 @@ def test_ap_ft_local_key_gen(dev, apdev): def test_ap_ft_vlan(dev, apdev): """WPA2-PSK-FT AP with VLAN""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['dynamic_vlan'] = "1" @@ -310,7 +310,7 @@ def test_ap_ft_vlan(dev, apdev): def test_ap_ft_vlan_disconnected(dev, apdev): """WPA2-PSK-FT AP with VLAN and local key generation""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1a(ssid=ssid, passphrase=passphrase) params['dynamic_vlan'] = "1" @@ -331,7 +331,7 @@ def test_ap_ft_vlan_disconnected(dev, apdev): def test_ap_ft_vlan_2(dev, apdev): """WPA2-PSK-FT AP with VLAN and dest-AP does not have VLAN info locally""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['dynamic_vlan'] = "1" @@ -350,7 +350,7 @@ def test_ap_ft_vlan_2(dev, apdev): def test_ap_ft_many(dev, apdev): """WPA2-PSK-FT AP multiple times""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -362,7 +362,7 @@ def test_ap_ft_many(dev, apdev): def test_ap_ft_many_vlan(dev, apdev): """WPA2-PSK-FT AP with VLAN multiple times""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['dynamic_vlan'] = "1" @@ -380,7 +380,7 @@ def test_ap_ft_many_vlan(dev, apdev): def test_ap_ft_mixed(dev, apdev): """WPA2-PSK-FT mixed-mode AP""" ssid = "test-ft-mixed" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(rsn=False, ssid=ssid, passphrase=passphrase) hapd = hostapd.add_ap(apdev[0], params) @@ -396,7 +396,7 @@ def test_ap_ft_mixed(dev, apdev): def test_ap_ft_pmf(dev, apdev): """WPA2-PSK-FT AP with PMF""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -428,7 +428,7 @@ def run_ap_ft_pmf_bip(dev, apdev, cipher): raise HwsimSkip("Cipher %s not supported" % cipher) ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -445,7 +445,7 @@ def run_ap_ft_pmf_bip(dev, apdev, cipher): def test_ap_ft_ocv(dev, apdev): """WPA2-PSK-FT AP with OCV""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -466,7 +466,7 @@ def test_ap_ft_ocv(dev, apdev): def test_ap_ft_over_ds(dev, apdev): """WPA2-PSK-FT AP over DS""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -474,8 +474,8 @@ def test_ap_ft_over_ds(dev, apdev): hapd1 = hostapd.add_ap(apdev[1], params) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True) - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4")]) def cleanup_ap_ft_separate_hostapd(): subprocess.call(["brctl", "delif", "br0ft", "veth0"], @@ -486,7 +486,7 @@ def cleanup_ap_ft_separate_hostapd(): stderr=open('/dev/null', 'w')) subprocess.call(["ip", "link", "del", "veth1"], stderr=open('/dev/null', 'w')) - for ifname in [ 'br0ft', 'br1ft', 'br-ft' ]: + for ifname in ['br0ft', 'br1ft', 'br-ft']: subprocess.call(['ip', 'link', 'set', 'dev', ifname, 'down'], stderr=open('/dev/null', 'w')) subprocess.call(['brctl', 'delbr', ifname], @@ -508,7 +508,7 @@ def test_ap_ft_over_ds_separate_hostapd(dev, apdev, params): def run_ap_ft_separate_hostapd(dev, apdev, params, over_ds): ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" logdir = params['logdir'] pidfile = os.path.join(logdir, 'ap_ft_over_ds_separate_hostapd.pid') logfile = os.path.join(logdir, 'ap_ft_over_ds_separate_hostapd.hapd') @@ -520,10 +520,10 @@ def run_ap_ft_separate_hostapd(dev, apdev, params, over_ds): subprocess.check_call(['brctl', 'setfd', br_ifname, '0']) subprocess.check_call(['ip', 'link', 'set', 'dev', br_ifname, 'up']) - subprocess.check_call([ "ip", "link", "add", "veth0", "type", "veth", - "peer", "name", "veth0br" ]) - subprocess.check_call([ "ip", "link", "add", "veth1", "type", "veth", - "peer", "name", "veth1br" ]) + subprocess.check_call(["ip", "link", "add", "veth0", "type", "veth", + "peer", "name", "veth0br"]) + subprocess.check_call(["ip", "link", "add", "veth1", "type", "veth", + "peer", "name", "veth1br"]) subprocess.check_call(['ip', 'link', 'set', 'dev', 'veth0br', 'up']) subprocess.check_call(['ip', 'link', 'set', 'dev', 'veth1br', 'up']) subprocess.check_call(['brctl', 'addif', br_ifname, 'veth0br']) @@ -546,13 +546,13 @@ def run_ap_ft_separate_hostapd(dev, apdev, params, over_ds): prg = os.path.join(logdir, 'alt-hostapd/hostapd/hostapd') if not os.path.exists(prg): prg = '../../hostapd/hostapd' - cmd = [ prg, '-B', '-ddKt', - '-P', pidfile, '-f', logfile, '-g', global_ctrl ] + cmd = [prg, '-B', '-ddKt', + '-P', pidfile, '-f', logfile, '-g', global_ctrl] subprocess.check_call(cmd) hglobal = hostapd.HostapdGlobal(global_ctrl_override=global_ctrl) - apdev_ft = { 'ifname': iface } - apdev2 = [ apdev_ft, apdev[1] ] + apdev_ft = {'ifname': iface} + apdev2 = [apdev_ft, apdev[1]] params = ft_params1(ssid=ssid, passphrase=passphrase) params["r0kh"] = "ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff" @@ -581,7 +581,7 @@ def run_ap_ft_separate_hostapd(dev, apdev, params, over_ds): def test_ap_ft_over_ds_ocv(dev, apdev): """WPA2-PSK-FT AP over DS""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -603,7 +603,7 @@ def test_ap_ft_over_ds_ocv(dev, apdev): def test_ap_ft_over_ds_disabled(dev, apdev): """WPA2-PSK-FT AP over DS disabled""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['ft_over_ds'] = '0' @@ -618,7 +618,7 @@ def test_ap_ft_over_ds_disabled(dev, apdev): def test_ap_ft_vlan_over_ds(dev, apdev): """WPA2-PSK-FT AP over DS with VLAN""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['dynamic_vlan'] = "1" @@ -631,13 +631,13 @@ def test_ap_ft_vlan_over_ds(dev, apdev): run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True, conndev="brvlan1") - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4")]) def test_ap_ft_over_ds_many(dev, apdev): """WPA2-PSK-FT AP over DS multiple times""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -650,7 +650,7 @@ def test_ap_ft_over_ds_many(dev, apdev): def test_ap_ft_vlan_over_ds_many(dev, apdev): """WPA2-PSK-FT AP over DS with VLAN multiple times""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['dynamic_vlan'] = "1" @@ -668,7 +668,7 @@ def test_ap_ft_vlan_over_ds_many(dev, apdev): def test_ap_ft_over_ds_unknown_target(dev, apdev): """WPA2-PSK-FT AP""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -681,7 +681,7 @@ def test_ap_ft_over_ds_unknown_target(dev, apdev): def test_ap_ft_over_ds_unexpected(dev, apdev): """WPA2-PSK-FT AP over DS and unexpected response""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -803,7 +803,7 @@ def run_ap_ft_pmf_bip_over_ds(dev, apdev, cipher): raise HwsimSkip("Cipher %s not supported" % cipher) ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -827,7 +827,7 @@ def run_ap_ft_pmf_bip_over_ds(dev, apdev, cipher): def test_ap_ft_over_ds_pull(dev, apdev): """WPA2-PSK-FT AP over DS (pull PMK)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["pmk_r1_push"] = "0" @@ -841,7 +841,7 @@ def test_ap_ft_over_ds_pull(dev, apdev): def test_ap_ft_over_ds_pull_old_key(dev, apdev): """WPA2-PSK-FT AP over DS (pull PMK; old key)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1_old_key(ssid=ssid, passphrase=passphrase) params["pmk_r1_push"] = "0" @@ -855,7 +855,7 @@ def test_ap_ft_over_ds_pull_old_key(dev, apdev): def test_ap_ft_over_ds_pull_vlan(dev, apdev): """WPA2-PSK-FT AP over DS (pull PMK) with VLAN""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["pmk_r1_push"] = "0" @@ -876,7 +876,7 @@ def test_ap_ft_sae(dev, apdev): if "SAE" not in dev[0].get_capability("auth_alg"): raise HwsimSkip("SAE not supported") ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['wpa_key_mgmt'] = "FT-SAE" @@ -896,7 +896,7 @@ def test_ap_ft_sae_over_ds(dev, apdev): if "SAE" not in dev[0].get_capability("auth_alg"): raise HwsimSkip("SAE not supported") ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['wpa_key_mgmt'] = "FT-SAE" @@ -933,16 +933,16 @@ def test_ap_ft_sae_pw_id(dev, apdev): def generic_ap_ft_eap(dev, apdev, vlan=False, cui=False, over_ds=False, discovery=False, roams=1): ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" if vlan: - identity="gpsk-vlan1" - conndev="brvlan1" + identity = "gpsk-vlan1" + conndev = "brvlan1" elif cui: - identity="gpsk-cui" - conndev=False + identity = "gpsk-cui" + conndev = False else: - identity="gpsk user" - conndev=False + identity = "gpsk user" + conndev = False radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase, discovery=discovery) @@ -968,8 +968,8 @@ def generic_ap_ft_eap(dev, apdev, vlan=False, cui=False, over_ds=False, conndev=conndev) if "[WPA2-FT/EAP-CCMP]" not in dev[0].request("SCAN_RESULTS"): raise Exception("Scan results missing RSN element info") - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-3"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-3") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-3"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-3")]) # Verify EAPOL reauthentication after FT protocol if dev[0].get_status_field('bssid') == apdev[0]['bssid']: @@ -1036,13 +1036,13 @@ def test_ap_ft_eap_vlan_over_ds_multi(dev, apdev): def generic_ap_ft_eap_pull(dev, apdev, vlan=False): """WPA2-EAP-FT AP (pull PMK)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" if vlan: - identity="gpsk-vlan1" - conndev="brvlan1" + identity = "gpsk-vlan1" + conndev = "brvlan1" else: - identity="gpsk user" - conndev=False + identity = "gpsk user" + conndev = False radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -1078,7 +1078,7 @@ def test_ap_ft_eap_pull_vlan(dev, apdev): def test_ap_ft_eap_pull_wildcard(dev, apdev): """WPA2-EAP-FT AP (pull PMK) - wildcard R0KH/R1KH""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase, discovery=True) @@ -1108,7 +1108,7 @@ def test_ap_ft_eap_pull_wildcard(dev, apdev): def test_ap_ft_mismatching_rrb_key_push(dev, apdev): """WPA2-PSK-FT AP over DS with mismatching RRB key (push)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -1124,7 +1124,7 @@ def test_ap_ft_mismatching_rrb_key_push(dev, apdev): def test_ap_ft_mismatching_rrb_key_pull(dev, apdev): """WPA2-PSK-FT AP over DS with mismatching RRB key (pull)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["pmk_r1_push"] = "0" @@ -1140,7 +1140,7 @@ def test_ap_ft_mismatching_rrb_key_pull(dev, apdev): def test_ap_ft_mismatching_r0kh_id_pull(dev, apdev): """WPA2-PSK-FT AP over DS with mismatching R0KH-ID (pull)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["pmk_r1_push"] = "0" @@ -1160,7 +1160,7 @@ def test_ap_ft_mismatching_r0kh_id_pull(dev, apdev): def test_ap_ft_mismatching_rrb_r0kh_push(dev, apdev): """WPA2-PSK-FT AP over DS with mismatching R0KH key (push)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -1176,7 +1176,7 @@ def test_ap_ft_mismatching_rrb_r0kh_push(dev, apdev): def test_ap_ft_mismatching_rrb_r0kh_pull(dev, apdev): """WPA2-PSK-FT AP over DS with mismatching R0KH key (pull)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1_r0kh_mismatch(ssid=ssid, passphrase=passphrase) params["pmk_r1_push"] = "0" @@ -1191,7 +1191,7 @@ def test_ap_ft_mismatching_rrb_r0kh_pull(dev, apdev): def test_ap_ft_mismatching_rrb_key_push_eap(dev, apdev): """WPA2-EAP-FT AP over DS with mismatching RRB key (push)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -1213,7 +1213,7 @@ def test_ap_ft_mismatching_rrb_key_push_eap(dev, apdev): def test_ap_ft_mismatching_rrb_key_pull_eap(dev, apdev): """WPA2-EAP-FT AP over DS with mismatching RRB key (pull)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -1235,7 +1235,7 @@ def test_ap_ft_mismatching_rrb_key_pull_eap(dev, apdev): def test_ap_ft_mismatching_r0kh_id_pull_eap(dev, apdev): """WPA2-EAP-FT AP over DS with mismatching R0KH-ID (pull)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -1263,7 +1263,7 @@ def test_ap_ft_mismatching_r0kh_id_pull_eap(dev, apdev): def test_ap_ft_mismatching_rrb_r0kh_push_eap(dev, apdev): """WPA2-EAP-FT AP over DS with mismatching R0KH key (push)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -1285,7 +1285,7 @@ def test_ap_ft_mismatching_rrb_r0kh_push_eap(dev, apdev): def test_ap_ft_mismatching_rrb_r0kh_pull_eap(dev, apdev): """WPA2-EAP-FT AP over DS with mismatching R0KH key (pull)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1_r0kh_mismatch(ssid=ssid, passphrase=passphrase) @@ -1307,7 +1307,7 @@ def test_ap_ft_mismatching_rrb_r0kh_pull_eap(dev, apdev): def test_ap_ft_gtk_rekey(dev, apdev): """WPA2-PSK-FT AP and GTK rekey""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['wpa_group_rekey'] = '1' @@ -1339,7 +1339,7 @@ def test_ap_ft_gtk_rekey(dev, apdev): def test_ft_psk_key_lifetime_in_memory(dev, apdev, params): """WPA2-PSK-FT and key lifetime in memory""" ssid = "test-ft" - passphrase="04c2726b4b8d5f1b4db9c07aa4d9e9d8f765cb5d25ec817e6cc4fcdd5255db0" + passphrase = "04c2726b4b8d5f1b4db9c07aa4d9e9d8f765cb5d25ec817e6cc4fcdd5255db0" psk = '93c90846ff67af9037ed83fb72b63dbeddaa81d47f926c20909b5886f1d9358d' pmk = binascii.unhexlify(psk) p = ft_params1(ssid=ssid, passphrase=passphrase) @@ -1448,7 +1448,7 @@ def test_ft_psk_key_lifetime_in_memory(dev, apdev, params): def test_ap_ft_invalid_resp(dev, apdev): """WPA2-PSK-FT AP and invalid response IEs""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1473,7 +1473,7 @@ def test_ap_ft_invalid_resp(dev, apdev): # RIC missing from protected IE count. "020002000000" + "3603a1b201" + "375200020203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001" + "3900", # Protected IE missing. - "020002000000" + "3603a1b201" + "375200ff0203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001" + "3900" + "0000" ] + "020002000000" + "3603a1b201" + "375200ff0203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001" + "3900" + "0000"] for t in tests: dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412") hapd1.set("ext_mgmt_frame_handling", "1") @@ -1507,7 +1507,7 @@ def test_ap_ft_gcmp_256(dev, apdev): if "GCMP-256" not in dev[0].get_capability("pairwise"): raise HwsimSkip("Cipher GCMP-256 not supported") ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['rsn_pairwise'] = "GCMP-256" @@ -1522,7 +1522,7 @@ def test_ap_ft_gcmp_256(dev, apdev): def setup_ap_ft_oom(dev, apdev): skip_with_fips(dev[0]) ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1561,7 +1561,7 @@ def test_ap_ft_oom3(dev, apdev): def test_ap_ft_oom4(dev, apdev): """WPA2-PSK-FT and OOM (4)""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" dst = setup_ap_ft_oom(dev, apdev) dev[0].request("REMOVE_NETWORK all") with alloc_fail(dev[0], 1, "=sme_update_ft_ies"): @@ -1571,7 +1571,7 @@ def test_ap_ft_oom4(dev, apdev): def test_ap_ft_ap_oom(dev, apdev): """WPA2-PSK-FT and AP OOM""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1592,7 +1592,7 @@ def test_ap_ft_ap_oom(dev, apdev): def test_ap_ft_ap_oom2(dev, apdev): """WPA2-PSK-FT and AP OOM 2""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1616,7 +1616,7 @@ def test_ap_ft_ap_oom2(dev, apdev): def test_ap_ft_ap_oom3(dev, apdev): """WPA2-PSK-FT and AP OOM 3""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1645,7 +1645,7 @@ def test_ap_ft_ap_oom3(dev, apdev): def test_ap_ft_ap_oom3b(dev, apdev): """WPA2-PSK-FT and AP OOM 3b""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1666,7 +1666,7 @@ def test_ap_ft_ap_oom3b(dev, apdev): def test_ap_ft_ap_oom4(dev, apdev): """WPA2-PSK-FT and AP OOM 4""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1698,7 +1698,7 @@ def test_ap_ft_ap_oom4(dev, apdev): def test_ap_ft_ap_oom5(dev, apdev): """WPA2-PSK-FT and AP OOM 5""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1735,7 +1735,7 @@ def test_ap_ft_ap_oom5(dev, apdev): def test_ap_ft_ap_oom6(dev, apdev): """WPA2-PSK-FT and AP OOM 6""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1759,7 +1759,7 @@ def test_ap_ft_ap_oom6(dev, apdev): def test_ap_ft_ap_oom7a(dev, apdev): """WPA2-PSK-FT and AP OOM 7a""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -1782,7 +1782,7 @@ def test_ap_ft_ap_oom7a(dev, apdev): def test_ap_ft_ap_oom7b(dev, apdev): """WPA2-PSK-FT and AP OOM 7b""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -1805,7 +1805,7 @@ def test_ap_ft_ap_oom7b(dev, apdev): def test_ap_ft_ap_oom7c(dev, apdev): """WPA2-PSK-FT and AP OOM 7c""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -1828,7 +1828,7 @@ def test_ap_ft_ap_oom7c(dev, apdev): def test_ap_ft_ap_oom7d(dev, apdev): """WPA2-PSK-FT and AP OOM 7d""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "2" @@ -1851,7 +1851,7 @@ def test_ap_ft_ap_oom7d(dev, apdev): def test_ap_ft_ap_oom8(dev, apdev): """WPA2-PSK-FT and AP OOM 8""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['ft_psk_generate_local'] = "1" @@ -1877,7 +1877,7 @@ def test_ap_ft_ap_oom8(dev, apdev): def test_ap_ft_ap_oom9(dev, apdev): """WPA2-PSK-FT and AP OOM 9""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1913,7 +1913,7 @@ def test_ap_ft_ap_oom9(dev, apdev): def test_ap_ft_ap_oom10(dev, apdev): """WPA2-PSK-FT and AP OOM 10""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1955,7 +1955,7 @@ def test_ap_ft_ap_oom10(dev, apdev): def test_ap_ft_ap_oom11(dev, apdev): """WPA2-PSK-FT and AP OOM 11""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1976,7 +1976,7 @@ def test_ap_ft_ap_oom11(dev, apdev): def test_ap_ft_over_ds_proto_ap(dev, apdev): """WPA2-PSK-FT AP over DS protocol testing for AP processing""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -1995,26 +1995,26 @@ def test_ap_ft_over_ds_proto_ap(dev, apdev): hapd0.set("ext_mgmt_frame_handling", "1") hdr = "d0003a01" + _bssid0 + _addr + _bssid0 + "1000" valid = "0601" + _addr + _bssid1 - tests = [ "0601", - "0601" + _addr, - "0601" + _addr + _bssid0, - "0601" + _addr + "ffffffffffff", - "0601" + _bssid0 + _bssid0, - valid, - valid + "01", - valid + "3700", - valid + "3600", - valid + "3603ffffff", - valid + "3603a1b2ff", - valid + "3603a1b2ff" + "3700", - valid + "3603a1b2ff" + "37520000" + 16*"00" + 32*"00" + 32*"00", - valid + "3603a1b2ff" + "37520001" + 16*"00" + 32*"00" + 32*"00", - valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa", - valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "3000", - valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "30260100000fac040100000fac040100000facff00000100a225368fe0983b5828a37a0acb37f253", - valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "30260100000fac040100000fac030100000fac0400000100a225368fe0983b5828a37a0acb37f253", - valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "30260100000fac040100000fac040100000fac0400000100a225368fe0983b5828a37a0acb37f253", - valid + "0001" ] + tests = ["0601", + "0601" + _addr, + "0601" + _addr + _bssid0, + "0601" + _addr + "ffffffffffff", + "0601" + _bssid0 + _bssid0, + valid, + valid + "01", + valid + "3700", + valid + "3600", + valid + "3603ffffff", + valid + "3603a1b2ff", + valid + "3603a1b2ff" + "3700", + valid + "3603a1b2ff" + "37520000" + 16*"00" + 32*"00" + 32*"00", + valid + "3603a1b2ff" + "37520001" + 16*"00" + 32*"00" + 32*"00", + valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa", + valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "3000", + valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "30260100000fac040100000fac040100000facff00000100a225368fe0983b5828a37a0acb37f253", + valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "30260100000fac040100000fac030100000fac0400000100a225368fe0983b5828a37a0acb37f253", + valid + "3603a1b2ff" + "37550000" + 16*"00" + 32*"00" + 32*"00" + "0301aa" + "30260100000fac040100000fac040100000fac0400000100a225368fe0983b5828a37a0acb37f253", + valid + "0001"] for t in tests: hapd0.dump_monitor() if "OK" not in hapd0.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): @@ -2025,7 +2025,7 @@ def test_ap_ft_over_ds_proto_ap(dev, apdev): def test_ap_ft_over_ds_proto(dev, apdev): """WPA2-PSK-FT AP over DS protocol testing""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2077,7 +2077,7 @@ def test_ap_ft_over_ds_proto(dev, apdev): def test_ap_ft_rrb(dev, apdev): """WPA2-PSK-FT RRB protocol testing""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2085,8 +2085,8 @@ def test_ap_ft_rrb(dev, apdev): dev[0].connect(ssid, psk=passphrase, key_mgmt="FT-PSK", proto="WPA2", scan_freq="2412") - _dst_ll = binascii.unhexlify(apdev[0]['bssid'].replace(':','')) - _src_ll = binascii.unhexlify(dev[0].own_addr().replace(':','')) + _dst_ll = binascii.unhexlify(apdev[0]['bssid'].replace(':', '')) + _src_ll = binascii.unhexlify(dev[0].own_addr().replace(':', '')) proto = b'\x89\x0d' ehdr = _dst_ll + _src_ll + proto @@ -2170,7 +2170,7 @@ def test_rsn_ie_proto_ft_psk_sta(dev, apdev): """RSN element protocol testing for FT-PSK + PMF cases on STA side""" bssid = apdev[0]['bssid'] ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["ieee80211w"] = "1" @@ -2181,17 +2181,17 @@ def test_rsn_ie_proto_ft_psk_sta(dev, apdev): ieee80211w="1", scan_freq="2412", pairwise="CCMP", group="CCMP") - tests = [ ('PMKIDCount field included', - '30160100000fac040100000fac040100000fac048c000000' + '3603a1b201'), - ('Extra IE before RSNE', - 'dd0400000000' + '30140100000fac040100000fac040100000fac048c00' + '3603a1b201'), - ('PMKIDCount and Group Management Cipher suite fields included', - '301a0100000fac040100000fac040100000fac048c000000000fac06' + '3603a1b201'), - ('Extra octet after defined fields (future extensibility)', - '301b0100000fac040100000fac040100000fac048c000000000fac0600' + '3603a1b201'), - ('No RSN Capabilities field (PMF disabled in practice)', - '30120100000fac040100000fac040100000fac04' + '3603a1b201') ] - for txt,ie in tests: + tests = [('PMKIDCount field included', + '30160100000fac040100000fac040100000fac048c000000' + '3603a1b201'), + ('Extra IE before RSNE', + 'dd0400000000' + '30140100000fac040100000fac040100000fac048c00' + '3603a1b201'), + ('PMKIDCount and Group Management Cipher suite fields included', + '301a0100000fac040100000fac040100000fac048c000000000fac06' + '3603a1b201'), + ('Extra octet after defined fields (future extensibility)', + '301b0100000fac040100000fac040100000fac048c000000000fac0600' + '3603a1b201'), + ('No RSN Capabilities field (PMF disabled in practice)', + '30120100000fac040100000fac040100000fac04' + '3603a1b201')] + for txt, ie in tests: dev[0].request("DISCONNECT") dev[0].wait_disconnected() logger.info(txt) @@ -2237,7 +2237,7 @@ def test_rsn_ie_proto_ft_psk_sta(dev, apdev): def test_ap_ft_ptk_rekey(dev, apdev): """WPA2-PSK-FT PTK rekeying triggered by station after roam""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2262,7 +2262,7 @@ def test_ap_ft_ptk_rekey(dev, apdev): def test_ap_ft_ptk_rekey_ap(dev, apdev): """WPA2-PSK-FT PTK rekeying triggered by AP after roam""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params['wpa_ptk_rekey'] = '2' @@ -2289,7 +2289,7 @@ def test_ap_ft_ptk_rekey_ap(dev, apdev): def test_ap_ft_internal_rrb_check(dev, apdev): """RRB internal delivery only to WPA enabled BSS""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -2301,7 +2301,7 @@ def test_ap_ft_internal_rrb_check(dev, apdev): if key_mgmt.split(' ')[0] != "FT-EAP": raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) - hapd1 = hostapd.add_ap(apdev[1], { "ssid" : ssid }) + hapd1 = hostapd.add_ap(apdev[1], {"ssid": ssid}) # Connect to WPA enabled AP dev[0].connect(ssid, key_mgmt="FT-EAP", proto="WPA2", ieee80211w="1", @@ -2316,7 +2316,7 @@ def test_ap_ft_internal_rrb_check(dev, apdev): def test_ap_ft_extra_ie(dev, apdev): """WPA2-PSK-FT AP with WPA2-PSK enabled and unexpected MDE""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["wpa_key_mgmt"] = "WPA-PSK FT-PSK" @@ -2345,7 +2345,7 @@ def test_ap_ft_extra_ie(dev, apdev): def test_ap_ft_ric(dev, apdev): """WPA2-PSK-FT AP and RIC""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2357,14 +2357,14 @@ def test_ap_ft_ric(dev, apdev): if "FAIL" not in dev[0].request("SET ric_ies q"): raise Exception("Invalid ric_ies value accepted") - tests = [ "3900", - "3900ff04eeeeeeee", - "390400000000", - "390400000000" + "390400000000", - "390400000000" + "dd050050f20202", - "390400000000" + "dd3d0050f2020201" + 55*"00", - "390400000000" + "dd3d0050f2020201aa300010270000000000000000000000000000000000000000000000000000ffffff7f00000000000000000000000040420f00ffff0000", - "390401010000" + "dd3d0050f2020201aa3000dc050000000000000000000000000000000000000000000000000000dc050000000000000000000000000000808d5b0028230000" ] + tests = ["3900", + "3900ff04eeeeeeee", + "390400000000", + "390400000000" + "390400000000", + "390400000000" + "dd050050f20202", + "390400000000" + "dd3d0050f2020201" + 55*"00", + "390400000000" + "dd3d0050f2020201aa300010270000000000000000000000000000000000000000000000000000ffffff7f00000000000000000000000040420f00ffff0000", + "390401010000" + "dd3d0050f2020201aa3000dc050000000000000000000000000000000000000000000000000000dc050000000000000000000000000000808d5b0028230000"] for t in tests: dev[0].set("ric_ies", t) run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, @@ -2379,7 +2379,7 @@ def ie_hex(ies, id): def test_ap_ft_reassoc_proto(dev, apdev): """WPA2-PSK-FT AP Reassociation Request frame parsing""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2420,43 +2420,43 @@ def test_ap_ft_reassoc_proto(dev, apdev): rsne = ie_hex(ies, 48) mde = ie_hex(ies, 54) fte = ie_hex(ies, 55) - tests = [ ] + tests = [] # RSN: Trying to use FT, but MDIE not included - tests += [ rsne ] + tests += [rsne] # RSN: Attempted to use unknown MDIE - tests += [ rsne + "3603000000" ] + tests += [rsne + "3603000000"] # Invalid RSN pairwise cipher - tests += [ "30260100000fac040100000fac030100000fac040000010029208a42cd25c85aa571567dce10dae3" ] + tests += ["30260100000fac040100000fac030100000fac040000010029208a42cd25c85aa571567dce10dae3"] # FT: No PMKID in RSNIE - tests += [ "30160100000fac040100000fac040100000fac0400000000" + ie_hex(ies, 54) ] + tests += ["30160100000fac040100000fac040100000fac0400000000" + ie_hex(ies, 54)] # FT: Invalid FTIE - tests += [ rsne + mde ] + tests += [rsne + mde] # FT: RIC IE(s) in the frame, but not included in protected IE count # FT: Failed to parse FT IEs - tests += [ rsne + mde + fte + "3900" ] + tests += [rsne + mde + fte + "3900"] # FT: SNonce mismatch in FTIE - tests += [ rsne + mde + "37520000" + 16*"00" + 32*"00" + 32*"00" ] + tests += [rsne + mde + "37520000" + 16*"00" + 32*"00" + 32*"00"] # FT: ANonce mismatch in FTIE - tests += [ rsne + mde + fte[0:40] + 32*"00" + fte[104:] ] + tests += [rsne + mde + fte[0:40] + 32*"00" + fte[104:]] # FT: No R0KH-ID subelem in FTIE - tests += [ rsne + mde + "3752" + fte[4:168] ] + tests += [rsne + mde + "3752" + fte[4:168]] # FT: R0KH-ID in FTIE did not match with the current R0KH-ID - tests += [ rsne + mde + "3755" + fte[4:168] + "0301ff" ] + tests += [rsne + mde + "3755" + fte[4:168] + "0301ff"] # FT: No R1KH-ID subelem in FTIE - tests += [ rsne + mde + "375e" + fte[4:168] + "030a" + binascii.hexlify(b"nas1.w1.fi").decode() ] + tests += [rsne + mde + "375e" + fte[4:168] + "030a" + binascii.hexlify(b"nas1.w1.fi").decode()] # FT: Unknown R1KH-ID used in ReassocReq - tests += [ rsne + mde + "3766" + fte[4:168] + "030a" + binascii.hexlify(b"nas1.w1.fi").decode() + "0106000000000000" ] + tests += [rsne + mde + "3766" + fte[4:168] + "030a" + binascii.hexlify(b"nas1.w1.fi").decode() + "0106000000000000"] # FT: PMKID in Reassoc Req did not match with the PMKR1Name derived from auth request - tests += [ rsne[:-32] + 16*"00" + mde + fte ] + tests += [rsne[:-32] + 16*"00" + mde + fte] # Invalid MIC in FTIE - tests += [ rsne + mde + fte[0:8] + 16*"00" + fte[40:] ] + tests += [rsne + mde + fte[0:8] + 16*"00" + fte[40:]] for t in tests: hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + ies1 + t) def test_ap_ft_reassoc_local_fail(dev, apdev): """WPA2-PSK-FT AP Reassociation Request frame and local failure""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2485,7 +2485,7 @@ def test_ap_ft_reassoc_replay(dev, apdev, params): """WPA2-PSK-FT AP and replayed Reassociation Request frame""" capfile = os.path.join(params['logdir'], "hwsim0.pcapng") ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) hapd0 = hostapd.add_ap(apdev[0], params) @@ -2555,7 +2555,7 @@ def test_ap_ft_reassoc_replay(dev, apdev, params): filt = "wlan.fc.type == 2 && " + \ "wlan.da == " + sta + " && " + \ "wlan.sa == " + ap - fields = [ "wlan.ccmp.extiv" ] + fields = ["wlan.ccmp.extiv"] res = run_tshark(capfile, filt, fields) vals = res.splitlines() logger.info("CCMP PN: " + str(vals)) @@ -2570,7 +2570,7 @@ def test_ap_ft_reassoc_replay(dev, apdev, params): def test_ap_ft_psk_file(dev, apdev): """WPA2-PSK-FT AP with PSK from a file""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1a(ssid=ssid, passphrase=passphrase) params['wpa_psk_file'] = 'hostapd.wpa_psk' @@ -2601,7 +2601,7 @@ def test_ap_ft_psk_file(dev, apdev): def test_ap_ft_eap_ap_config_change(dev, apdev): """WPA2-EAP-FT AP changing from 802.1X-only to FT-only""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" bssid = apdev[0]['bssid'] radius = hostapd.radius_params() @@ -2636,7 +2636,7 @@ def test_ap_ft_eap_ap_config_change(dev, apdev): def test_ap_ft_eap_sha384(dev, apdev): """WPA2-EAP-FT with SHA384""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -2658,7 +2658,7 @@ def test_ap_ft_eap_sha384(dev, apdev): def test_ap_ft_eap_sha384_over_ds(dev, apdev): """WPA2-EAP-FT with SHA384 over DS""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" radius = hostapd.radius_params() params = ft_params1(ssid=ssid, passphrase=passphrase) @@ -2680,7 +2680,7 @@ def test_ap_ft_eap_sha384_over_ds(dev, apdev): def test_ap_ft_roam_rrm(dev, apdev): """WPA2-PSK-FT AP and radio measurement request""" ssid = "test-ft" - passphrase="12345678" + passphrase = "12345678" params = ft_params1(ssid=ssid, passphrase=passphrase) params["rrm_beacon_report"] = "1" diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 937d6fa..5a11207 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -41,15 +41,15 @@ def hs20_ap_params(ssid="test-hs20"): params['uesa'] = "0" params['venue_group'] = "7" params['venue_type'] = "1" - params['venue_name'] = [ "eng:Example venue", "fin:Esimerkkipaikka" ] - params['roaming_consortium'] = [ "112233", "1020304050", "010203040506", - "fedcba" ] + params['venue_name'] = ["eng:Example venue", "fin:Esimerkkipaikka"] + params['roaming_consortium'] = ["112233", "1020304050", "010203040506", + "fedcba"] params['domain_name'] = "example.com,another.example.com" - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]", - "0,another.example.com" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]", + "0,another.example.com"] params['hs20'] = "1" params['hs20_wan_metrics'] = "01:8000:1000:80:240:3000" - params['hs20_conn_capab'] = [ "1:0:2", "6:22:1", "17:5060:0" ] + params['hs20_conn_capab'] = ["1:0:2", "6:22:1", "17:5060:0"] params['hs20_operating_class'] = "5173" params['anqp_3gpp_cell_net'] = "244,91" return params @@ -174,13 +174,13 @@ def test_ap_anqp_sharing(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['hessid'] = bssid - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) logger.info("Normal network selection with shared ANQP results") dev[0].scan_for_bss(bssid, freq="2412") dev[0].scan_for_bss(bssid2, freq="2412") @@ -234,9 +234,9 @@ def test_ap_anqp_domain_id(dev, apdev): hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) dev[0].scan_for_bss(bssid, freq="2412") dev[0].scan_for_bss(bssid2, freq="2412") interworking_select(dev[0], None, "home", freq="2412") @@ -254,13 +254,13 @@ def test_ap_anqp_no_sharing_diff_ess(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params(ssid="test-hs20-another") params['hessid'] = bssid - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) logger.info("Normal network selection with shared ANQP results") dev[0].scan_for_bss(bssid, freq="2412") dev[0].scan_for_bss(bssid2, freq="2412") @@ -283,13 +283,13 @@ def test_ap_anqp_no_sharing_missing_info(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['hessid'] = bssid - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) logger.info("Normal network selection with shared ANQP results") dev[0].scan_for_bss(bssid, freq="2412") dev[0].scan_for_bss(bssid2, freq="2412") @@ -308,13 +308,13 @@ def test_ap_anqp_sharing_oom(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['hessid'] = bssid - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) dev[0].scan_for_bss(bssid, freq="2412") dev[0].scan_for_bss(bssid2, freq="2412") interworking_select(dev[0], None, "home", freq="2412") @@ -331,8 +331,8 @@ def test_ap_nai_home_realm_query(dev, apdev): check_eap_capa(dev[0], "MSCHAPV2") bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]", - "0,another.example.org" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]", + "0,another.example.org"] hostapd.add_ap(apdev[0], params) dev[0].scan(freq="2412") @@ -360,9 +360,9 @@ def test_ap_nai_home_realm_query(dev, apdev): if binascii.hexlify(b"example.org").decode() not in nai2: raise Exception("Non-home realm not reported in wildcard query ") - cmds = [ "foo", - "00:11:22:33:44:55 123", - "00:11:22:33:44:55 qq" ] + cmds = ["foo", + "00:11:22:33:44:55 123", + "00:11:22:33:44:55 qq"] for cmd in cmds: if "FAIL" not in dev[0].request("HS20_GET_NAI_HOME_REALM_LIST " + cmd): raise Exception("Invalid HS20_GET_NAI_HOME_REALM_LIST accepted: " + cmd) @@ -386,9 +386,9 @@ def test_ap_nai_home_realm_query(dev, apdev): if "NAI Realm list" not in ev: raise Exception("Missing NAI Realm list: " + ev) - dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) dev[0].dump_monitor() if "OK" not in dev[0].request("HS20_GET_NAI_HOME_REALM_LIST " + bssid): raise Exception("HS20_GET_NAI_HOME_REALM_LIST failed") @@ -499,15 +499,15 @@ def test_ap_hs20_select(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test", - 'password': "secret", - 'domain': "no.match.example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", + 'password': "secret", + 'domain': "no.match.example.com"}) interworking_select(dev[0], bssid, "roaming", freq="2412") dev[0].set_cred_quoted(id, "realm", "no.match.example.com") @@ -519,14 +519,14 @@ def test_ap_hs20_select(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.org,21" ] + params['nai_realm'] = ["0,example.org,21"] params['hessid'] = bssid2 params['domain_name'] = "example.org" hostapd.add_ap(apdev[1], params) dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'realm': "example.org", 'username': "test", - 'password': "secret", - 'domain': "example.org" }) + id = dev[0].add_cred_values({'realm': "example.org", 'username': "test", + 'password': "secret", + 'domain': "example.org"}) interworking_select(dev[0], bssid2, "home", freq="2412") def hs20_simulated_sim(dev, ap, method): @@ -538,8 +538,8 @@ def hs20_simulated_sim(dev, ap, method): hostapd.add_ap(ap, params) dev.hs20_enable() - dev.add_cred_values({ 'imsi': "555444-333222111", 'eap': method, - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) + dev.add_cred_values({'imsi': "555444-333222111", 'eap': method, + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) interworking_select(dev, bssid, "home", freq="2412") interworking_connect(dev, bssid, method) check_sp_type(dev, "home") @@ -564,8 +564,8 @@ def test_ap_hs20_sim_invalid(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - dev[0].add_cred_values({ 'imsi': "555444-3332221110", 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) + dev[0].add_cred_values({'imsi': "555444-3332221110", 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) # This hits "No valid IMSI available" in build_root_nai() interworking_select(dev[0], bssid, freq="2412") @@ -580,8 +580,8 @@ def test_ap_hs20_sim_oom(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - dev[0].add_cred_values({ 'imsi': "555444-333222111", 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) + dev[0].add_cred_values({'imsi': "555444-333222111", 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) dev[0].scan_for_bss(bssid, freq=2412) interworking_select(dev[0], bssid, freq="2412") @@ -616,7 +616,7 @@ def test_ap_hs20_ext_sim(dev, apdev): dev[0].hs20_enable() try: dev[0].request("SET external_sim 1") - dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" }) + dev[0].add_cred_values({'imsi': "23201-0000000000", 'eap': "SIM"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_ext_sim_connect(dev[0], bssid, "SIM") check_sp_type(dev[0], "home") @@ -636,7 +636,7 @@ def test_ap_hs20_ext_sim_roaming(dev, apdev): dev[0].hs20_enable() try: dev[0].request("SET external_sim 1") - dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" }) + dev[0].add_cred_values({'imsi': "23201-0000000000", 'eap': "SIM"}) interworking_select(dev[0], bssid, "roaming", freq="2412") interworking_ext_sim_connect(dev[0], bssid, "SIM") check_sp_type(dev[0], "roaming") @@ -653,12 +653,12 @@ def test_ap_hs20_username(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com", - 'update_identifier': "1234" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com", + 'update_identifier': "1234"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "home") @@ -686,12 +686,12 @@ def test_ap_hs20_connect_api(dev, apdev): wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.hs20_enable() wpas.flush_scan_cache() - id = wpas.add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com", - 'update_identifier': "1234" }) + id = wpas.add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com", + 'update_identifier': "1234"}) interworking_select(wpas, bssid, "home", freq="2412") interworking_connect(wpas, bssid, "TTLS") check_sp_type(wpas, "home") @@ -711,12 +711,12 @@ def test_ap_hs20_auto_interworking(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable(auto_interworking=True) - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com", - 'update_identifier': "1234" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com", + 'update_identifier': "1234"}) dev[0].request("REASSOCIATE") dev[0].wait_connected(timeout=15) check_sp_type(dev[0], "home") @@ -729,19 +729,19 @@ def test_ap_hs20_auto_interworking(dev, apdev): @remote_compatible def test_ap_hs20_auto_interworking_no_match(dev, apdev): """Hotspot 2.0 connection with auto_interworking=1 and no matching network""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "mismatch" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "mismatch"}) dev[0].hs20_enable(auto_interworking=True) id = dev[0].connect("mismatch", psk="12345678", scan_freq="2412", only_add_network=True) dev[0].request("ENABLE_NETWORK " + str(id) + " no-connect") - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com", - 'update_identifier': "1234" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com", + 'update_identifier': "1234"}) dev[0].request("INTERWORKING_SELECT auto freq=2412") time.sleep(0.1) dev[0].dump_monitor() @@ -753,8 +753,8 @@ def test_ap_hs20_auto_interworking_no_match(dev, apdev): fetch = 0 scan = 0 for j in range(15): - ev = dev[0].wait_event([ "ANQP fetch completed", - "CTRL-EVENT-SCAN-RESULTS" ], timeout=0.05) + ev = dev[0].wait_event(["ANQP fetch completed", + "CTRL-EVENT-SCAN-RESULTS"], timeout=0.05) if ev is None: break if "ANQP fetch completed" in ev: @@ -770,15 +770,15 @@ def test_ap_hs20_auto_interworking_no_match(dev, apdev): def test_ap_hs20_auto_interworking_no_cred_match(dev, apdev): """Hotspot 2.0 connection with auto_interworking=1 but no cred match""" bssid = apdev[0]['bssid'] - params = { "ssid": "test" } + params = {"ssid": "test"} hostapd.add_ap(apdev[0], params) dev[0].hs20_enable(auto_interworking=True) - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com" }) + dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com"}) id = dev[0].connect("test", psk="12345678", only_add_network=True) dev[0].request("ENABLE_NETWORK %s" % id) @@ -792,16 +792,16 @@ def test_ap_hs20_auto_interworking_no_cred_match(dev, apdev): def eap_test(dev, ap, eap_params, method, user, release=0): bssid = ap['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com," + eap_params ] + params['nai_realm'] = ["0,example.com," + eap_params] if release > 0: params['hs20_release'] = str(release) hostapd.add_ap(ap, params) dev.hs20_enable() - dev.add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': user, - 'password': "password" }) + dev.add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': user, + 'password': "password"}) interworking_select(dev, bssid, freq="2412") interworking_connect(dev, bssid, method) @@ -913,15 +913,15 @@ def test_ap_hs20_eap_tls(dev, apdev): """Hotspot 2.0 connection with EAP-TLS""" bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,13[5:6]" ] + params['nai_realm'] = ["0,example.com,13[5:6]"] hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "certificate-user", - 'ca_cert': "auth_serv/ca.pem", - 'client_cert': "auth_serv/user.pem", - 'private_key': "auth_serv/user.key"}) + dev[0].add_cred_values({'realm': "example.com", + 'username': "certificate-user", + 'ca_cert': "auth_serv/ca.pem", + 'client_cert': "auth_serv/user.pem", + 'private_key': "auth_serv/user.key"}) interworking_select(dev[0], bssid, freq="2412") interworking_connect(dev[0], bssid, "TLS") @@ -930,15 +930,15 @@ def test_ap_hs20_eap_cert_unknown(dev, apdev): """Hotspot 2.0 connection with certificate, but unknown EAP method""" bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,99[5:6]" ] + params['nai_realm'] = ["0,example.com,99[5:6]"] hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "certificate-user", - 'ca_cert': "auth_serv/ca.pem", - 'client_cert': "auth_serv/user.pem", - 'private_key': "auth_serv/user.key"}) + dev[0].add_cred_values({'realm': "example.com", + 'username': "certificate-user", + 'ca_cert': "auth_serv/ca.pem", + 'client_cert': "auth_serv/user.pem", + 'private_key': "auth_serv/user.key"}) interworking_select(dev[0], None, no_match=True, freq="2412") @remote_compatible @@ -946,15 +946,15 @@ def test_ap_hs20_eap_cert_unsupported(dev, apdev): """Hotspot 2.0 connection with certificate, but unsupported TTLS""" bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,21[5:6]" ] + params['nai_realm'] = ["0,example.com,21[5:6]"] hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "certificate-user", - 'ca_cert': "auth_serv/ca.pem", - 'client_cert': "auth_serv/user.pem", - 'private_key': "auth_serv/user.key"}) + dev[0].add_cred_values({'realm': "example.com", + 'username': "certificate-user", + 'ca_cert': "auth_serv/ca.pem", + 'client_cert': "auth_serv/user.pem", + 'private_key': "auth_serv/user.key"}) interworking_select(dev[0], None, no_match=True, freq="2412") @remote_compatible @@ -965,9 +965,9 @@ def test_ap_hs20_eap_invalid_cred(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "certificate-user", - 'client_cert': "auth_serv/user.pem" }) + dev[0].add_cred_values({'realm': "example.com", + 'username': "certificate-user", + 'client_cert': "auth_serv/user.pem"}) interworking_select(dev[0], None, no_match=True, freq="2412") def test_ap_hs20_nai_realms(dev, apdev): @@ -975,15 +975,15 @@ def test_ap_hs20_nai_realms(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() params['hessid'] = bssid - params['nai_realm'] = [ "0,no.match.here;example.com;no.match.here.either,21[2:1][5:7]" ] + params['nai_realm'] = ["0,no.match.here;example.com;no.match.here.either,21[2:1][5:7]"] hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "pap user", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "pap user", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "home") @@ -996,13 +996,13 @@ def test_ap_hs20_roaming_consortium(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - for consortium in [ "112233", "1020304050", "010203040506", "fedcba" ]: - id = dev[0].add_cred_values({ 'username': "user", - 'password': "password", - 'domain': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'roaming_consortium': consortium, - 'eap': "PEAP" }) + for consortium in ["112233", "1020304050", "010203040506", "fedcba"]: + id = dev[0].add_cred_values({'username': "user", + 'password': "password", + 'domain': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'roaming_consortium': consortium, + 'eap': "PEAP"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "PEAP") check_sp_type(dev[0], "home") @@ -1020,15 +1020,15 @@ def test_ap_hs20_roaming_consortiums_match(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - tests = [ ("112233", "112233"), - ("ffffff,1020304050,eeeeee", "1020304050") ] - for consortium,selected in tests: - id = dev[0].add_cred_values({ 'username': "user", - 'password': "password", - 'domain': "my.home.example.com", - 'ca_cert': "auth_serv/ca.pem", - 'roaming_consortiums': consortium, - 'eap': "PEAP" }) + tests = [("112233", "112233"), + ("ffffff,1020304050,eeeeee", "1020304050")] + for consortium, selected in tests: + id = dev[0].add_cred_values({'username': "user", + 'password': "password", + 'domain': "my.home.example.com", + 'ca_cert': "auth_serv/ca.pem", + 'roaming_consortiums': consortium, + 'eap': "PEAP"}) interworking_select(dev[0], bssid, "roaming", freq="2412") interworking_connect(dev[0], bssid, "PEAP") check_sp_type(dev[0], "roaming") @@ -1065,12 +1065,12 @@ def test_ap_hs20_roaming_consortium_invalid(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'username': "user", - 'password': "password", - 'domain': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'roaming_consortium': "fedcba", - 'eap': "PEAP" }) + id = dev[0].add_cred_values({'username': "user", + 'password': "password", + 'domain': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'roaming_consortium': "fedcba", + 'eap': "PEAP"}) interworking_select(dev[0], bssid, "home", freq="2412", no_match=True) def test_ap_hs20_roaming_consortium_element(dev, apdev): @@ -1084,12 +1084,12 @@ def test_ap_hs20_roaming_consortium_element(dev, apdev): dev[0].hs20_enable() dev[0].scan_for_bss(bssid, freq="2412") - id = dev[0].add_cred_values({ 'username': "user", - 'password': "password", - 'domain': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'roaming_consortium': "112233", - 'eap': "PEAP" }) + id = dev[0].add_cred_values({'username': "user", + 'password': "password", + 'domain': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'roaming_consortium': "112233", + 'eap': "PEAP"}) interworking_select(dev[0], bssid, freq="2412", no_match=True) hapd.set('vendor_elements', '6f020001') @@ -1109,12 +1109,12 @@ def test_ap_hs20_roaming_consortium_constraints(dev, apdev): dev[0].hs20_enable() - vals = { 'username': "user", - 'password': "password", - 'domain': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'roaming_consortium': "fedcba", - 'eap': "TTLS" } + vals = {'username': "user", + 'password': "password", + 'domain': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'roaming_consortium': "fedcba", + 'eap': "TTLS"} vals2 = vals.copy() vals2['required_roaming_consortium'] = "223344" id = dev[0].add_cred_values(vals2) @@ -1189,9 +1189,9 @@ def test_ap_hs20_3gpp_constraints(dev, apdev): dev[0].hs20_enable() - vals = { 'imsi': "555444-333222111", - 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123" } + vals = {'imsi': "555444-333222111", + 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"} vals2 = vals.copy() vals2['required_roaming_consortium'] = "223344" id = dev[0].add_cred_values(vals2) @@ -1268,13 +1268,13 @@ def test_ap_hs20_connect_no_full_match(dev, apdev): dev[0].hs20_enable() - vals = { 'username': "user", - 'password': "password", - 'domain': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'roaming_consortium': "fedcba", - 'eap': "TTLS", - 'min_dl_bandwidth_home': "65500" } + vals = {'username': "user", + 'password': "password", + 'domain': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'roaming_consortium': "fedcba", + 'eap': "TTLS", + 'min_dl_bandwidth_home': "65500"} id = dev[0].add_cred_values(vals) dev[0].request("INTERWORKING_SELECT freq=2412") ev = dev[0].wait_event(["INTERWORKING-AP"], timeout=15) @@ -1286,9 +1286,9 @@ def test_ap_hs20_connect_no_full_match(dev, apdev): dev[0].remove_cred(id) dev[0].wait_disconnected() - vals = { 'imsi': "555444-333222111", 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123", - 'min_dl_bandwidth_roaming': "65500" } + vals = {'imsi': "555444-333222111", 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123", + 'min_dl_bandwidth_roaming': "65500"} id = dev[0].add_cred_values(vals) dev[0].request("INTERWORKING_SELECT freq=2412") ev = dev[0].wait_event(["INTERWORKING-AP"], timeout=15) @@ -1305,19 +1305,19 @@ def test_ap_hs20_username_roaming(dev, apdev): check_eap_capa(dev[0], "MSCHAPV2") bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]", - "0,roaming.example.com,21[2:4][5:7]", - "0,another.example.com" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]", + "0,roaming.example.com,21[2:4][5:7]", + "0,another.example.com"] params['domain_name'] = "another.example.com" params['hessid'] = bssid hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "roaming.example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "roaming.example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "roaming", freq="2412") interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "roaming") @@ -1331,10 +1331,10 @@ def test_ap_hs20_username_unknown(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password"}) interworking_select(dev[0], bssid, "unknown", freq="2412") interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "unknown") @@ -1349,11 +1349,11 @@ def test_ap_hs20_username_unknown2(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "unknown", freq="2412") interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "unknown") @@ -1367,11 +1367,11 @@ def test_ap_hs20_gas_while_associated(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") @@ -1393,15 +1393,15 @@ def test_ap_hs20_gas_with_another_ap_while_associated(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['hessid'] = bssid2 - params['nai_realm'] = [ "0,no-match.example.org,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,no-match.example.org,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") dev[0].dump_monitor() @@ -1437,16 +1437,16 @@ def _test_ap_hs20_gas_while_associated_with_pmf(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['hessid'] = bssid2 - params['nai_realm'] = [ "0,no-match.example.org,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,no-match.example.org,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() dev[0].request("SET pmf 2") - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") @@ -1474,16 +1474,16 @@ def _test_ap_hs20_gas_with_another_ap_while_using_pmf(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['hessid'] = bssid2 - params['nai_realm'] = [ "0,no-match.example.org,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,no-match.example.org,13[5:6],21[2:4][5:7]"] hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() dev[0].request("SET pmf 2") - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") dev[0].dump_monitor() @@ -1512,11 +1512,11 @@ def test_ap_hs20_gas_frag_while_associated(dev, apdev): hapd.set("gas_frag_limit", "50") dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) interworking_select(dev[0], bssid, "home", freq="2412") interworking_connect(dev[0], bssid, "TTLS") @@ -1536,11 +1536,11 @@ def test_ap_hs20_multiple_connects(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" } + values = {'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"} id = dev[0].add_cred_values(values) dev[0].scan_for_bss(bssid, freq="2412") @@ -1576,11 +1576,11 @@ def test_ap_hs20_disallow_aps(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" } + values = {'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"} id = dev[0].add_cred_values(values) dev[0].scan_for_bss(bssid, freq="2412") @@ -1657,10 +1657,10 @@ def policy_test(dev, ap, values, only_one=True): return events def default_cred(domain=None, user="hs20-test"): - cred = { 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': user, - 'password': "password" } + cred = {'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': user, + 'password': "password"} if domain: cred['domain'] = domain return cred @@ -1691,7 +1691,7 @@ def test_ap_hs20_req_roaming_consortium(dev, apdev): params = hs20_ap_params() params['ssid'] = "test-hs20-other" - params['roaming_consortium'] = [ "223344" ] + params['roaming_consortium'] = ["223344"] hostapd.add_ap(apdev[1], params) values = default_cred() @@ -1704,7 +1704,8 @@ def test_ap_hs20_req_roaming_consortium(dev, apdev): dev[0].set_cred(id, "required_roaming_consortium", "112233") dev[0].set_cred(id, "required_roaming_consortium", "112233445566778899aabbccddeeff") - for val in [ "", "1", "11", "1122", "1122334", "112233445566778899aabbccddeeff00" ]: + for val in ["", "1", "11", "1122", "1122334", + "112233445566778899aabbccddeeff00"]: if "FAIL" not in dev[0].request('SET_CRED {} required_roaming_consortium {}'.format(id, val)): raise Exception("Invalid roaming consortium value accepted: " + val) @@ -1717,7 +1718,7 @@ def test_ap_hs20_req_roaming_consortium_no_match(dev, apdev): params = hs20_ap_params() params['ssid'] = "test-hs20-other" - params['roaming_consortium'] = [ "223345" ] + params['roaming_consortium'] = ["223345"] hostapd.add_ap(apdev[1], params) values = default_cred() @@ -1733,13 +1734,13 @@ def test_ap_hs20_excluded_ssid(dev, apdev): """Hotspot 2.0 exclusion based on SSID""" check_eap_capa(dev[0], "MSCHAPV2") params = hs20_ap_params() - params['roaming_consortium'] = [ "223344" ] + params['roaming_consortium'] = ["223344"] params['anqp_3gpp_cell_net'] = "555,444" hostapd.add_ap(apdev[0], params) params = hs20_ap_params() params['ssid'] = "test-hs20-other" - params['roaming_consortium'] = [ "223344" ] + params['roaming_consortium'] = ["223344"] params['anqp_3gpp_cell_net'] = "555,444" hostapd.add_ap(apdev[1], params) @@ -1765,9 +1766,9 @@ def test_ap_hs20_excluded_ssid(dev, apdev): if len(ev) != 1: raise Exception("Excluded network not reported") - values = { 'imsi': "555444-333222111", 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123", - 'excluded_ssid': "test-hs20" } + values = {'imsi': "555444-333222111", 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123", + 'excluded_ssid': "test-hs20"} events = policy_test(dev[0], apdev[1], values) ev = [e for e in events if "INTERWORKING-BLACKLISTED " + apdev[0]['bssid'] in e] if len(ev) != 1: @@ -1782,11 +1783,11 @@ def test_ap_hs20_roam_to_higher_prio(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) logger.info("Connect to the only network option") interworking_select(dev[0], bssid, "roaming", freq="2412") dev[0].dump_monitor() @@ -1821,12 +1822,12 @@ def test_ap_hs20_domain_suffix_match_full(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com", - 'domain_suffix_match': "server.w1.fi" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com", + 'domain_suffix_match': "server.w1.fi"}) interworking_select(dev[0], bssid, "home", freq="2412") dev[0].dump_monitor() interworking_connect(dev[0], bssid, "TTLS") @@ -1852,12 +1853,12 @@ def test_ap_hs20_domain_suffix_match(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com", - 'domain_suffix_match': "w1.fi" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com", + 'domain_suffix_match': "w1.fi"}) interworking_select(dev[0], bssid, "home", freq="2412") dev[0].dump_monitor() interworking_connect(dev[0], bssid, "TTLS") @@ -1984,16 +1985,16 @@ def _test_ap_hs20_multi_cred_sp_prio(dev, apdev): dev[0].hs20_enable() dev[0].scan_for_bss(bssid, freq="2412") dev[0].request("SET external_sim 1") - id1 = dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM", - 'provisioning_sp': "example.com", - 'sp_priority' :"1" }) - id2 = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com", - 'provisioning_sp': "example.com", - 'sp_priority': "2" }) + id1 = dev[0].add_cred_values({'imsi': "23201-0000000000", 'eap': "SIM", + 'provisioning_sp': "example.com", + 'sp_priority' :"1"}) + id2 = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com", + 'provisioning_sp': "example.com", + 'sp_priority': "2"}) dev[0].dump_monitor() dev[0].scan_for_bss(bssid, freq="2412") dev[0].request("INTERWORKING_SELECT auto freq=2412") @@ -2036,16 +2037,16 @@ def _test_ap_hs20_multi_cred_sp_prio2(dev, apdev): dev[0].hs20_enable() dev[0].request("SET external_sim 1") - id1 = dev[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM", - 'provisioning_sp': "example.com", - 'sp_priority': "1" }) - id2 = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com", - 'provisioning_sp': "example.com", - 'sp_priority': "2" }) + id1 = dev[0].add_cred_values({'imsi': "23201-0000000000", 'eap': "SIM", + 'provisioning_sp': "example.com", + 'sp_priority': "1"}) + id2 = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com", + 'provisioning_sp': "example.com", + 'sp_priority': "2"}) dev[0].dump_monitor() dev[0].scan_for_bss(bssid, freq="2412") dev[0].scan_for_bss(bssid2, freq="2412") @@ -2080,20 +2081,20 @@ def test_ap_hs20_multi_cred_sp_prio_same(dev, apdev): dev[0].hs20_enable() dev[0].scan_for_bss(bssid, freq="2412") - id1 = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "domain1.example.com", - 'provisioning_sp': "example.com", - 'sp_priority': "1" }) - id2 = dev[0].add_cred_values({ 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "domain2.example.com", - 'provisioning_sp': "example.com", - 'sp_priority': "1" }) + id1 = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "domain1.example.com", + 'provisioning_sp': "example.com", + 'sp_priority': "1"}) + id2 = dev[0].add_cred_values({'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "domain2.example.com", + 'provisioning_sp': "example.com", + 'sp_priority': "1"}) dev[0].dump_monitor() dev[0].scan_for_bss(bssid, freq="2412") check_auto_select(dev[0], bssid) @@ -2153,7 +2154,7 @@ def test_ap_hs20_req_conn_capab(dev, apdev): bssid2 = apdev[1]['bssid'] params = hs20_ap_params(ssid="test-hs20b") - params['hs20_conn_capab'] = [ "1:0:2", "6:22:1", "17:5060:0", "50:0:1" ] + params['hs20_conn_capab'] = ["1:0:2", "6:22:1", "17:5060:0", "50:0:1"] hostapd.add_ap(apdev[1], params) dev[0].remove_cred(id) @@ -2191,7 +2192,7 @@ def test_ap_hs20_req_conn_capab_and_roaming_partner_preference(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() params['domain_name'] = "roaming.example.org" - params['hs20_conn_capab'] = [ "1:0:2", "6:22:1", "17:5060:0", "50:0:1" ] + params['hs20_conn_capab'] = ["1:0:2", "6:22:1", "17:5060:0", "50:0:1"] hostapd.add_ap(apdev[0], params) bssid2 = apdev[1]['bssid'] @@ -2305,8 +2306,8 @@ def test_ap_hs20_min_bandwidth_home_hidden_ssid_in_scan_res(dev, apdev): check_eap_capa(dev[0], "MSCHAPV2") bssid = apdev[0]['bssid'] - hapd = hostapd.add_ap(apdev[0], { "ssid": 'secret', - "ignore_broadcast_ssid": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'secret', + "ignore_broadcast_ssid": "1"}) dev[0].scan_for_bss(bssid, freq=2412) hapd.disable() hapd_global = hostapd.HostapdGlobal(apdev[0]) @@ -2495,15 +2496,15 @@ def test_ap_hs20_deauth_req_from_radius(dev, apdev): def _test_ap_hs20_deauth_req_from_radius(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,21[2:4]" ] + params['nai_realm'] = ["0,example.com,21[2:4]"] params['hs20_deauth_req_timeout'] = "2" hostapd.add_ap(apdev[0], params) dev[0].request("SET pmf 2") dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-deauth-test", - 'password': "password" }) + dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-deauth-test", + 'password': "password"}) interworking_select(dev[0], bssid, freq="2412") interworking_connect(dev[0], bssid, "TTLS") ev = dev[0].wait_event(["HS20-DEAUTH-IMMINENT-NOTICE"], timeout=5) @@ -2546,14 +2547,14 @@ def test_ap_hs20_remediation_required(dev, apdev): def _test_ap_hs20_remediation_required(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,21[2:4]" ] + params['nai_realm'] = ["0,example.com,21[2:4]"] hostapd.add_ap(apdev[0], params) dev[0].request("SET pmf 1") dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-subrem-test", - 'password': "password" }) + dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-subrem-test", + 'password': "password"}) interworking_select(dev[0], bssid, freq="2412") interworking_connect(dev[0], bssid, "TTLS") ev = dev[0].wait_event(["HS20-SUBSCRIPTION-REMEDIATION"], timeout=5) @@ -2574,7 +2575,7 @@ def _test_ap_hs20_remediation_required_ctrl(dev, apdev): bssid = apdev[0]['bssid'] addr = dev[0].own_addr() params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,21[2:4]" ] + params['nai_realm'] = ["0,example.com,21[2:4]"] hapd = hostapd.add_ap(apdev[0], params) dev[0].request("SET pmf 1") @@ -2617,14 +2618,14 @@ def test_ap_hs20_session_info(dev, apdev): def _test_ap_hs20_session_info(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['nai_realm'] = [ "0,example.com,21[2:4]" ] + params['nai_realm'] = ["0,example.com,21[2:4]"] hostapd.add_ap(apdev[0], params) dev[0].request("SET pmf 1") dev[0].hs20_enable() - dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-session-info-test", - 'password': "password" }) + dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-session-info-test", + 'password': "password"}) interworking_select(dev[0], bssid, freq="2412") interworking_connect(dev[0], bssid, "TTLS") ev = dev[0].wait_event(["ESS-DISASSOC-IMMINENT"], timeout=10) @@ -2641,11 +2642,11 @@ def _test_ap_hs20_session_info(dev, apdev): def test_ap_hs20_osen(dev, apdev): """Hotspot 2.0 OSEN connection""" - params = { 'ssid': "osen", - 'osen': "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "1812", - 'auth_server_shared_secret': "radius" } + params = {'ssid': "osen", + 'osen': "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "1812", + 'auth_server_shared_secret': "radius"} hostapd.add_ap(apdev[0], params) dev[1].connect("osen", key_mgmt="NONE", scan_freq="2412", @@ -2719,10 +2720,10 @@ def test_ap_hs20_network_preference(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" } + values = {'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"} dev[0].add_cred_values(values) id = dev[0].add_network() @@ -2744,7 +2745,7 @@ def test_ap_hs20_network_preference(dev, apdev): dev[0].scan_for_bss(bssid2, freq="2412") dev[0].request("INTERWORKING_SELECT auto freq=2412") ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", - "INTERWORKING-ALREADY-CONNECTED" ], timeout=15) + "INTERWORKING-ALREADY-CONNECTED"], timeout=15) if ev is None: raise Exception("Connection timed out") if "INTERWORKING-ALREADY-CONNECTED" in ev: @@ -2760,11 +2761,11 @@ def test_ap_hs20_network_preference2(dev, apdev): hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com", - 'priority': "1" } + values = {'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com", + 'priority': "1"} dev[0].add_cred_values(values) id = dev[0].add_network() @@ -2785,7 +2786,7 @@ def test_ap_hs20_network_preference2(dev, apdev): dev[0].scan_for_bss(bssid, freq="2412") dev[0].request("INTERWORKING_SELECT auto freq=2412") ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", - "INTERWORKING-ALREADY-CONNECTED" ], timeout=15) + "INTERWORKING-ALREADY-CONNECTED"], timeout=15) if ev is None: raise Exception("Connection timed out") if "INTERWORKING-ALREADY-CONNECTED" in ev: @@ -2806,14 +2807,14 @@ def test_ap_hs20_network_preference3(dev, apdev): hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'priority': "1" } + values = {'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'priority': "1"} dev[0].add_cred_values(values) - values = { 'realm': "example.org", - 'username': "hs20-test", - 'password': "password" } + values = {'realm': "example.org", + 'username': "hs20-test", + 'password': "password"} id = dev[0].add_cred_values(values) dev[0].scan_for_bss(bssid, freq="2412") @@ -2826,7 +2827,7 @@ def test_ap_hs20_network_preference3(dev, apdev): dev[0].set_cred(id, "priority", "2") dev[0].request("INTERWORKING_SELECT auto freq=2412") ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", - "INTERWORKING-ALREADY-CONNECTED" ], timeout=15) + "INTERWORKING-ALREADY-CONNECTED"], timeout=15) if ev is None: raise Exception("Connection timed out") if "INTERWORKING-ALREADY-CONNECTED" in ev: @@ -2849,14 +2850,14 @@ def test_ap_hs20_network_preference4(dev, apdev): hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'priority': "1" } + values = {'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'priority': "1"} dev[0].add_cred_values(values) - values = { 'imsi': "555444-333222111", - 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123" } + values = {'imsi': "555444-333222111", + 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"} id = dev[0].add_cred_values(values) dev[0].scan_for_bss(bssid, freq="2412") @@ -2869,7 +2870,7 @@ def test_ap_hs20_network_preference4(dev, apdev): dev[0].set_cred(id, "priority", "2") dev[0].request("INTERWORKING_SELECT auto freq=2412") ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", - "INTERWORKING-ALREADY-CONNECTED" ], timeout=15) + "INTERWORKING-ALREADY-CONNECTED"], timeout=15) if ev is None: raise Exception("Connection timed out") if "INTERWORKING-ALREADY-CONNECTED" in ev: @@ -2885,10 +2886,10 @@ def test_ap_hs20_interworking_select_blocking_scan(dev, apdev): hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" } + values = {'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"} dev[0].add_cred_values(values) dev[0].scan_for_bss(bssid, freq="2412") @@ -2904,9 +2905,9 @@ def test_ap_hs20_fetch_osu(dev, apdev): params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png" params['osu_ssid'] = '"HS 2.0 OSU open"' params['osu_method_list'] = "1" - params['osu_friendly_name'] = [ "eng:Test OSU", "fin:Testi-OSU" ] + params['osu_friendly_name'] = ["eng:Test OSU", "fin:Testi-OSU"] params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ] + params['osu_service_desc'] = ["eng:Example services", "fin:Esimerkkipalveluja"] params['osu_server_uri'] = "https://example.com/osu/" hostapd.add_ap(apdev[0], params) @@ -2917,9 +2918,9 @@ def test_ap_hs20_fetch_osu(dev, apdev): params['osu_ssid'] = '"HS 2.0 OSU OSEN"' params['osu_method_list'] = "0" params['osu_nai'] = "osen@example.com" - params['osu_friendly_name'] = [ "eng:Test2 OSU", "fin:Testi2-OSU" ] + params['osu_friendly_name'] = ["eng:Test2 OSU", "fin:Testi2-OSU"] params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = [ "eng:Example services2", "fin:Esimerkkipalveluja2" ] + params['osu_service_desc'] = ["eng:Example services2", "fin:Esimerkkipalveluja2"] params['osu_server_uri'] = "https://example.org/osu/" hostapd.add_ap(apdev[1], params) @@ -2928,7 +2929,7 @@ def test_ap_hs20_fetch_osu(dev, apdev): dev[0].hs20_enable() dir = "/tmp/osu-fetch" if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) else: @@ -2969,7 +2970,7 @@ def test_ap_hs20_fetch_osu(dev, apdev): if "OSU-PROVIDER " + bssid2 not in prov: raise Exception("Missing OSU_PROVIDER(2)") finally: - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) os.rmdir(dir) @@ -3060,7 +3061,7 @@ def test_ap_hs20_fetch_osu_no_info(dev, apdev): dev[0].hs20_enable() dir = "/tmp/osu-fetch" if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) else: @@ -3076,7 +3077,7 @@ def test_ap_hs20_fetch_osu_no_info(dev, apdev): if ev is None: raise Exception("Timeout on OSU fetch") finally: - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) os.rmdir(dir) @@ -3088,16 +3089,17 @@ def test_ap_hs20_fetch_osu_no_icon(dev, apdev): params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo-no-file.png" params['osu_ssid'] = '"HS 2.0 OSU open"' params['osu_method_list'] = "1" - params['osu_friendly_name'] = [ "eng:Test OSU", "fin:Testi-OSU" ] + params['osu_friendly_name'] = ["eng:Test OSU", "fin:Testi-OSU"] params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ] + params['osu_service_desc'] = ["eng:Example services", + "fin:Esimerkkipalveluja"] params['osu_server_uri'] = "https://example.com/osu/" hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() dir = "/tmp/osu-fetch" if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) else: @@ -3113,7 +3115,7 @@ def test_ap_hs20_fetch_osu_no_icon(dev, apdev): if ev is None: raise Exception("Timeout on OSU fetch") finally: - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) os.rmdir(dir) @@ -3125,10 +3127,11 @@ def test_ap_hs20_fetch_osu_single_ssid(dev, apdev): params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo-no-file.png" params['osu_ssid'] = '"HS 2.0 OSU open"' params['osu_method_list'] = "1" - params['osu_friendly_name'] = [ "eng:Test OSU", "fin:Testi-OSU" ] + params['osu_friendly_name'] = ["eng:Test OSU", "fin:Testi-OSU"] params['osu_nai2'] = "osen@example.com" params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ] + params['osu_service_desc'] = ["eng:Example services", + "fin:Esimerkkipalveluja"] params['osu_server_uri'] = "https://example.com/osu/" params['wpa_key_mgmt'] = "WPA-EAP OSEN" hostapd.add_ap(apdev[0], params) @@ -3136,7 +3139,7 @@ def test_ap_hs20_fetch_osu_single_ssid(dev, apdev): dev[0].hs20_enable() dir = "/tmp/osu-fetch" if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) else: @@ -3175,7 +3178,7 @@ def test_ap_hs20_fetch_osu_single_ssid(dev, apdev): if not osu_nai2: raise Exception("osu_nai2 not reported") finally: - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) os.rmdir(dir) @@ -3187,10 +3190,11 @@ def test_ap_hs20_fetch_osu_single_ssid2(dev, apdev): params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo-no-file.png" params['osu_ssid'] = '"HS 2.0 OSU open"' params['osu_method_list'] = "1" - params['osu_friendly_name'] = [ "eng:Test OSU", "fin:Testi-OSU" ] + params['osu_friendly_name'] = ["eng:Test OSU", "fin:Testi-OSU"] params['osu_nai2'] = "osen@example.com" params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ] + params['osu_service_desc'] = ["eng:Example services", + "fin:Esimerkkipalveluja"] params['osu_server_uri'] = "https://example.com/osu/" params['wpa_key_mgmt'] = "WPA-EAP OSEN" hapd = hostapd.add_ap(apdev[0], params, no_enable=True) @@ -3203,7 +3207,7 @@ def test_ap_hs20_fetch_osu_single_ssid2(dev, apdev): dev[0].hs20_enable() dir = "/tmp/osu-fetch" if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) else: @@ -3247,7 +3251,7 @@ def test_ap_hs20_fetch_osu_single_ssid2(dev, apdev): if not osu_nai2b: raise Exception("osu_nai2b not reported") finally: - files = [ f for f in os.listdir(dir) if f.startswith("osu-") ] + files = [f for f in os.listdir(dir) if f.startswith("osu-")] for f in files: os.remove(dir + "/" + f) os.rmdir(dir) @@ -3271,13 +3275,14 @@ def test_ap_hs20_req_hs20_icon(dev, apdev): """Hotspot 2.0 OSU provider and multi-icon fetch with REQ_HS20_ICON""" bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['hs20_icon'] = [ "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png", - "128:80:zxx:image/png:test_logo:auth_serv/sha512-server.pem" ] + params['hs20_icon'] = ["128:80:zxx:image/png:w1fi_logo:w1fi_logo.png", + "128:80:zxx:image/png:test_logo:auth_serv/sha512-server.pem"] params['osu_ssid'] = '"HS 2.0 OSU open"' params['osu_method_list'] = "1" - params['osu_friendly_name'] = [ "eng:Test OSU", "fin:Testi-OSU" ] - params['osu_icon'] = [ "w1fi_logo", "w1fi_logo2" ] - params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ] + params['osu_friendly_name'] = ["eng:Test OSU", "fin:Testi-OSU"] + params['osu_icon'] = ["w1fi_logo", "w1fi_logo2"] + params['osu_service_desc'] = ["eng:Example services", + "fin:Esimerkkipalveluja"] params['osu_server_uri'] = "https://example.com/osu/" hostapd.add_ap(apdev[0], params) @@ -3325,9 +3330,9 @@ def test_ap_hs20_req_operator_icon(dev, apdev): """Hotspot 2.0 operator icons""" bssid = apdev[0]['bssid'] params = hs20_ap_params() - params['hs20_icon'] = [ "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png", - "500:300:fi:image/png:test_logo:auth_serv/sha512-server.pem" ] - params['operator_icon'] = [ "w1fi_logo", "unknown_logo", "test_logo" ] + params['hs20_icon'] = ["128:80:zxx:image/png:w1fi_logo:w1fi_logo.png", + "500:300:fi:image/png:test_logo:auth_serv/sha512-server.pem"] + params['operator_icon'] = ["w1fi_logo", "unknown_logo", "test_logo"] hostapd.add_ap(apdev[0], params) value = struct.pack('BBBBL3BB', 2, 1, 6, 0, 12345, 0, 0, 0, 0) payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + 192*b'\x00' # magic @@ -4522,14 +4532,14 @@ def build_dhcp_ack(dst_ll, src_ll, ip_src, ip_dst, yiaddr, chaddr, def build_arp(dst_ll, src_ll, opcode, sender_mac, sender_ip, target_mac, target_ip): - _dst_ll = binascii.unhexlify(dst_ll.replace(':','')) - _src_ll = binascii.unhexlify(src_ll.replace(':','')) + _dst_ll = binascii.unhexlify(dst_ll.replace(':', '')) + _src_ll = binascii.unhexlify(src_ll.replace(':', '')) proto = b'\x08\x06' ehdr = _dst_ll + _src_ll + proto - _sender_mac = binascii.unhexlify(sender_mac.replace(':','')) + _sender_mac = binascii.unhexlify(sender_mac.replace(':', '')) _sender_ip = socket.inet_pton(socket.AF_INET, sender_ip) - _target_mac = binascii.unhexlify(target_mac.replace(':','')) + _target_mac = binascii.unhexlify(target_mac.replace(':', '')) _target_ip = socket.inet_pton(socket.AF_INET, target_ip) arp = struct.pack('>HHBBH', 1, 0x0800, 6, 4, opcode) @@ -4565,7 +4575,7 @@ def get_permanent_neighbors(ifname): cmd = subprocess.Popen(['ip', 'nei'], stdout=subprocess.PIPE) res = cmd.stdout.read().decode() cmd.stdout.close() - return [ line for line in res.splitlines() if "PERMANENT" in line and ifname in line ] + return [line for line in res.splitlines() if "PERMANENT" in line and ifname in line] def get_bridge_macs(ifname): cmd = subprocess.Popen(['brctl', 'showmacs', ifname], @@ -4576,9 +4586,9 @@ def get_bridge_macs(ifname): def tshark_get_arp(cap, filter): res = run_tshark(cap, filter, - [ "eth.dst", "eth.src", - "arp.src.hw_mac", "arp.src.proto_ipv4", - "arp.dst.hw_mac", "arp.dst.proto_ipv4" ], + ["eth.dst", "eth.src", + "arp.src.hw_mac", "arp.src.proto_ipv4", + "arp.dst.hw_mac", "arp.dst.proto_ipv4"], wait=False) frames = [] for l in res.splitlines(): @@ -4587,10 +4597,10 @@ def tshark_get_arp(cap, filter): def tshark_get_ns(cap): res = run_tshark(cap, "icmpv6.type == 135", - [ "eth.dst", "eth.src", - "ipv6.src", "ipv6.dst", - "icmpv6.nd.ns.target_address", - "icmpv6.opt.linkaddr" ], + ["eth.dst", "eth.src", + "ipv6.src", "ipv6.dst", + "icmpv6.nd.ns.target_address", + "icmpv6.opt.linkaddr"], wait=False) frames = [] for l in res.splitlines(): @@ -4599,10 +4609,10 @@ def tshark_get_ns(cap): def tshark_get_na(cap): res = run_tshark(cap, "icmpv6.type == 136", - [ "eth.dst", "eth.src", - "ipv6.src", "ipv6.dst", - "icmpv6.nd.na.target_address", - "icmpv6.opt.linkaddr" ], + ["eth.dst", "eth.src", + "ipv6.src", "ipv6.dst", + "icmpv6.nd.na.target_address", + "icmpv6.opt.linkaddr"], wait=False) frames = [] for l in res.splitlines(): @@ -4622,7 +4632,7 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): prefix + ".%s.pcap" % dev[2].ifname) bssid = apdev[0]['bssid'] - params = { 'ssid': 'open' } + params = {'ssid': 'open'} params['proxy_arp'] = '1' hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd.set("ap_isolate", "1") @@ -4639,7 +4649,7 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): if "AP-ENABLED" not in ev: raise Exception("AP startup failed") - params2 = { 'ssid': 'another' } + params2 = {'ssid': 'another'} hapd2 = hostapd.add_ap(apdev[1], params2, no_enable=True) hapd2.set('bridge', 'ap-br0') hapd2.enable() @@ -4648,7 +4658,7 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) if ebtables: - for chain in [ 'FORWARD', 'OUTPUT' ]: + for chain in ['FORWARD', 'OUTPUT']: try: subprocess.call(['ebtables', '-A', chain, '-p', 'ARP', '-d', 'Broadcast', '-o', apdev[0]['ifname'], @@ -4768,8 +4778,8 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): if '192.168.1.123 dev ap-br0 lladdr 02:00:00:00:00:00 PERMANENT' not in matches: raise Exception("dev0 IPv4 addr missing") - targets = [ "192.168.1.123", "192.168.1.124", "192.168.1.125", - "192.168.1.126" ] + targets = ["192.168.1.123", "192.168.1.124", "192.168.1.125", + "192.168.1.126"] for target in targets: send_arp(dev[1], sender_ip="192.168.1.100", target_ip=target) @@ -4884,18 +4894,18 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): logger.info("dev0 seen ARP requests:\n" + str(arp_req)) logger.info("dev0 seen ARP replies:\n" + str(arp_reply)) - if [ 'ff:ff:ff:ff:ff:ff', addr1, - addr1, '192.168.1.100', - '00:00:00:00:00:00', '192.168.1.123' ] in arp_req: + if ['ff:ff:ff:ff:ff:ff', addr1, + addr1, '192.168.1.100', + '00:00:00:00:00:00', '192.168.1.123'] in arp_req: raise Exception("dev0 saw ARP request from dev1") - if [ 'ff:ff:ff:ff:ff:ff', addr2, - addr2, '192.168.1.103', - '00:00:00:00:00:00', '192.168.1.123' ] in arp_req: + if ['ff:ff:ff:ff:ff:ff', addr2, + addr2, '192.168.1.103', + '00:00:00:00:00:00', '192.168.1.123'] in arp_req: raise Exception("dev0 saw ARP request from dev2") # TODO: Uncomment once fixed in kernel - #if [ 'ff:ff:ff:ff:ff:ff', bssid, - # bssid, '192.168.1.101', - # '00:00:00:00:00:00', '192.168.1.123' ] in arp_req: + #if ['ff:ff:ff:ff:ff:ff', bssid, + # bssid, '192.168.1.101', + # '00:00:00:00:00:00', '192.168.1.123'] in arp_req: # raise Exception("dev0 saw ARP request from br") if ebtables: @@ -4908,9 +4918,9 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): logger.info("dev1 seen ARP requests:\n" + str(arp_req)) logger.info("dev1 seen ARP replies:\n" + str(arp_reply)) - if [ 'ff:ff:ff:ff:ff:ff', addr2, - addr2, '192.168.1.103', - '00:00:00:00:00:00', '192.168.1.123' ] in arp_req: + if ['ff:ff:ff:ff:ff:ff', addr2, + addr2, '192.168.1.103', + '00:00:00:00:00:00', '192.168.1.123'] in arp_req: raise Exception("dev1 saw ARP request from dev2") if [addr1, addr0, addr0, '192.168.1.123', addr1, '192.168.1.100'] not in arp_reply: raise Exception("dev1 did not get ARP response for 192.168.1.123") @@ -4925,9 +4935,9 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): logger.info("dev2 seen ARP requests:\n" + str(arp_req)) logger.info("dev2 seen ARP replies:\n" + str(arp_reply)) - if [ addr2, addr0, - addr0, '192.168.1.123', - addr2, '192.168.1.103' ] not in arp_reply: + if [addr2, addr0, + addr0, '192.168.1.123', + addr2, '192.168.1.103'] not in arp_reply: raise Exception("dev2 did not get ARP response for 192.168.1.123") arp_req = tshark_get_arp(cap_br, "arp.opcode == 1") @@ -4936,9 +4946,9 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): logger.info("br seen ARP replies:\n" + str(arp_reply)) # TODO: Uncomment once fixed in kernel - #if [ bssid, addr0, - # addr0, '192.168.1.123', - # bssid, '192.168.1.101' ] not in arp_reply: + #if [bssid, addr0, + # addr0, '192.168.1.123', + # bssid, '192.168.1.101'] not in arp_reply: # raise Exception("br did not get ARP response for 192.168.1.123") def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): @@ -4955,7 +4965,7 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): prefix + ".%s.pcap" % dev[2].ifname) bssid = apdev[0]['bssid'] - params = { 'ssid': 'open' } + params = {'ssid': 'open'} params['proxy_arp'] = '1' hapd = hostapd.add_ap(apdev[0], params, no_enable=True) hapd.set("ap_isolate", "1") @@ -4972,7 +4982,7 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): if "AP-ENABLED" not in ev: raise Exception("AP startup failed") - params2 = { 'ssid': 'another' } + params2 = {'ssid': 'another'} hapd2 = hostapd.add_ap(apdev[1], params2, no_enable=True) hapd2.set('bridge', 'ap-br0') hapd2.enable() @@ -4981,7 +4991,7 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) if ebtables: - for chain in [ 'FORWARD', 'OUTPUT' ]: + for chain in ['FORWARD', 'OUTPUT']: try: subprocess.call(['ebtables', '-A', chain, '-d', 'Multicast', '-p', 'IPv6', '--ip6-protocol', 'ipv6-icmp', @@ -5038,8 +5048,8 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): addr1 = dev[1].p2p_interface_addr() addr2 = dev[2].p2p_interface_addr() - src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':','')) - src_ll_opt1 = b"\x01\x01" + binascii.unhexlify(addr1.replace(':','')) + src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':', '')) + src_ll_opt1 = b"\x01\x01" + binascii.unhexlify(addr1.replace(':', '')) # DAD NS send_ns(dev[0], ip_src="::", target="aaaa:bbbb:cccc::2") @@ -5139,8 +5149,8 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): na = tshark_get_na(cap_dev0) logger.info("dev0 seen NA: " + str(na)) - if [ addr0, addr1, 'aaaa:bbbb:dddd::2', 'aaaa:bbbb:cccc::2', - 'aaaa:bbbb:dddd::2', addr1 ] not in na: + if [addr0, addr1, 'aaaa:bbbb:dddd::2', 'aaaa:bbbb:cccc::2', + 'aaaa:bbbb:dddd::2', addr1] not in na: # For now, skip the test instead of reporting the error since the IPv6 # proxyarp support is not yet in the upstream kernel tree. #raise Exception("dev0 did not get NA for aaaa:bbbb:dddd::2") @@ -5156,8 +5166,8 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): na = tshark_get_na(cap_dev1) logger.info("dev1 seen NA: " + str(na)) - if [ addr1, addr0, 'aaaa:bbbb:cccc::2', 'aaaa:bbbb:dddd::2', - 'aaaa:bbbb:cccc::2', addr0 ] not in na: + if [addr1, addr0, 'aaaa:bbbb:cccc::2', 'aaaa:bbbb:dddd::2', + 'aaaa:bbbb:cccc::2', addr0] not in na: raise Exception("dev1 did not get NA for aaaa:bbbb:cccc::2") if ebtables: @@ -5171,14 +5181,14 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): logger.info("dev2 seen NA: " + str(na)) # FIX: enable once kernel implementation for proxyarp IPv6 is fixed - #if [ addr2, addr0, 'aaaa:bbbb:cccc::2', 'aaaa:bbbb:ff00::2', - # 'aaaa:bbbb:cccc::2', addr0 ] not in na: + #if [addr2, addr0, 'aaaa:bbbb:cccc::2', 'aaaa:bbbb:ff00::2', + # 'aaaa:bbbb:cccc::2', addr0] not in na: # raise Exception("dev2 did not get NA for aaaa:bbbb:cccc::2") - #if [ addr2, addr1, 'aaaa:bbbb:dddd::2', 'aaaa:bbbb:ff00::2', - # 'aaaa:bbbb:dddd::2', addr1 ] not in na: + #if [addr2, addr1, 'aaaa:bbbb:dddd::2', 'aaaa:bbbb:ff00::2', + # 'aaaa:bbbb:dddd::2', addr1] not in na: # raise Exception("dev2 did not get NA for aaaa:bbbb:dddd::2") - #if [ addr2, addr1, 'aaaa:bbbb:eeee::2', 'aaaa:bbbb:ff00::2', - # 'aaaa:bbbb:eeee::2', addr1 ] not in na: + #if [addr2, addr1, 'aaaa:bbbb:eeee::2', 'aaaa:bbbb:ff00::2', + # 'aaaa:bbbb:eeee::2', addr1] not in na: # raise Exception("dev2 did not get NA for aaaa:bbbb:eeee::2") def test_proxyarp_open(dev, apdev, params): @@ -5242,11 +5252,11 @@ def test_proxyarp_errors(dev, apdev, params): stderr=open('/dev/null', 'w')) def run_proxyarp_errors(dev, apdev, params): - params = { 'ssid': 'open', - 'proxy_arp': '1', - 'ap_isolate': '1', - 'bridge': 'ap-br0', - 'disable_dgaf': '1' } + params = {'ssid': 'open', + 'proxy_arp': '1', + 'ap_isolate': '1', + 'bridge': 'ap-br0', + 'disable_dgaf': '1'} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) try: hapd.enable() @@ -5288,7 +5298,7 @@ def run_proxyarp_errors(dev, apdev, params): wait_fail_trigger(dev[0], "GET_FAIL") with alloc_fail(hapd, 1, "sta_ip6addr_add"): - src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':','')) + src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':', '')) pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2", ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2", opt=src_ll_opt0) @@ -5308,11 +5318,11 @@ def test_ap_hs20_connect_deinit(dev, apdev): wpas.interface_add("wlan5", drv_params="") wpas.hs20_enable() wpas.flush_scan_cache() - wpas.add_cred_values({ 'realm': "example.com", - 'username': "hs20-test", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem", - 'domain': "example.com" }) + wpas.add_cred_values({'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem", + 'domain': "example.com"}) wpas.scan_for_bss(bssid, freq=2412) hapd.disable() @@ -5339,26 +5349,26 @@ def test_ap_hs20_anqp_format_errors(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - values = { 'realm': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'username': "hs20-test", - 'password': "password", - 'domain': "example.com" } + values = {'realm': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"} id = dev[0].add_cred_values(values) dev[0].scan_for_bss(bssid, freq="2412") - tests = [ "00", "ffff", "010011223344", "020008000005112233445500", - "01000400000000", "01000000000000", - "01000300000200", "0100040000ff0000", "01000300000100", - "01000300000001", - "01000600000056112233", - "01000900000002050001000111", - "01000600000001000000", "01000600000001ff0000", - "01000600000001020001", - "010008000000010400010001", "0100080000000104000100ff", - "010011000000010d00050200020100030005000600", - "0000" ] + tests = ["00", "ffff", "010011223344", "020008000005112233445500", + "01000400000000", "01000000000000", + "01000300000200", "0100040000ff0000", "01000300000100", + "01000300000001", + "01000600000056112233", + "01000900000002050001000111", + "01000600000001000000", "01000600000001ff0000", + "01000600000001020001", + "010008000000010400010001", "0100080000000104000100ff", + "010011000000010d00050200020100030005000600", + "0000"] for t in tests: hapd.set("anqp_elem", "263:" + t) dev[0].request("INTERWORKING_SELECT freq=2412") @@ -5368,11 +5378,11 @@ def test_ap_hs20_anqp_format_errors(dev, apdev): dev[0].dump_monitor() dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'imsi': "555444-333222111", 'eap': "AKA", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) + id = dev[0].add_cred_values({'imsi': "555444-333222111", 'eap': "AKA", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) - tests = [ "00", "0100", "0001", "00ff", "000200ff", "0003000101", - "00020100" ] + tests = ["00", "0100", "0001", "00ff", "000200ff", "0003000101", + "00020100"] for t in tests: hapd.set("anqp_elem", "264:" + t) dev[0].request("INTERWORKING_SELECT freq=2412") @@ -5390,20 +5400,20 @@ def test_ap_hs20_cred_with_nai_realm(dev, apdev): dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "test", - 'password': "secret", - 'domain': "example.com", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "test", + 'password': "secret", + 'domain': "example.com", + 'eap': 'TTLS'}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'realm': "foo.com", - 'username': "test", - 'password': "secret", - 'domain': "example.com", - 'roaming_consortium': "112234", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "foo.com", + 'username': "test", + 'password': "secret", + 'domain': "example.com", + 'roaming_consortium': "112234", + 'eap': 'TTLS'}) interworking_select(dev[0], bssid, "home", freq=2412, no_match=True) dev[0].remove_cred(id) @@ -5417,12 +5427,12 @@ def test_ap_hs20_cred_and_no_roaming_consortium(dev, apdev): dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "test", - 'password': "secret", - 'domain': "example.com", - 'roaming_consortium': "112234", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "test", + 'password': "secret", + 'domain': "example.com", + 'roaming_consortium': "112234", + 'eap': 'TTLS'}) interworking_select(dev[0], bssid, "home", freq=2412, no_match=True) def test_ap_hs20_interworking_oom(dev, apdev): @@ -5430,28 +5440,28 @@ def test_ap_hs20_interworking_oom(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() params['hessid'] = bssid - params['nai_realm'] = [ "0,no.match.here;example.com;no.match.here.either,21[2:1][5:7]", - "0,example.com,13[5:6],21[2:4][5:7]", - "0,another.example.com" ] + params['nai_realm'] = ["0,no.match.here;example.com;no.match.here.either,21[2:1][5:7]", + "0,example.com,13[5:6],21[2:4][5:7]", + "0,another.example.com"] hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "test", - 'password': "secret", - 'domain': "example.com", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "test", + 'password': "secret", + 'domain': "example.com", + 'eap': 'TTLS'}) dev[0].scan_for_bss(bssid, freq="2412") - funcs = [ "wpabuf_alloc;interworking_anqp_send_req", - "anqp_build_req;interworking_anqp_send_req", - "gas_query_req;interworking_anqp_send_req", - "dup_binstr;nai_realm_parse_realm", - "=nai_realm_parse_realm", - "=nai_realm_parse", - "=nai_realm_match" ] + funcs = ["wpabuf_alloc;interworking_anqp_send_req", + "anqp_build_req;interworking_anqp_send_req", + "gas_query_req;interworking_anqp_send_req", + "dup_binstr;nai_realm_parse_realm", + "=nai_realm_parse_realm", + "=nai_realm_parse", + "=nai_realm_match"] for func in funcs: with alloc_fail(dev[0], 1, func): dev[0].request("INTERWORKING_SELECT auto freq=2412") @@ -5483,21 +5493,21 @@ def test_ap_hs20_no_rsn_connect(dev, apdev): params['auth_server_port'] = "1812" params['auth_server_shared_secret'] = "radius" params['interworking'] = "1" - params['roaming_consortium'] = [ "112233", "1020304050", "010203040506", - "fedcba" ] - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]", - "0,another.example.com" ] + params['roaming_consortium'] = ["112233", "1020304050", "010203040506", + "fedcba"] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]", + "0,another.example.com"] hapd = hostapd.add_ap(apdev[0], params) dev[0].hs20_enable() dev[0].scan_for_bss(bssid, freq="2412") - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "test", - 'password': "secret", - 'domain': "example.com", - 'roaming_consortium': "112233", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "test", + 'password': "secret", + 'domain': "example.com", + 'roaming_consortium': "112233", + 'eap': 'TTLS'}) interworking_select(dev[0], bssid, freq=2412, no_match=True) if "FAIL" not in dev[0].request("INTERWORKING_CONNECT " + bssid): @@ -5512,12 +5522,12 @@ def test_ap_hs20_no_match_connect(dev, apdev): dev[0].hs20_enable() dev[0].scan_for_bss(bssid, freq="2412") - id = dev[0].add_cred_values({ 'realm': "example.org", - 'username': "test", - 'password': "secret", - 'domain': "example.org", - 'roaming_consortium': "112234", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "example.org", + 'username': "test", + 'password': "secret", + 'domain': "example.org", + 'roaming_consortium': "112234", + 'eap': 'TTLS'}) interworking_select(dev[0], bssid, freq=2412, no_match=True) if "FAIL" not in dev[0].request("INTERWORKING_CONNECT " + bssid): @@ -5528,30 +5538,30 @@ def test_ap_hs20_multiple_home_cred(dev, apdev): bssid = apdev[0]['bssid'] params = hs20_ap_params() params['hessid'] = bssid - params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,example.com,13[5:6],21[2:4][5:7]"] params['domain_name'] = "example.com" hapd = hostapd.add_ap(apdev[0], params) bssid2 = apdev[1]['bssid'] params = hs20_ap_params(ssid="test-hs20-other") params['hessid'] = bssid2 - params['nai_realm'] = [ "0,example.org,13[5:6],21[2:4][5:7]" ] + params['nai_realm'] = ["0,example.org,13[5:6],21[2:4][5:7]"] params['domain_name'] = "example.org" hapd2 = hostapd.add_ap(apdev[1], params) dev[0].hs20_enable() dev[0].scan_for_bss(bssid2, freq="2412") dev[0].scan_for_bss(bssid, freq="2412") - id = dev[0].add_cred_values({ 'realm': "example.com", - 'priority': '2', + id = dev[0].add_cred_values({'realm': "example.com", + 'priority': '2', + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com"}) + id2 = dev[0].add_cred_values({'realm': "example.org", + 'priority': '3', 'username': "hs20-test", 'password': "password", - 'domain': "example.com" }) - id2 = dev[0].add_cred_values({ 'realm': "example.org", - 'priority': '3', - 'username': "hs20-test", - 'password': "password", - 'domain': "example.org" }) + 'domain': "example.org"}) dev[0].request("INTERWORKING_SELECT auto freq=2412") ev = dev[0].wait_connected(timeout=15) if bssid2 not in ev: @@ -5569,12 +5579,12 @@ def test_ap_hs20_anqp_invalid_gas_response(dev, apdev): dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "test", - 'password': "secret", - 'domain': "example.com", - 'roaming_consortium': "112234", - 'eap': 'TTLS' }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "test", + 'password': "secret", + 'domain': "example.com", + 'roaming_consortium': "112234", + 'eap': 'TTLS'}) dev[0].request("INTERWORKING_SELECT freq=2412") query = gas_rx(hapd) @@ -5656,11 +5666,11 @@ def test_ap_hs20_anqp_invalid_gas_response(dev, apdev): if "result=SUCCESS" not in ev: raise Exception("Unexpected result: " + ev) - tests = [ struct.pack('eap.eap_methods = os_malloc()") @@ -5704,10 +5714,10 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'realm': "example.com", - 'domain': "example.com", - 'username': "hs20-test-with-domain@example.com", - 'password': "password" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'domain': "example.com", + 'username': "hs20-test-with-domain@example.com", + 'password': "password"}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() dev[0].request("NOTE anon = os_malloc()") @@ -5720,10 +5730,10 @@ def test_ap_hs20_set_profile_failures(dev, apdev): dev[0].remove_cred(id) dev[0].wait_disconnected() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'domain': "example.com", - 'username': "hs20-test", - 'password': "password" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'domain': "example.com", + 'username': "hs20-test", + 'password': "password"}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() dev[0].request("NOTE anon = os_malloc() (second)") @@ -5746,12 +5756,12 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'roaming_consortium': "112233", - 'domain': "example.com", - 'username': "hs20-test", - 'password': "password", - 'eap': 'TTLS', - 'phase2': "auth=MSCHAPV2" }) + id = dev[0].add_cred_values({'roaming_consortium': "112233", + 'domain': "example.com", + 'username': "hs20-test", + 'password': "password", + 'eap': 'TTLS', + 'phase2': "auth=MSCHAPV2"}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() dev[0].request("NOTE anon = os_strdup()") @@ -5768,12 +5778,12 @@ def test_ap_hs20_set_profile_failures(dev, apdev): dev[0].remove_cred(id) dev[0].wait_disconnected() - id = dev[0].add_cred_values({ 'roaming_consortium': "112233", - 'domain': "example.com", - 'realm': "example.com", - 'username': "user", - 'password': "password", - 'eap': 'PEAP' }) + id = dev[0].add_cred_values({'roaming_consortium': "112233", + 'domain': "example.com", + 'realm': "example.com", + 'username': "user", + 'password': "password", + 'eap': 'PEAP'}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() dev[0].request("NOTE id = os_strdup()") @@ -5786,12 +5796,12 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'roaming_consortium': "112233", - 'domain': "example.com", - 'realm': "example.com", - 'username': "user", - 'password': "password", - 'eap': "TTLS" }) + id = dev[0].add_cred_values({'roaming_consortium': "112233", + 'domain': "example.com", + 'realm': "example.com", + 'username': "user", + 'password': "password", + 'eap': "TTLS"}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() dev[0].request("NOTE wpa_config_set_quoted(identity) (second)") @@ -5810,11 +5820,11 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'roaming_consortium': "112233", - 'domain': "example.com", - 'realm': "example.com", - 'username': "user", - 'eap': "PEAP" }) + id = dev[0].add_cred_values({'roaming_consortium': "112233", + 'domain': "example.com", + 'realm': "example.com", + 'username': "user", + 'eap': "PEAP"}) dev[0].set_cred(id, "password", "ext:password") interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() @@ -5827,15 +5837,15 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'realm': "example.com", - 'domain': "example.com", - 'username': "certificate-user", - 'phase1': "include_tls_length=0", - 'domain_suffix_match': "example.com", - 'ca_cert': "auth_serv/ca.pem", - 'client_cert': "auth_serv/user.pem", - 'private_key': "auth_serv/user.key", - 'private_key_passwd': "secret" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'domain': "example.com", + 'username': "certificate-user", + 'phase1': "include_tls_length=0", + 'domain_suffix_match': "example.com", + 'ca_cert': "auth_serv/ca.pem", + 'client_cert': "auth_serv/user.pem", + 'private_key': "auth_serv/user.key", + 'private_key_passwd': "secret"}) interworking_select(dev[0], bssid, "home", freq=2412) dev[0].dump_monitor() dev[0].request("NOTE wpa_config_set_quoted(client_cert)") @@ -5863,8 +5873,8 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'imsi': "555444-333222111", 'eap': "SIM", - 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) + id = dev[0].add_cred_values({'imsi': "555444-333222111", 'eap': "SIM", + 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"}) interworking_select(dev[0], bssid, freq=2412) dev[0].dump_monitor() with alloc_fail(dev[0], 1, "interworking_set_hs20_params"): @@ -5884,9 +5894,9 @@ def test_ap_hs20_set_profile_failures(dev, apdev): wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") dev[0].remove_cred(id) - id = dev[0].add_cred_values({ 'roaming_consortium': "112233", - 'username': "user@example.com", - 'password': "password" }) + id = dev[0].add_cred_values({'roaming_consortium': "112233", + 'username': "user@example.com", + 'password': "password"}) interworking_select(dev[0], bssid, freq=2412) dev[0].dump_monitor() dev[0].request("NOTE Interworking: No EAP method set for credential using roaming consortium") @@ -5897,10 +5907,10 @@ def test_ap_hs20_set_profile_failures(dev, apdev): params = hs20_ap_params() params['nai_realm'] = "0,example.com,25[3:26]" hapd = hostapd.add_ap(apdev[0], params) - id = dev[0].add_cred_values({ 'realm': "example.com", - 'domain': "example.com", - 'username': "hs20-test", - 'password': "password" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'domain': "example.com", + 'username': "hs20-test", + 'password': "password"}) interworking_select(dev[0], bssid, freq=2412) dev[0].dump_monitor() dev[0].request("NOTE wpa_config_set(PEAP/FAST-phase1)") @@ -6170,14 +6180,14 @@ def run_ap_hs20_terms_and_conditions_sql(dev, apdev, params, url_template, try: - params = { "ssid": "as", "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "sqlite:" + dbfile, - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key" } + params = {"ssid": "as", "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "sqlite:" + dbfile, + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key"} params['hs20_t_c_server_url'] = url_template authsrv = hostapd.add_ap(apdev[1], params) @@ -6195,10 +6205,10 @@ def run_ap_hs20_terms_and_conditions_sql(dev, apdev, params, url_template, dev[0].request("SET pmf 1") dev[0].hs20_enable() - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "user-mschapv2", - 'password': "password", - 'ca_cert': "auth_serv/ca.pem" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "user-mschapv2", + 'password': "password", + 'ca_cert': "auth_serv/ca.pem"}) interworking_select(dev[0], bssid, freq="2412") interworking_connect(dev[0], bssid, "TTLS") diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py index 1df9a9d..9c6f1e4 100644 --- a/tests/hwsim/test_ap_ht.py +++ b/tests/hwsim/test_ap_ht.py @@ -36,9 +36,9 @@ def set_world_reg(apdev0=None, apdev1=None, dev0=None): def test_ap_ht40_scan(dev, apdev): """HT40 co-ex scan""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -76,8 +76,8 @@ def test_ap_ht40_scan(dev, apdev): def test_ap_ht_wifi_generation(dev, apdev): """HT and wifi_generation""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht", - "channel": "6" } + params = {"ssid": "test-ht", + "channel": "6"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-ht", key_mgmt="NONE", scan_freq="2437") @@ -104,14 +104,14 @@ def test_ap_ht_wifi_generation(dev, apdev): def test_ap_ht40_scan_conflict(dev, apdev): """HT40 co-ex scan conflict""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "6", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "channel": "6", + "ht_capab": "[HT40+]"} hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -145,14 +145,14 @@ def test_ap_ht40_scan_conflict(dev, apdev): def test_ap_ht40_scan_conflict2(dev, apdev): """HT40 co-ex scan conflict (HT40-)""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "11", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "11", + "ht_capab": "[HT40-]"} hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "1", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "channel": "1", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -185,8 +185,8 @@ def test_ap_ht40_scan_conflict2(dev, apdev): def test_ap_ht40_scan_not_affected(dev, apdev): """HT40 co-ex scan and other BSS not affected""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht20", - "channel": "11" } + params = {"ssid": "test-ht20", + "channel": "11"} hostapd.add_ap(apdev[1], params) hostapd.cmd_execute(apdev[0], ['ifconfig', apdev[0]['ifname'], 'up']) @@ -197,9 +197,9 @@ def test_ap_ht40_scan_not_affected(dev, apdev): time.sleep(0.1) hostapd.cmd_execute(apdev[0], ['ifconfig', apdev[0]['ifname'], 'down']) - params = { "ssid": "test-ht40", - "channel": "1", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "channel": "1", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -233,13 +233,13 @@ def test_ap_ht40_scan_not_affected(dev, apdev): def test_ap_ht40_scan_legacy_conflict(dev, apdev): """HT40 co-ex scan conflict with legacy 20 MHz AP""" clear_scan_cache(apdev[0]) - params = { "ssid": "legacy-20", - "channel": "7", "ieee80211n": "0" } + params = {"ssid": "legacy-20", + "channel": "7", "ieee80211n": "0"} hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -273,13 +273,13 @@ def test_ap_ht40_scan_legacy_conflict(dev, apdev): def test_ap_ht40_scan_ht20_conflict(dev, apdev): """HT40 co-ex scan conflict with HT 20 MHz AP""" clear_scan_cache(apdev[0]) - params = { "ssid": "ht-20", - "channel": "7", "ieee80211n": "1" } + params = {"ssid": "ht-20", + "channel": "7", "ieee80211n": "1"} hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -312,14 +312,14 @@ def test_ap_ht40_scan_ht20_conflict(dev, apdev): def test_ap_ht40_scan_intolerant(dev, apdev): """HT40 co-ex scan finding an AP advertising 40 MHz intolerant""" clear_scan_cache(apdev[0]) - params = { "ssid": "another-bss", - "channel": "1", - "ht_capab": "[40-INTOLERANT]" } + params = {"ssid": "another-bss", + "channel": "1", + "ht_capab": "[40-INTOLERANT]"} hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "1", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "channel": "1", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -352,14 +352,14 @@ def test_ap_ht40_scan_intolerant(dev, apdev): def test_ap_ht40_scan_match(dev, apdev): """HT40 co-ex scan matching configuration""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -395,17 +395,17 @@ def test_ap_ht40_5ghz_match(dev, apdev): try: hapd = None hapd2 = None - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "36", - "country_code": "US", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "36", + "country_code": "US", + "ht_capab": "[HT40+]"} hapd2 = hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -449,17 +449,17 @@ def test_ap_ht40_5ghz_switch(dev, apdev): try: hapd = None hapd2 = None - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "36", - "country_code": "US", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "36", + "country_code": "US", + "ht_capab": "[HT40+]"} hapd2 = hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "40", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "40", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -502,11 +502,11 @@ def test_ap_ht40_5ghz_switch2(dev, apdev): try: hapd = None hapd2 = None - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "36", - "country_code": "US", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "36", + "country_code": "US", + "ht_capab": "[HT40+]"} hapd2 = hostapd.add_ap(apdev[1], params) id = dev[0].add_network() @@ -518,10 +518,10 @@ def test_ap_ht40_5ghz_switch2(dev, apdev): dev[0].select_network(id) time.sleep(1) - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "40", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "40", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -561,29 +561,29 @@ def test_ap_ht40_5ghz_switch2(dev, apdev): def test_obss_scan(dev, apdev): """Overlapping BSS scan request""" - params = { "ssid": "obss-scan", - "channel": "6", - "ht_capab": "[HT40-]", - "obss_interval": "10" } + params = {"ssid": "obss-scan", + "channel": "6", + "ht_capab": "[HT40-]", + "obss_interval": "10"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "another-bss", - "channel": "9", - "ieee80211n": "0" } + params = {"ssid": "another-bss", + "channel": "9", + "ieee80211n": "0"} hostapd.add_ap(apdev[1], params) run_obss_scan(hapd, dev) def test_obss_scan_ht40_plus(dev, apdev): """Overlapping BSS scan request (HT40+)""" - params = { "ssid": "obss-scan", - "channel": "6", - "ht_capab": "[HT40+]", - "obss_interval": "10" } + params = {"ssid": "obss-scan", + "channel": "6", + "ht_capab": "[HT40+]", + "obss_interval": "10"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "another-bss", - "channel": "9", - "ieee80211n": "0" } + params = {"ssid": "another-bss", + "channel": "9", + "ieee80211n": "0"} hostapd.add_ap(apdev[1], params) run_obss_scan(hapd, dev) @@ -621,15 +621,15 @@ def run_obss_scan(hapd, dev): def test_obss_scan_40_intolerant(dev, apdev): """Overlapping BSS scan request with 40 MHz intolerant AP""" - params = { "ssid": "obss-scan", - "channel": "6", - "ht_capab": "[HT40-]", - "obss_interval": "10" } + params = {"ssid": "obss-scan", + "channel": "6", + "ht_capab": "[HT40-]", + "obss_interval": "10"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "another-bss", - "channel": "7", - "ht_capab": "[40-INTOLERANT]" } + params = {"ssid": "another-bss", + "channel": "7", + "ht_capab": "[40-INTOLERANT]"} hostapd.add_ap(apdev[1], params) dev[0].connect("obss-scan", key_mgmt="NONE", scan_freq="2437") @@ -666,9 +666,9 @@ def test_obss_scan_40_intolerant(dev, apdev): def test_obss_coex_report_handling(dev, apdev): """Overlapping BSS scan report handling with obss_interval=0""" clear_scan_cache(apdev[0]) - params = { "ssid": "obss-scan", - "channel": "6", - "ht_capab": "[HT40-]" } + params = {"ssid": "obss-scan", + "channel": "6", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] dev[0].connect("obss-scan", key_mgmt="NONE", scan_freq="2437") @@ -679,10 +679,10 @@ def test_obss_coex_report_handling(dev, apdev): # 20/40 MHz co-ex report tests: number of invalid reports and a valid report # that forces 20 MHz channel. - tests = [ '0400', '040048', '04004801', '0400480000', '0400490100', - '040048ff0000', '04004801ff49ff00', '04004801004900', - '0400480100490101', '0400480100490201ff', - '040048010449020005' ] + tests = ['0400', '040048', '04004801', '0400480000', '0400490100', + '040048ff0000', '04004801ff49ff00', '04004801004900', + '0400480100490101', '0400480100490201ff', + '040048010449020005'] for msg in tests: req = "MGMT_TX {} {} freq=2437 action={}".format(bssid, bssid, msg) if "OK" not in dev[0].request(req): @@ -695,10 +695,10 @@ def test_obss_coex_report_handling(dev, apdev): def test_obss_coex_report_handling1(dev, apdev): """Overlapping BSS scan report handling with obss_interval=1""" clear_scan_cache(apdev[0]) - params = { "ssid": "obss-scan", - "channel": "6", - "ht_capab": "[HT40+]", - "obss_interval": "1" } + params = {"ssid": "obss-scan", + "channel": "6", + "ht_capab": "[HT40+]", + "obss_interval": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] dev[0].connect("obss-scan", key_mgmt="NONE", scan_freq="2437") @@ -729,10 +729,10 @@ def test_obss_coex_report_handling1(dev, apdev): def test_obss_coex_report_handling2(dev, apdev): """Overlapping BSS scan report handling with obss_interval=1 and no overlap""" clear_scan_cache(apdev[0]) - params = { "ssid": "obss-scan", - "channel": "6", - "ht_capab": "[HT40+]", - "obss_interval": "1" } + params = {"ssid": "obss-scan", + "channel": "6", + "ht_capab": "[HT40+]", + "obss_interval": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] dev[0].connect("obss-scan", key_mgmt="NONE", scan_freq="2437") @@ -765,19 +765,19 @@ def test_obss_coex_report_handling2(dev, apdev): def test_olbc(dev, apdev): """OLBC detection""" - params = { "ssid": "test-olbc", - "channel": "6", - "ht_capab": "[HT40-]", - "ap_table_expiration_time": "2" } + params = {"ssid": "test-olbc", + "channel": "6", + "ht_capab": "[HT40-]", + "ap_table_expiration_time": "2"} hapd = hostapd.add_ap(apdev[0], params) status = hapd.get_status() if status['olbc'] != '0' or status['olbc_ht'] != '0': raise Exception("Unexpected OLBC information") - params = { "ssid": "olbc-ap", - "hw_mode": "b", - "channel": "6", - "wmm_enabled": "0" } + params = {"ssid": "olbc-ap", + "hw_mode": "b", + "channel": "6", + "wmm_enabled": "0"} hostapd.add_ap(apdev[1], params) time.sleep(0.5) status = hapd.get_status() @@ -806,9 +806,9 @@ def test_olbc_table_limit(dev, apdev): hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf') hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf') - params = { "ssid": "test-olbc", - "channel": "1", - "ap_table_max_size": "2" } + params = {"ssid": "test-olbc", + "channel": "1", + "ap_table_max_size": "2"} hapd = hostapd.add_ap(apdev[1], params) time.sleep(0.3) @@ -824,22 +824,22 @@ def test_olbc_5ghz(dev, apdev): try: hapd = None hapd2 = None - params = { "ssid": "test-olbc", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]" } + params = {"ssid": "test-olbc", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params) status = hapd.get_status() if status['olbc'] != '0' or status['olbc_ht'] != '0': raise Exception("Unexpected OLBC information") - params = { "ssid": "olbc-ap", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ieee80211n": "0", - "wmm_enabled": "0" } + params = {"ssid": "olbc-ap", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ieee80211n": "0", + "wmm_enabled": "0"} hapd2 = hostapd.add_ap(apdev[1], params) found = False for i in range(20): @@ -860,8 +860,8 @@ def test_olbc_5ghz(dev, apdev): def test_ap_require_ht(dev, apdev): """Require HT""" - params = { "ssid": "require-ht", - "require_ht": "1" } + params = {"ssid": "require-ht", + "require_ht": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[1].connect("require-ht", key_mgmt="NONE", scan_freq="2412", @@ -881,7 +881,7 @@ def test_ap_require_ht(dev, apdev): def test_ap_ht_stbc(dev, apdev): """HT STBC overrides""" - params = { "ssid": "ht" } + params = {"ssid": "ht"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("ht", key_mgmt="NONE", scan_freq="2412") @@ -893,9 +893,9 @@ def test_ap_ht_stbc(dev, apdev): @remote_compatible def test_ap_require_ht_limited_rates(dev, apdev): """Require HT with limited supported rates""" - params = { "ssid": "require-ht", - "supported_rates": "60 120 240 360 480 540", - "require_ht": "1" } + params = {"ssid": "require-ht", + "supported_rates": "60 120 240 360 480 540", + "require_ht": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[1].connect("require-ht", key_mgmt="NONE", scan_freq="2412", @@ -911,9 +911,9 @@ def test_ap_require_ht_limited_rates(dev, apdev): @remote_compatible def test_ap_ht_capab_not_supported(dev, apdev): """HT configuration with driver not supporting all ht_capab entries""" - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-][LDPC][SMPS-STATIC][SMPS-DYNAMIC][GF][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][RX-STBC12][RX-STBC123][DELAYED-BA][MAX-AMSDU-7935][DSSS_CCK-40][LSIG-TXOP-PROT]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-][LDPC][SMPS-STATIC][SMPS-DYNAMIC][GF][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][RX-STBC12][RX-STBC123][DELAYED-BA][MAX-AMSDU-7935][DSSS_CCK-40][LSIG-TXOP-PROT]"} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("Unexpected ENABLE success") @@ -921,9 +921,9 @@ def test_ap_ht_capab_not_supported(dev, apdev): def test_ap_ht_40mhz_intolerant_sta(dev, apdev): """Associated STA indicating 40 MHz intolerant""" clear_scan_cache(apdev[0]) - params = { "ssid": "intolerant", - "channel": "6", - "ht_capab": "[HT40-]" } + params = {"ssid": "intolerant", + "channel": "6", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params) if hapd.get_status_field("num_sta_ht40_intolerant") != "0": raise Exception("Unexpected num_sta_ht40_intolerant value") @@ -954,10 +954,10 @@ def test_ap_ht_40mhz_intolerant_sta(dev, apdev): def test_ap_ht_40mhz_intolerant_sta_deinit(dev, apdev): """Associated STA indicating 40 MHz intolerant and hostapd deinit""" clear_scan_cache(apdev[0]) - params = { "ssid": "intolerant", - "channel": "6", - "ht_capab": "[HT40-]", - "obss_interval": "0" } + params = {"ssid": "intolerant", + "channel": "6", + "ht_capab": "[HT40-]", + "obss_interval": "0"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("intolerant", key_mgmt="NONE", scan_freq="2437", @@ -973,10 +973,10 @@ def test_ap_ht_40mhz_intolerant_sta_deinit(dev, apdev): def test_ap_ht_40mhz_intolerant_ap(dev, apdev): """Associated STA reports 40 MHz intolerant AP after association""" clear_scan_cache(apdev[0]) - params = { "ssid": "ht", - "channel": "6", - "ht_capab": "[HT40-]", - "obss_interval": "3" } + params = {"ssid": "ht", + "channel": "6", + "ht_capab": "[HT40-]", + "obss_interval": "3"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("ht", key_mgmt="NONE", scan_freq="2437") @@ -985,9 +985,9 @@ def test_ap_ht_40mhz_intolerant_ap(dev, apdev): raise Exception("Unexpected secondary channel information") logger.info("Start 40 MHz intolerant AP") - params = { "ssid": "intolerant", - "channel": "5", - "ht_capab": "[40-INTOLERANT]" } + params = {"ssid": "intolerant", + "channel": "5", + "ht_capab": "[40-INTOLERANT]"} hapd2 = hostapd.add_ap(apdev[1], params) logger.info("Waiting for co-ex report from STA") @@ -1025,12 +1025,12 @@ def test_ap_ht40_csa(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "ht", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1" } + params = {"ssid": "ht", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("ht", key_mgmt="NONE", scan_freq="5180") @@ -1069,12 +1069,12 @@ def test_ap_ht40_csa2(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "ht", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1" } + params = {"ssid": "ht", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("ht", key_mgmt="NONE", scan_freq="5180") @@ -1113,12 +1113,12 @@ def test_ap_ht40_csa3(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "ht", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1" } + params = {"ssid": "ht", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("ht", key_mgmt="NONE", scan_freq="5180") @@ -1155,12 +1155,12 @@ def test_ap_ht40_csa3(dev, apdev): @remote_compatible def test_ap_ht_smps(dev, apdev): """SMPS AP configuration options""" - params = { "ssid": "ht1", "ht_capab": "[SMPS-STATIC]" } + params = {"ssid": "ht1", "ht_capab": "[SMPS-STATIC]"} try: hapd = hostapd.add_ap(apdev[0], params) except: raise HwsimSkip("Assume mac80211_hwsim was not recent enough to support SMPS") - params = { "ssid": "ht2", "ht_capab": "[SMPS-DYNAMIC]" } + params = {"ssid": "ht2", "ht_capab": "[SMPS-DYNAMIC]"} hapd2 = hostapd.add_ap(apdev[1], params) dev[0].connect("ht1", key_mgmt="NONE", scan_freq="2412") @@ -1171,14 +1171,14 @@ def test_ap_ht_smps(dev, apdev): @remote_compatible def test_prefer_ht20(dev, apdev): """Preference on HT20 over no-HT""" - params = { "ssid": "test", - "channel": "1", - "ieee80211n": "0" } + params = {"ssid": "test", + "channel": "1", + "ieee80211n": "0"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "test", - "channel": "1", - "ieee80211n": "1" } + params = {"ssid": "test", + "channel": "1", + "ieee80211n": "1"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -1198,15 +1198,15 @@ def test_prefer_ht20(dev, apdev): def test_prefer_ht40(dev, apdev): """Preference on HT40 over HT20""" - params = { "ssid": "test", - "channel": "1", - "ieee80211n": "1" } + params = {"ssid": "test", + "channel": "1", + "ieee80211n": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "test", - "channel": "1", - "ieee80211n": "1", - "ht_capab": "[HT40+]" } + params = {"ssid": "test", + "channel": "1", + "ieee80211n": "1", + "ht_capab": "[HT40+]"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -1227,18 +1227,18 @@ def test_prefer_ht40(dev, apdev): @remote_compatible def test_prefer_ht20_during_roam(dev, apdev): """Preference on HT20 over no-HT in roaming consideration""" - params = { "ssid": "test", - "channel": "1", - "ieee80211n": "0" } + params = {"ssid": "test", + "channel": "1", + "ieee80211n": "0"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] dev[0].scan_for_bss(bssid, freq=2412) dev[0].connect("test", key_mgmt="NONE", scan_freq="2412") - params = { "ssid": "test", - "channel": "1", - "ieee80211n": "1" } + params = {"ssid": "test", + "channel": "1", + "ieee80211n": "1"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] dev[0].scan_for_bss(bssid2, freq=2412) @@ -1253,11 +1253,11 @@ def test_ap_ht40_5ghz_invalid_pair(dev, apdev): """HT40 on 5 GHz with invalid channel pair""" clear_scan_cache(apdev[0]) try: - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "40", - "country_code": "US", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "40", + "country_code": "US", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = hapd.wait_event(["AP-DISABLED", "AP-ENABLED"], timeout=10) if not ev: @@ -1274,11 +1274,11 @@ def test_ap_ht40_5ghz_disabled_sec(dev, apdev): """HT40 on 5 GHz with disabled secondary channel""" clear_scan_cache(apdev[0]) try: - params = { "ssid": "test-ht40", - "hw_mode": "a", - "channel": "48", - "country_code": "US", - "ht_capab": "[HT40+]"} + params = {"ssid": "test-ht40", + "hw_mode": "a", + "channel": "48", + "country_code": "US", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = hapd.wait_event(["AP-DISABLED", "AP-ENABLED"], timeout=10) if not ev: @@ -1295,15 +1295,15 @@ def test_ap_ht40_scan_broken_ap(dev, apdev): clear_scan_cache(apdev[0]) # Broken AP: Include HT Capabilities element but not HT Operation element - params = { "ssid": "legacy-20", - "channel": "7", "ieee80211n": "0", - "wmm_enabled": "1", - "vendor_elements": "2d1a0e001bffff000000000000000000000100000000000000000000" } + params = {"ssid": "legacy-20", + "channel": "7", "ieee80211n": "0", + "wmm_enabled": "1", + "vendor_elements": "2d1a0e001bffff000000000000000000000100000000000000000000"} hapd2 = hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-ht40", - "channel": "5", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "5", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) state = hapd.get_status_field("state") @@ -1340,10 +1340,10 @@ def run_op_class(dev, apdev, hw_mode, channel, country, ht_capab, sec_chan, freq, opclass): clear_scan_cache(apdev[0]) try: - params = { "ssid": "test-ht40", - "hw_mode": hw_mode, - "channel": channel, - "ht_capab": ht_capab } + params = {"ssid": "test-ht40", + "hw_mode": hw_mode, + "channel": channel, + "ht_capab": ht_capab} if country: params['country_code'] = country hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) @@ -1439,9 +1439,9 @@ def test_ap_ht_op_class_127(dev, apdev): def test_ap_ht40_plus_minus1(dev, apdev): """HT40 with both plus and minus allowed (1)""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "11", - "ht_capab": "[HT40+][HT40-]"} + params = {"ssid": "test-ht40", + "channel": "11", + "ht_capab": "[HT40+][HT40-]"} hapd = hostapd.add_ap(apdev[0], params) freq = hapd.get_status_field("freq") @@ -1459,9 +1459,9 @@ def test_ap_ht40_plus_minus1(dev, apdev): def test_ap_ht40_plus_minus2(dev, apdev): """HT40 with both plus and minus allowed (2)""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "1", - "ht_capab": "[HT40+][HT40-]"} + params = {"ssid": "test-ht40", + "channel": "1", + "ht_capab": "[HT40+][HT40-]"} hapd = hostapd.add_ap(apdev[0], params) freq = hapd.get_status_field("freq") @@ -1479,9 +1479,9 @@ def test_ap_ht40_plus_minus2(dev, apdev): def test_ap_ht40_disable(dev, apdev): """HT40 disabling""" clear_scan_cache(apdev[0]) - params = { "ssid": "test-ht40", - "channel": "6", - "ht_capab": "[HT40-]"} + params = {"ssid": "test-ht40", + "channel": "6", + "ht_capab": "[HT40-]"} hapd = hostapd.add_ap(apdev[0], params) sec = hapd.get_status_field("secondary_channel") diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py index cca0cb7..4cdb33a 100644 --- a/tests/hwsim/test_ap_open.py +++ b/tests/hwsim/test_ap_open.py @@ -25,26 +25,26 @@ def test_ap_open(dev, apdev): _test_ap_open(dev, apdev) def _test_ap_open(dev, apdev): - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", bg_scan_period="0") - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") hwsim_utils.test_connectivity(dev[0], hapd) dev[0].request("DISCONNECT") - ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5) if ev is None: raise Exception("No disconnection event received from hostapd") def test_ap_open_packet_loss(dev, apdev): """AP with open mode configuration and large packet loss""" - params = { "ssid": "open", - "ignore_probe_probability": "0.5", - "ignore_auth_probability": "0.5", - "ignore_assoc_probability": "0.5", - "ignore_reassoc_probability": "0.5" } + params = {"ssid": "open", + "ignore_probe_probability": "0.5", + "ignore_auth_probability": "0.5", + "ignore_assoc_probability": "0.5", + "ignore_reassoc_probability": "0.5"} hapd = hostapd.add_ap(apdev[0], params) for i in range(0, 3): dev[i].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -55,7 +55,7 @@ def test_ap_open_packet_loss(dev, apdev): @remote_compatible def test_ap_open_unknown_action(dev, apdev): """AP with open mode configuration and unknown Action frame""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") bssid = apdev[0]['bssid'] cmd = "MGMT_TX {} {} freq=2412 action=765432".format(bssid, bssid) @@ -69,7 +69,7 @@ def test_ap_open_unknown_action(dev, apdev): def test_ap_open_invalid_wmm_action(dev, apdev): """AP with open mode configuration and invalid WMM Action frame""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") bssid = apdev[0]['bssid'] cmd = "MGMT_TX {} {} freq=2412 action=1100".format(bssid, bssid) @@ -82,7 +82,7 @@ def test_ap_open_invalid_wmm_action(dev, apdev): @remote_compatible def test_ap_open_reconnect_on_inactivity_disconnect(dev, apdev): """Reconnect to open mode AP after inactivity related disconnection""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") hapd.request("DEAUTHENTICATE " + dev[0].p2p_interface_addr() + " reason=4") dev[0].wait_disconnected(timeout=5) @@ -92,7 +92,7 @@ def test_ap_open_reconnect_on_inactivity_disconnect(dev, apdev): def test_ap_open_assoc_timeout(dev, apdev): """AP timing out association""" ssid = "test" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].scan(freq="2412") hapd.set("ext_mgmt_frame_handling", "1") dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -131,7 +131,7 @@ def test_ap_open_assoc_timeout(dev, apdev): def test_ap_open_auth_drop_sta(dev, apdev): """AP dropping station after successful authentication""" - hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0]['ifname'], {"ssid": "open"}) dev[0].scan(freq="2412") hapd.set("ext_mgmt_frame_handling", "1") dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -162,7 +162,7 @@ def test_ap_open_auth_drop_sta(dev, apdev): @remote_compatible def test_ap_open_id_str(dev, apdev): """AP with open mode and id_str""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", id_str="foo", wait_connect=False) ev = dev[0].wait_connected(timeout=10) @@ -174,7 +174,7 @@ def test_ap_open_id_str(dev, apdev): @remote_compatible def test_ap_open_select_any(dev, apdev): """AP with open mode and select any network""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) id = dev[0].connect("unknown", key_mgmt="NONE", scan_freq="2412", only_add_network=True) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -193,7 +193,7 @@ def test_ap_open_select_any(dev, apdev): @remote_compatible def test_ap_open_unexpected_assoc_event(dev, apdev): """AP with open mode and unexpected association event""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") dev[0].request("DISCONNECT") dev[0].wait_disconnected(timeout=15) @@ -214,7 +214,7 @@ def test_ap_open_unexpected_assoc_event(dev, apdev): def test_ap_open_external_assoc(dev, apdev): """AP with open mode and external association""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open-ext-assoc" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open-ext-assoc"}) try: dev[0].request("STA_AUTOCONNECT 0") id = dev[0].connect("open-ext-assoc", key_mgmt="NONE", scan_freq="2412", @@ -224,8 +224,8 @@ def test_ap_open_external_assoc(dev, apdev): # This will be accepted due to matching network dev[0].cmd_execute(['iw', 'dev', dev[0].ifname, 'connect', 'open-ext-assoc', "2412", apdev[0]['bssid']]) - ev = dev[0].wait_event([ "CTRL-EVENT-DISCONNECTED", - "CTRL-EVENT-CONNECTED" ], timeout=10) + ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED", + "CTRL-EVENT-CONNECTED"], timeout=10) if ev is None: raise Exception("Connection timed out") if "CTRL-EVENT-DISCONNECTED" in ev: @@ -240,9 +240,9 @@ def test_ap_open_external_assoc(dev, apdev): def test_ap_bss_load(dev, apdev): """AP with open mode (no security) configuration""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "open", - "bss_load_update_period": "10", - "chan_util_avg_period": "20" }) + {"ssid": "open", + "bss_load_update_period": "10", + "chan_util_avg_period": "20"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") # this does not really get much useful output with mac80211_hwsim currently, # but run through the channel survey update couple of times @@ -258,8 +258,8 @@ def test_ap_bss_load(dev, apdev): def test_ap_bss_load_fail(dev, apdev): """BSS Load update failing to get survey data""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "open", - "bss_load_update_period": "1" }) + {"ssid": "open", + "bss_load_update_period": "1"}) with fail_test(hapd, 1, "wpa_driver_nl80211_get_survey"): wait_fail_trigger(hapd, "GET_FAIL") @@ -267,7 +267,7 @@ def hapd_out_of_mem(hapd, apdev, count, func): with alloc_fail(hapd, count, func): started = False try: - hostapd.add_ap(apdev, { "ssid": "open" }) + hostapd.add_ap(apdev, {"ssid": "open"}) started = True except: pass @@ -276,7 +276,7 @@ def hapd_out_of_mem(hapd, apdev, count, func): def test_ap_open_out_of_memory(dev, apdev): """hostapd failing to setup interface due to allocation failure""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_alloc_bss_data") for i in range(1, 3): @@ -297,12 +297,12 @@ def test_ap_open_out_of_memory(dev, apdev): # verify that a new interface can still be added when memory allocation does # not fail - hostapd.add_ap(apdev[1], { "ssid": "open" }) + hostapd.add_ap(apdev[1], {"ssid": "open"}) def test_bssid_black_white_list(dev, apdev): """BSSID black/white list""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", bssid_whitelist=apdev[1]['bssid']) @@ -340,8 +340,8 @@ def test_bssid_black_white_list(dev, apdev): def test_ap_open_wpas_in_bridge(dev, apdev): """Open mode AP and wpas interface in a bridge""" - br_ifname='sta-br0' - ifname='wlan5' + br_ifname = 'sta-br0' + ifname = 'wlan5' try: _test_ap_open_wpas_in_bridge(dev, apdev) finally: @@ -351,10 +351,10 @@ def test_ap_open_wpas_in_bridge(dev, apdev): subprocess.call(['iw', ifname, 'set', '4addr', 'off']) def _test_ap_open_wpas_in_bridge(dev, apdev): - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) - br_ifname='sta-br0' - ifname='wlan5' + br_ifname = 'sta-br0' + ifname = 'wlan5' wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') # First, try a failure case of adding an interface try: @@ -379,8 +379,8 @@ def _test_ap_open_wpas_in_bridge(dev, apdev): @remote_compatible def test_ap_open_start_disabled(dev, apdev): """AP with open mode and beaconing disabled""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open", - "start_disabled": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open", + "start_disabled": "1"}) bssid = apdev[0]['bssid'] dev[0].flush_scan_cache() @@ -395,8 +395,8 @@ def test_ap_open_start_disabled(dev, apdev): @remote_compatible def test_ap_open_start_disabled2(dev, apdev): """AP with open mode and beaconing disabled (2)""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open", - "start_disabled": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open", + "start_disabled": "1"}) bssid = apdev[0]['bssid'] dev[0].flush_scan_cache() @@ -417,8 +417,8 @@ def test_ap_open_start_disabled2(dev, apdev): @remote_compatible def test_ap_open_ifdown(dev, apdev): """AP with open mode and external ifconfig down""" - params = { "ssid": "open", - "ap_max_inactivity": "1" } + params = {"ssid": "open", + "ap_max_inactivity": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] @@ -448,10 +448,10 @@ def test_ap_open_ifdown(dev, apdev): def test_ap_open_disconnect_in_ps(dev, apdev, params): """Disconnect with the client in PS to regression-test a kernel bug""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", bg_scan_period="0") - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") @@ -493,9 +493,9 @@ def test_ap_open_disconnect_in_ps(dev, apdev, params): @remote_compatible def test_ap_open_select_network(dev, apdev): """Open mode connection and SELECT_NETWORK to change network""" - hapd1 = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd1 = hostapd.add_ap(apdev[0], {"ssid": "open"}) bssid1 = apdev[0]['bssid'] - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open2" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "open2"}) bssid2 = apdev[1]['bssid'] id1 = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -520,7 +520,7 @@ def test_ap_open_select_network(dev, apdev): @remote_compatible def test_ap_open_disable_enable(dev, apdev): """AP with open mode getting disabled and re-enabled""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", bg_scan_period="0") @@ -560,7 +560,7 @@ def sta_enable_disable(dev, bssid): def test_ap_open_sta_enable_disable(dev, apdev): """AP with open mode and wpa_supplicant ENABLE/DISABLE_NETWORK""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) bssid = apdev[0]['bssid'] sta_enable_disable(dev[0], bssid) @@ -578,7 +578,7 @@ def test_ap_open_select_twice(dev, apdev): ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10) if ev is None: raise Exception("No result reported") - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) # Verify that the second SELECT_NETWORK starts a new scan immediately by # waiting less than the default scan period. dev[0].select_network(id) @@ -607,7 +607,7 @@ def test_ap_open_reassoc_not_found(dev, apdev): @remote_compatible def test_ap_open_sta_statistics(dev, apdev): """AP with open mode and STA statistics""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -627,7 +627,7 @@ def test_ap_open_sta_statistics(dev, apdev): @remote_compatible def test_ap_open_poll_sta(dev, apdev): """AP with open mode and STA poll""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -641,7 +641,7 @@ def test_ap_open_poll_sta(dev, apdev): def test_ap_open_pmf_default(dev, apdev): """AP with open mode (no security) configuration and pmf=2""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[1].connect("open", key_mgmt="NONE", scan_freq="2412", ieee80211w="2", wait_connect=False) dev[2].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -664,7 +664,7 @@ def test_ap_open_pmf_default(dev, apdev): def test_ap_open_drv_fail(dev, apdev): """AP with open mode and driver operations failing""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) with fail_test(dev[0], 1, "wpa_driver_nl80211_authenticate"): dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", @@ -679,17 +679,17 @@ def test_ap_open_drv_fail(dev, apdev): dev[0].request("REMOVE_NETWORK all") def run_multicast_to_unicast(dev, apdev, convert): - params = { "ssid": "open" } + params = {"ssid": "open"} params["multicast_to_unicast"] = "1" if convert else "0" hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(hapd.own_addr(), freq=2412) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") hwsim_utils.test_connectivity(dev[0], hapd, multicast_to_unicast=convert) dev[0].request("DISCONNECT") - ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5) if ev is None: raise Exception("No disconnection event received from hostapd") @@ -703,8 +703,8 @@ def test_ap_open_multicast_to_unicast_disabled(dev, apdev): def test_ap_open_drop_duplicate(dev, apdev, params): """AP dropping duplicate management frames""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open", - "interworking": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open", + "interworking": "1"}) hapd.set("ext_mgmt_frame_handling", "1") bssid = hapd.own_addr().replace(':', '') addr = "020304050607" @@ -763,7 +763,7 @@ def test_ap_open_drop_duplicate(dev, apdev, params): def test_ap_open_select_network_freq(dev, apdev): """AP with open mode and use for SELECT_NETWORK freq parameter""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) id = dev[0].connect("open", key_mgmt="NONE", only_add_network=True) dev[0].select_network(id, freq=2412) start = os.times()[4] @@ -803,10 +803,10 @@ def _test_ap_open_country(dev, apdev, country_code, country3): clear_regdom(hapd, dev) def run_ap_open_country(dev, apdev, country_code, country3): - hapd = hostapd.add_ap(apdev[0], { "ssid": "open", - "country_code": country_code, - "country3": country3, - "ieee80211d": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open", + "country_code": country_code, + "country3": country3, + "ieee80211d": "1"}) dev[0].scan_for_bss(hapd.own_addr(), freq=2412) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") dev[0].wait_regdom(country_ie=True) @@ -814,8 +814,8 @@ def run_ap_open_country(dev, apdev, country_code, country3): def test_ap_open_disable_select(dev, apdev): """DISABLE_NETWORK for connected AP followed by SELECT_NETWORK""" - hapd1 = hostapd.add_ap(apdev[0], { "ssid": "open" }) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" }) + hapd1 = hostapd.add_ap(apdev[0], {"ssid": "open"}) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "open"}) id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") dev[0].request("DISABLE_NETWORK %d" % id) @@ -828,7 +828,7 @@ def test_ap_open_disable_select(dev, apdev): def test_ap_open_reassoc_same(dev, apdev): """AP with open mode and STA reassociating back to same AP without auth exchange""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") try: dev[0].request("SET reassoc_same_bss_optim 1") @@ -840,10 +840,10 @@ def test_ap_open_reassoc_same(dev, apdev): def test_ap_open_no_reflection(dev, apdev): """AP with open mode, STA sending packets to itself""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") # test normal connectivity is OK @@ -867,8 +867,8 @@ def test_ap_open_no_reflection(dev, apdev): def test_ap_no_auth_ack(dev, apdev): """AP not receiving Authentication frame ACK""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open", - "ap_max_inactivity": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open", + "ap_max_inactivity": "1"}) hapd.set("ext_mgmt_frame_handling", "1") bssid = hapd.own_addr() addr = "02:01:02:03:04:05" diff --git a/tests/hwsim/test_ap_params.py b/tests/hwsim/test_ap_params.py index 72e05b9..8a183c4 100644 --- a/tests/hwsim/test_ap_params.py +++ b/tests/hwsim/test_ap_params.py @@ -92,8 +92,8 @@ def test_ap_element_parse(dev, apdev): """Information element parsing - extra coverage""" bssid = apdev[0]['bssid'] ssid = "test-wpa2-psk" - params = { 'ssid': ssid, - 'vendor_elements': "380501020304059e009e009e009e009e009e00" } + params = {'ssid': ssid, + 'vendor_elements': "380501020304059e009e009e009e009e009e00"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") bss = dev[0].get_bss(bssid) @@ -105,8 +105,8 @@ def test_ap_element_parse_oom(dev, apdev): """Information element parsing OOM""" bssid = apdev[0]['bssid'] ssid = "test-wpa2-psk" - params = { 'ssid': ssid, - 'vendor_elements': "dd0d506f9a0a00000600411c440028" } + params = {'ssid': ssid, + 'vendor_elements': "dd0d506f9a0a00000600411c440028"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") with alloc_fail(dev[0], 1, "wpabuf_alloc;ieee802_11_vendor_ie_concat"): @@ -489,7 +489,7 @@ def test_ap_max_num_sta_no_probe_resp(dev, apdev, params): dev[1].scan(freq=2412, type="ONLY") if seen: out = run_tshark(os.path.join(logdir, "hwsim0.pcapng"), - "wlan.fc.type_subtype == 5", ["wlan.da" ]) + "wlan.fc.type_subtype == 5", ["wlan.da"]) if out: if dev[0].own_addr() not in out: # Discovery happened through Beacon frame reception. That's not @@ -547,7 +547,7 @@ def test_ap_tx_queue_params_invalid(dev, apdev): def test_ap_beacon_rate_legacy(dev, apdev): """Open AP with Beacon frame TX rate 5.5 Mbps""" - hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' }) + hapd = hostapd.add_ap(apdev[0], {'ssid': 'beacon-rate'}) res = hapd.get_driver_status_field('capa.flags') if (int(res, 0) & 0x0000080000000000) == 0: raise HwsimSkip("Setting Beacon frame TX rate not supported") @@ -558,7 +558,7 @@ def test_ap_beacon_rate_legacy(dev, apdev): def test_ap_beacon_rate_legacy2(dev, apdev): """Open AP with Beacon frame TX rate 12 Mbps in VHT BSS""" - hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' }) + hapd = hostapd.add_ap(apdev[0], {'ssid': 'beacon-rate'}) res = hapd.get_driver_status_field('capa.flags') if (int(res, 0) & 0x0000080000000000) == 0: raise HwsimSkip("Setting Beacon frame TX rate not supported") @@ -585,7 +585,7 @@ def test_ap_beacon_rate_legacy2(dev, apdev): def test_ap_beacon_rate_ht(dev, apdev): """Open AP with Beacon frame TX rate HT-MCS 0""" - hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' }) + hapd = hostapd.add_ap(apdev[0], {'ssid': 'beacon-rate'}) res = hapd.get_driver_status_field('capa.flags') if (int(res, 0) & 0x0000100000000000) == 0: raise HwsimSkip("Setting Beacon frame TX rate not supported") @@ -596,7 +596,7 @@ def test_ap_beacon_rate_ht(dev, apdev): def test_ap_beacon_rate_ht2(dev, apdev): """Open AP with Beacon frame TX rate HT-MCS 1 in VHT BSS""" - hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' }) + hapd = hostapd.add_ap(apdev[0], {'ssid': 'beacon-rate'}) res = hapd.get_driver_status_field('capa.flags') if (int(res, 0) & 0x0000100000000000) == 0: raise HwsimSkip("Setting Beacon frame TX rate not supported") @@ -623,7 +623,7 @@ def test_ap_beacon_rate_ht2(dev, apdev): def test_ap_beacon_rate_vht(dev, apdev): """Open AP with Beacon frame TX rate VHT-MCS 0""" - hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' }) + hapd = hostapd.add_ap(apdev[0], {'ssid': 'beacon-rate'}) res = hapd.get_driver_status_field('capa.flags') if (int(res, 0) & 0x0000200000000000) == 0: raise HwsimSkip("Setting Beacon frame TX rate not supported") @@ -651,8 +651,8 @@ def test_ap_beacon_rate_vht(dev, apdev): def test_ap_wep_to_wpa(dev, apdev): """WEP to WPA2-PSK configuration change in hostapd""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-to-wpa", - "wep_key0": '"hello"' }) + {"ssid": "wep-to-wpa", + "wep_key0": '"hello"'}) dev[0].flush_scan_cache() dev[0].connect("wep-to-wpa", key_mgmt="NONE", wep_key0='"hello"', scan_freq="2412") @@ -723,7 +723,7 @@ def test_ap_eapol_version(dev, apdev): def test_ap_dtim_period(dev, apdev): """DTIM period configuration""" ssid = "dtim-period" - params = { 'ssid': ssid, 'dtim_period': "10" } + params = {'ssid': ssid, 'dtim_period': "10"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") @@ -749,7 +749,7 @@ def test_ap_dtim_period(dev, apdev): def test_ap_no_probe_resp(dev, apdev): """AP with Probe Response frame sending from hostapd disabled""" ssid = "no-probe-resp" - params = { 'ssid': ssid, 'send_probe_response': "0" } + params = {'ssid': ssid, 'send_probe_response': "0"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].scan_for_bss(bssid, freq="2412", passive=True) @@ -763,9 +763,9 @@ def test_ap_no_probe_resp(dev, apdev): def test_ap_long_preamble(dev, apdev): """AP with long preamble""" ssid = "long-preamble" - params = { 'ssid': ssid, 'preamble': "0", - 'hw_mode': 'b', 'ieee80211n': '0', - 'supported_rates': '10', 'basic_rates': '10' } + params = {'ssid': ssid, 'preamble': "0", + 'hw_mode': 'b', 'ieee80211n': '0', + 'supported_rates': '10', 'basic_rates': '10'} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].scan_for_bss(bssid, freq="2412") @@ -775,7 +775,7 @@ def test_ap_long_preamble(dev, apdev): def test_ap_wmm_uapsd(dev, apdev): """AP with U-APSD advertisement""" ssid = "uapsd" - params = { 'ssid': ssid, 'uapsd_advertisement_enabled': "1" } + params = {'ssid': ssid, 'uapsd_advertisement_enabled': "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].scan_for_bss(bssid, freq="2412") @@ -785,7 +785,7 @@ def test_ap_wmm_uapsd(dev, apdev): def test_ap_wowlan_triggers(dev, apdev): """AP with wowlan_triggers""" ssid = "wowlan" - params = { 'ssid': ssid, 'wowlan_triggers': "any" } + params = {'ssid': ssid, 'wowlan_triggers': "any"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].scan_for_bss(bssid, freq="2412") diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index bcb95ac..e35914c 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -135,7 +135,7 @@ def test_ap_wpa2_psk_file_keyid(dev, apdev, params): if "OK" not in hapd.request("RELOAD_WPA_PSK"): raise Exception("RELOAD_WPA_PSK failed") - check_disconnect(dev, [ False, True, False ]) + check_disconnect(dev, [False, True, False]) with open(psk_file, 'w') as f: f.write('00:00:00:00:00:00 secret passphrase\n') @@ -163,7 +163,7 @@ def test_ap_wpa2_psk_file_keyid(dev, apdev, params): if "OK" not in hapd.request("RELOAD_WPA_PSK"): raise Exception("RELOAD_WPA_PSK failed") - check_disconnect(dev, [ True, True, False ]) + check_disconnect(dev, [True, True, False]) @remote_compatible def test_ap_wpa2_psk_mem(dev, apdev): @@ -260,8 +260,8 @@ def test_ap_wpa2_sha256_ptk_rekey(dev, apdev): if ev is None: raise Exception("PTK rekey timed out") hwsim_utils.test_connectivity(dev[0], hapd) - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6")]) @remote_compatible def test_ap_wpa2_sha256_ptk_rekey_ap(dev, apdev): @@ -278,8 +278,8 @@ def test_ap_wpa2_sha256_ptk_rekey_ap(dev, apdev): if ev is None: raise Exception("PTK rekey timed out") hwsim_utils.test_connectivity(dev[0], hapd) - check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"), - ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6") ]) + check_mib(dev[0], [("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-6"), + ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-6")]) @remote_compatible def test_ap_wpa_ptk_rekey(dev, apdev): @@ -322,14 +322,14 @@ def test_ap_wpa_ccmp(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].connect(ssid, psk=passphrase, scan_freq="2412") hwsim_utils.test_connectivity(dev[0], hapd) - check_mib(dev[0], [ ("dot11RSNAConfigGroupCipherSize", "128"), - ("dot11RSNAGroupCipherRequested", "00-50-f2-4"), - ("dot11RSNAPairwiseCipherRequested", "00-50-f2-4"), - ("dot11RSNAAuthenticationSuiteRequested", "00-50-f2-2"), - ("dot11RSNAGroupCipherSelected", "00-50-f2-4"), - ("dot11RSNAPairwiseCipherSelected", "00-50-f2-4"), - ("dot11RSNAAuthenticationSuiteSelected", "00-50-f2-2"), - ("dot1xSuppSuppControlledPortStatus", "Authorized") ]) + check_mib(dev[0], [("dot11RSNAConfigGroupCipherSize", "128"), + ("dot11RSNAGroupCipherRequested", "00-50-f2-4"), + ("dot11RSNAPairwiseCipherRequested", "00-50-f2-4"), + ("dot11RSNAAuthenticationSuiteRequested", "00-50-f2-2"), + ("dot11RSNAGroupCipherSelected", "00-50-f2-4"), + ("dot11RSNAPairwiseCipherSelected", "00-50-f2-4"), + ("dot11RSNAAuthenticationSuiteSelected", "00-50-f2-2"), + ("dot1xSuppSuppControlledPortStatus", "Authorized")]) def test_ap_wpa2_psk_file_errors(dev, apdev): """WPA2-PSK AP with various PSK file error and success cases""" @@ -343,8 +343,8 @@ def test_ap_wpa2_psk_file_errors(dev, apdev): except: pass - params = { "ssid": ssid, "wpa": "2", "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "CCMP", "wpa_psk_file": pskfile } + params = {"ssid": ssid, "wpa": "2", "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "CCMP", "wpa_psk_file": pskfile} try: # missing PSK file @@ -1271,9 +1271,9 @@ def sha1_prf(key, label, data, outlen): def pmk_to_ptk(pmk, addr1, addr2, nonce1, nonce2): if addr1 < addr2: - data = binascii.unhexlify(addr1.replace(':','')) + binascii.unhexlify(addr2.replace(':','')) + data = binascii.unhexlify(addr1.replace(':', '')) + binascii.unhexlify(addr2.replace(':', '')) else: - data = binascii.unhexlify(addr2.replace(':','')) + binascii.unhexlify(addr1.replace(':','')) + data = binascii.unhexlify(addr2.replace(':', '')) + binascii.unhexlify(addr1.replace(':', '')) if nonce1 < nonce2: data += nonce1 + nonce2 else: @@ -1352,12 +1352,12 @@ def eapol_test(apdev, dev, wpa2=True): else: rsne = binascii.unhexlify('dd160050f20101000050f20201000050f20201000050f202') snonce = binascii.unhexlify('1111111111111111111111111111111111111111111111111111111111111111') - return (bssid,ssid,hapd,snonce,pmk,addr,rsne) + return (bssid, ssid, hapd, snonce, pmk, addr, rsne) @remote_compatible def test_ap_wpa2_psk_ext_eapol(dev, apdev): """WPA2-PSK AP using external EAPOL supplicant""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg = recv_eapol(hapd) anonce = msg['rsn_key_nonce'] @@ -1385,7 +1385,7 @@ def test_ap_wpa2_psk_ext_eapol(dev, apdev): @remote_compatible def test_ap_wpa2_psk_ext_eapol_retry1(dev, apdev): """WPA2 4-way handshake with EAPOL-Key 1/4 retransmitted""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg1 = recv_eapol(hapd) anonce = msg1['rsn_key_nonce'] @@ -1412,7 +1412,7 @@ def test_ap_wpa2_psk_ext_eapol_retry1(dev, apdev): @remote_compatible def test_ap_wpa2_psk_ext_eapol_retry1b(dev, apdev): """WPA2 4-way handshake with EAPOL-Key 1/4 and 2/4 retransmitted""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg1 = recv_eapol(hapd) anonce = msg1['rsn_key_nonce'] @@ -1434,7 +1434,7 @@ def test_ap_wpa2_psk_ext_eapol_retry1b(dev, apdev): @remote_compatible def test_ap_wpa2_psk_ext_eapol_retry1c(dev, apdev): """WPA2 4-way handshake with EAPOL-Key 1/4 and 2/4 retransmitted and SNonce changing""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg1 = recv_eapol(hapd) anonce = msg1['rsn_key_nonce'] @@ -1458,7 +1458,7 @@ def test_ap_wpa2_psk_ext_eapol_retry1c(dev, apdev): @remote_compatible def test_ap_wpa2_psk_ext_eapol_retry1d(dev, apdev): """WPA2 4-way handshake with EAPOL-Key 1/4 and 2/4 retransmitted and SNonce changing and older used""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg1 = recv_eapol(hapd) anonce = msg1['rsn_key_nonce'] @@ -1482,7 +1482,7 @@ def test_ap_wpa2_psk_ext_eapol_retry1d(dev, apdev): @remote_compatible def test_ap_wpa2_psk_ext_eapol_type_diff(dev, apdev): """WPA2 4-way handshake using external EAPOL supplicant""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg = recv_eapol(hapd) anonce = msg['rsn_key_nonce'] @@ -1513,8 +1513,8 @@ def test_ap_wpa2_psk_ext_eapol_type_diff(dev, apdev): @remote_compatible def test_ap_wpa_psk_ext_eapol(dev, apdev): """WPA2-PSK AP using external EAPOL supplicant""" - (bssid,ssid,hapd,snonce,pmk,addr,wpae) = eapol_test(apdev[0], dev[0], - wpa2=False) + (bssid, ssid, hapd, snonce, pmk, addr, wpae) = eapol_test(apdev[0], dev[0], + wpa2=False) msg = recv_eapol(hapd) anonce = msg['rsn_key_nonce'] @@ -1541,7 +1541,7 @@ def test_ap_wpa_psk_ext_eapol(dev, apdev): @remote_compatible def test_ap_wpa2_psk_ext_eapol_key_info(dev, apdev): """WPA2-PSK 4-way handshake with strange key info values""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) msg = recv_eapol(hapd) anonce = msg['rsn_key_nonce'] @@ -1632,7 +1632,7 @@ def aes_wrap(kek, plain): for i in range(1, n + 1): b = enc(struct.pack('>Q', a) + r[i - 1]) a = struct.unpack('>Q', b[:8])[0] ^ (n * j + i) - r[i - 1] =b[8:] + r[i - 1] = b[8:] return struct.pack('>Q', a) + b''.join(r) def pad_key_data(plain): @@ -1646,7 +1646,7 @@ def pad_key_data(plain): def test_ap_wpa2_psk_supp_proto(dev, apdev): """WPA2-PSK 4-way handshake protocol testing for supplicant""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -1843,7 +1843,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev): def test_ap_wpa2_psk_supp_proto_no_ie(dev, apdev): """WPA2-PSK supplicant protocol testing: IE not included""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -1870,7 +1870,7 @@ def test_ap_wpa2_psk_supp_proto_no_ie(dev, apdev): def test_ap_wpa2_psk_supp_proto_ie_mismatch(dev, apdev): """WPA2-PSK supplicant protocol testing: IE mismatch""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -1897,7 +1897,7 @@ def test_ap_wpa2_psk_supp_proto_ie_mismatch(dev, apdev): def test_ap_wpa2_psk_supp_proto_ok(dev, apdev): """WPA2-PSK supplicant protocol testing: success""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -1925,7 +1925,7 @@ def test_ap_wpa2_psk_supp_proto_ok(dev, apdev): def test_ap_wpa2_psk_supp_proto_no_gtk(dev, apdev): """WPA2-PSK supplicant protocol testing: no GTK""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -1955,7 +1955,7 @@ def test_ap_wpa2_psk_supp_proto_no_gtk(dev, apdev): def test_ap_wpa2_psk_supp_proto_anonce_change(dev, apdev): """WPA2-PSK supplicant protocol testing: ANonce change""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -1986,7 +1986,7 @@ def test_ap_wpa2_psk_supp_proto_anonce_change(dev, apdev): def test_ap_wpa2_psk_supp_proto_unexpected_group_msg(dev, apdev): """WPA2-PSK supplicant protocol testing: unexpected group message""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2018,7 +2018,7 @@ def test_ap_wpa2_psk_supp_proto_unexpected_group_msg(dev, apdev): @remote_compatible def test_ap_wpa2_psk_supp_proto_msg_1_invalid_kde(dev, apdev): """WPA2-PSK supplicant protocol testing: invalid KDE in msg 1/4""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2035,7 +2035,7 @@ def test_ap_wpa2_psk_supp_proto_msg_1_invalid_kde(dev, apdev): def test_ap_wpa2_psk_supp_proto_wrong_pairwise_key_len(dev, apdev): """WPA2-PSK supplicant protocol testing: wrong pairwise key length""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2067,7 +2067,7 @@ def test_ap_wpa2_psk_supp_proto_wrong_pairwise_key_len(dev, apdev): def test_ap_wpa2_psk_supp_proto_wrong_group_key_len(dev, apdev): """WPA2-PSK supplicant protocol testing: wrong group key length""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2098,7 +2098,7 @@ def test_ap_wpa2_psk_supp_proto_wrong_group_key_len(dev, apdev): def test_ap_wpa2_psk_supp_proto_gtk_tx_bit_workaround(dev, apdev): """WPA2-PSK supplicant protocol testing: GTK TX bit workaround""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2129,7 +2129,7 @@ def test_ap_wpa2_psk_supp_proto_gtk_tx_bit_workaround(dev, apdev): def test_ap_wpa2_psk_supp_proto_gtk_keyidx_0_and_3(dev, apdev): """WPA2-PSK supplicant protocol testing: GTK key index 0 and 3""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2182,7 +2182,7 @@ def test_ap_wpa2_psk_supp_proto_gtk_keyidx_0_and_3(dev, apdev): def test_ap_wpa2_psk_supp_proto_no_gtk_in_group_msg(dev, apdev): """WPA2-PSK supplicant protocol testing: GTK KDE missing from group msg""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2223,7 +2223,7 @@ def test_ap_wpa2_psk_supp_proto_no_gtk_in_group_msg(dev, apdev): def test_ap_wpa2_psk_supp_proto_too_long_gtk_in_group_msg(dev, apdev): """WPA2-PSK supplicant protocol testing: too long GTK KDE in group msg""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2264,7 +2264,7 @@ def test_ap_wpa2_psk_supp_proto_too_long_gtk_in_group_msg(dev, apdev): def test_ap_wpa2_psk_supp_proto_too_long_gtk_kde(dev, apdev): """WPA2-PSK supplicant protocol testing: too long GTK KDE""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2292,7 +2292,7 @@ def test_ap_wpa2_psk_supp_proto_too_long_gtk_kde(dev, apdev): def test_ap_wpa2_psk_supp_proto_gtk_not_encrypted(dev, apdev): """WPA2-PSK supplicant protocol testing: GTK KDE not encrypted""" - (bssid,ssid,hapd,snonce,pmk,addr,rsne) = eapol_test(apdev[0], dev[0]) + (bssid, ssid, hapd, snonce, pmk, addr, rsne) = eapol_test(apdev[0], dev[0]) # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated msg = recv_eapol(hapd) @@ -2350,7 +2350,7 @@ def read_process_memory(pid, key=None): continue if not perm.startswith('rw'): continue - for name in [ "[heap]", "[stack]" ]: + for name in ["[heap]", "[stack]"]: if name in l: logger.info("%s 0x%x-0x%x is at %d-%d" % (name, start, end, len(buf), len(buf) + (end - start))) mem.seek(start) @@ -2506,8 +2506,8 @@ def test_ap_wpa2_psk_wep(dev, apdev): def test_ap_wpa2_psk_wpas_in_bridge(dev, apdev): """WPA2-PSK AP and wpas interface in a bridge""" - br_ifname='sta-br0' - ifname='wlan5' + br_ifname = 'sta-br0' + ifname = 'wlan5' try: _test_ap_wpa2_psk_wpas_in_bridge(dev, apdev) finally: @@ -2522,8 +2522,8 @@ def _test_ap_wpa2_psk_wpas_in_bridge(dev, apdev): params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) hapd = hostapd.add_ap(apdev[0], params) - br_ifname='sta-br0' - ifname='wlan5' + br_ifname = 'sta-br0' + ifname = 'wlan5' wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') subprocess.call(['brctl', 'addbr', br_ifname]) subprocess.call(['brctl', 'setfd', br_ifname, '0']) @@ -2675,29 +2675,29 @@ def test_ap_wpa_ie_parsing(dev, apdev): id = dev[0].connect(ssid, psk=passphrase, scan_freq="2412", only_add_network=True) - tests = [ "dd040050f201", - "dd050050f20101", - "dd060050f2010100", - "dd060050f2010001", - "dd070050f201010000", - "dd080050f20101000050", - "dd090050f20101000050f2", - "dd0a0050f20101000050f202", - "dd0b0050f20101000050f20201", - "dd0c0050f20101000050f2020100", - "dd0c0050f20101000050f2020000", - "dd0c0050f20101000050f202ffff", - "dd0d0050f20101000050f202010000", - "dd0e0050f20101000050f20201000050", - "dd0f0050f20101000050f20201000050f2", - "dd100050f20101000050f20201000050f202", - "dd110050f20101000050f20201000050f20201", - "dd120050f20101000050f20201000050f2020100", - "dd120050f20101000050f20201000050f2020000", - "dd120050f20101000050f20201000050f202ffff", - "dd130050f20101000050f20201000050f202010000", - "dd140050f20101000050f20201000050f20201000050", - "dd150050f20101000050f20201000050f20201000050f2" ] + tests = ["dd040050f201", + "dd050050f20101", + "dd060050f2010100", + "dd060050f2010001", + "dd070050f201010000", + "dd080050f20101000050", + "dd090050f20101000050f2", + "dd0a0050f20101000050f202", + "dd0b0050f20101000050f20201", + "dd0c0050f20101000050f2020100", + "dd0c0050f20101000050f2020000", + "dd0c0050f20101000050f202ffff", + "dd0d0050f20101000050f202010000", + "dd0e0050f20101000050f20201000050", + "dd0f0050f20101000050f20201000050f2", + "dd100050f20101000050f20201000050f202", + "dd110050f20101000050f20201000050f20201", + "dd120050f20101000050f20201000050f2020100", + "dd120050f20101000050f20201000050f2020000", + "dd120050f20101000050f20201000050f202ffff", + "dd130050f20101000050f20201000050f202010000", + "dd140050f20101000050f20201000050f20201000050", + "dd150050f20101000050f20201000050f20201000050f2"] for t in tests: try: if "OK" not in dev[0].request("VENDOR_ELEM_ADD 13 " + t): @@ -2711,9 +2711,9 @@ def test_ap_wpa_ie_parsing(dev, apdev): finally: dev[0].request("VENDOR_ELEM_REMOVE 13 *") - tests = [ "dd170050f20101000050f20201000050f20201000050f202ff", - "dd180050f20101000050f20201000050f20201000050f202ffff", - "dd190050f20101000050f20201000050f20201000050f202ffffff" ] + tests = ["dd170050f20101000050f20201000050f20201000050f202ff", + "dd180050f20101000050f20201000050f20201000050f202ffff", + "dd190050f20101000050f20201000050f20201000050f202ffffff"] for t in tests: try: if "OK" not in dev[0].request("VENDOR_ELEM_ADD 13 " + t): @@ -2761,25 +2761,25 @@ def test_rsn_ie_proto_psk_sta(dev, apdev): raise Exception("Invalid own_ie_override value accepted") id = dev[0].connect(ssid, psk=passphrase, scan_freq="2412") - tests = [ ('No RSN Capabilities field', - '30120100000fac040100000fac040100000fac02'), - ('Reserved RSN Capabilities bits set', - '30140100000fac040100000fac040100000fac023cff'), - ('Truncated RSN Capabilities field', - '30130100000fac040100000fac040100000fac023c'), - ('Extra pairwise cipher suite (unsupported)', - '30180100000fac040200ffffffff000fac040100000fac020c00'), - ('Extra AKM suite (unsupported)', - '30180100000fac040100000fac040200ffffffff000fac020c00'), - ('PMKIDCount field included', - '30160100000fac040100000fac040100000fac020c000000'), - ('Truncated PMKIDCount field', - '30150100000fac040100000fac040100000fac020c0000'), - ('Unexpected Group Management Cipher Suite with PMF disabled', - '301a0100000fac040100000fac040100000fac020c000000000fac06'), - ('Extra octet after defined fields (future extensibility)', - '301b0100000fac040100000fac040100000fac020c000000000fac0600') ] - for txt,ie in tests: + tests = [('No RSN Capabilities field', + '30120100000fac040100000fac040100000fac02'), + ('Reserved RSN Capabilities bits set', + '30140100000fac040100000fac040100000fac023cff'), + ('Truncated RSN Capabilities field', + '30130100000fac040100000fac040100000fac023c'), + ('Extra pairwise cipher suite (unsupported)', + '30180100000fac040200ffffffff000fac040100000fac020c00'), + ('Extra AKM suite (unsupported)', + '30180100000fac040100000fac040200ffffffff000fac020c00'), + ('PMKIDCount field included', + '30160100000fac040100000fac040100000fac020c000000'), + ('Truncated PMKIDCount field', + '30150100000fac040100000fac040100000fac020c0000'), + ('Unexpected Group Management Cipher Suite with PMF disabled', + '301a0100000fac040100000fac040100000fac020c000000000fac06'), + ('Extra octet after defined fields (future extensibility)', + '301b0100000fac040100000fac040100000fac020c000000000fac0600')] + for txt, ie in tests: dev[0].request("DISCONNECT") dev[0].wait_disconnected() dev[0].dump_monitor() @@ -2831,10 +2831,10 @@ def test_ap_wpa2_psk_assoc_rsn(dev, apdev): params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) hapd = hostapd.add_ap(apdev[0], params) - tests = [ ("Normal wpa_supplicant assoc req RSN IE", - "30140100000fac040100000fac040100000fac020000"), - ("RSN IE without RSN Capabilities", - "30120100000fac040100000fac040100000fac02") ] + tests = [("Normal wpa_supplicant assoc req RSN IE", + "30140100000fac040100000fac040100000fac020000"), + ("RSN IE without RSN Capabilities", + "30120100000fac040100000fac040100000fac02")] for title, ie in tests: logger.info(title) set_test_assoc_ie(dev[0], ie) @@ -2842,11 +2842,11 @@ def test_ap_wpa2_psk_assoc_rsn(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ ("WPA IE instead of RSN IE and only RSN enabled on AP", - "dd160050f20101000050f20201000050f20201000050f202", 40), - ("Empty RSN IE", "3000", 40), - ("RSN IE with truncated Version", "300101", 40), - ("RSN IE with only Version", "30020100", 43) ] + tests = [("WPA IE instead of RSN IE and only RSN enabled on AP", + "dd160050f20101000050f20201000050f20201000050f202", 40), + ("Empty RSN IE", "3000", 40), + ("RSN IE with truncated Version", "300101", 40), + ("RSN IE with only Version", "30020100", 43)] for title, ie, status in tests: logger.info(title) set_test_assoc_ie(dev[0], ie) @@ -2865,11 +2865,11 @@ def test_ap_wpa2_psk_ft_workaround(dev, apdev): ssid = "test-wpa2-psk-ft" passphrase = 'qwertyuiop' - params = { "wpa": "2", - "wpa_key_mgmt": "FT-PSK WPA-PSK", - "rsn_pairwise": "CCMP", - "ssid": ssid, - "wpa_passphrase": passphrase } + params = {"wpa": "2", + "wpa_key_mgmt": "FT-PSK WPA-PSK", + "rsn_pairwise": "CCMP", + "ssid": ssid, + "wpa_passphrase": passphrase} params["mobility_domain"] = "a1b2" params["r0_key_lifetime"] = "10000" params["pmk_r1_push"] = "1" @@ -2899,8 +2899,8 @@ def test_ap_wpa2_psk_assoc_rsn_pmkid(dev, apdev): def test_ap_wpa_psk_rsn_pairwise(dev, apdev): """WPA-PSK AP and only rsn_pairwise set""" - params = { "ssid": "wpapsk", "wpa": "1", "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "TKIP", "wpa_passphrase": "1234567890" } + params = {"ssid": "wpapsk", "wpa": "1", "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "TKIP", "wpa_passphrase": "1234567890"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("wpapsk", psk="1234567890", proto="WPA", pairwise="TKIP", scan_freq="2412") diff --git a/tests/hwsim/test_ap_qosmap.py b/tests/hwsim/test_ap_qosmap.py index 1cc202e..e4e940f 100644 --- a/tests/hwsim/test_ap_qosmap.py +++ b/tests/hwsim/test_ap_qosmap.py @@ -25,12 +25,12 @@ def check_qos_map(ap, hapd, dev, sta, dscp, tid, ap_tid=None): time.sleep(sleep_time) tx = wt.get_tx_tid(bssid, sta, tid) if tx == 0: - [ tx, rx ] = wt.get_tid_counters(bssid, sta) + [tx, rx] = wt.get_tid_counters(bssid, sta) logger.info("Expected TX DSCP " + str(dscp) + " with TID " + str(tid) + " but counters: " + str(tx)) raise Exception("No STA->AP data frame using the expected TID") rx = wt.get_rx_tid(bssid, sta, ap_tid) if rx == 0: - [ tx, rx ] = wt.get_tid_counters(bssid, sta) + [tx, rx] = wt.get_tid_counters(bssid, sta) logger.info("Expected RX DSCP " + str(dscp) + " with TID " + str(ap_tid) + " but counters: " + str(rx)) raise Exception("No AP->STA data frame using the expected TID") @@ -41,7 +41,7 @@ def test_ap_qosmap(dev, apdev): if int(drv_flags, 0) & 0x40000000 == 0: raise HwsimSkip("Driver does not support QoS Map") ssid = "test-qosmap" - params = { "ssid": ssid } + params = {"ssid": ssid} params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55' hapd = hostapd.add_ap(apdev[0], params) dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") @@ -79,14 +79,14 @@ def test_ap_qosmap(dev, apdev): def test_ap_qosmap_default(dev, apdev): """QoS mapping with default values""" ssid = "test-qosmap-default" - params = { "ssid": ssid } + params = {"ssid": ssid} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") addr = dev[0].p2p_interface_addr() dev[0].request("DATA_TEST_CONFIG 1") hapd.request("DATA_TEST_CONFIG 1") Wlantest.setup(hapd) - for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: + for dscp in [0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: check_qos_map(apdev[0], hapd, dev[0], addr, dscp, dscp >> 3) dev[0].request("DATA_TEST_CONFIG 0") hapd.request("DATA_TEST_CONFIG 0") @@ -95,38 +95,38 @@ def test_ap_qosmap_default(dev, apdev): def test_ap_qosmap_default_acm(dev, apdev): """QoS mapping with default values and ACM=1 for VO/VI""" ssid = "test-qosmap-default" - params = { "ssid": ssid, - "wmm_ac_bk_aifs": "7", - "wmm_ac_bk_cwmin": "4", - "wmm_ac_bk_cwmax": "10", - "wmm_ac_bk_txop_limit": "0", - "wmm_ac_bk_acm": "0", - "wmm_ac_be_aifs": "3", - "wmm_ac_be_cwmin": "4", - "wmm_ac_be_cwmax": "10", - "wmm_ac_be_txop_limit": "0", - "wmm_ac_be_acm": "0", - "wmm_ac_vi_aifs": "2", - "wmm_ac_vi_cwmin": "3", - "wmm_ac_vi_cwmax": "4", - "wmm_ac_vi_txop_limit": "94", - "wmm_ac_vi_acm": "1", - "wmm_ac_vo_aifs": "2", - "wmm_ac_vo_cwmin": "2", - "wmm_ac_vo_cwmax": "2", - "wmm_ac_vo_txop_limit": "47", - "wmm_ac_vo_acm": "1" } + params = {"ssid": ssid, + "wmm_ac_bk_aifs": "7", + "wmm_ac_bk_cwmin": "4", + "wmm_ac_bk_cwmax": "10", + "wmm_ac_bk_txop_limit": "0", + "wmm_ac_bk_acm": "0", + "wmm_ac_be_aifs": "3", + "wmm_ac_be_cwmin": "4", + "wmm_ac_be_cwmax": "10", + "wmm_ac_be_txop_limit": "0", + "wmm_ac_be_acm": "0", + "wmm_ac_vi_aifs": "2", + "wmm_ac_vi_cwmin": "3", + "wmm_ac_vi_cwmax": "4", + "wmm_ac_vi_txop_limit": "94", + "wmm_ac_vi_acm": "1", + "wmm_ac_vo_aifs": "2", + "wmm_ac_vo_cwmin": "2", + "wmm_ac_vo_cwmax": "2", + "wmm_ac_vo_txop_limit": "47", + "wmm_ac_vo_acm": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") addr = dev[0].p2p_interface_addr() dev[0].request("DATA_TEST_CONFIG 1") hapd.request("DATA_TEST_CONFIG 1") Wlantest.setup(hapd) - for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: + for dscp in [0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]: ap_tid = dscp >> 3 tid = ap_tid # downgrade VI/VO to BE - if tid in [ 4, 5, 6, 7 ]: + if tid in [4, 5, 6, 7]: tid = 3 check_qos_map(apdev[0], hapd, dev[0], addr, dscp, tid, ap_tid) dev[0].request("DATA_TEST_CONFIG 0") @@ -136,7 +136,7 @@ def test_ap_qosmap_default_acm(dev, apdev): def test_ap_qosmap_invalid(dev, apdev): """QoS mapping ctrl_iface error handling""" ssid = "test-qosmap" - params = { "ssid": ssid } + params = {"ssid": ssid} hapd = hostapd.add_ap(apdev[0], params) if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"): raise Exception("Unexpected SEND_QOS_MAP_CONF success") diff --git a/tests/hwsim/test_ap_roam.py b/tests/hwsim/test_ap_roam.py index 575239f..6708f3f 100644 --- a/tests/hwsim/test_ap_roam.py +++ b/tests/hwsim/test_ap_roam.py @@ -16,10 +16,10 @@ from wpasupplicant import WpaSupplicant @remote_compatible def test_ap_roam_open(dev, apdev): """Roam between two open APs""" - hapd0 = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd0 = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) dev[0].connect("test-open", key_mgmt="NONE") hwsim_utils.test_connectivity(dev[0], hapd0) - hapd1 = hostapd.add_ap(apdev[1], { "ssid": "test-open" }) + hapd1 = hostapd.add_ap(apdev[1], {"ssid": "test-open"}) dev[0].scan(type="ONLY") dev[0].roam(apdev[1]['bssid']) hwsim_utils.test_connectivity(dev[0], hapd1) @@ -29,10 +29,10 @@ def test_ap_roam_open(dev, apdev): @remote_compatible def test_ap_roam_open_failed(dev, apdev): """Roam failure due to rejected authentication""" - hapd0 = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd0 = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") hwsim_utils.test_connectivity(dev[0], hapd0) - params = { "ssid": "test-open", "max_num_sta" : "0" } + params = {"ssid": "test-open", "max_num_sta": "0"} hapd1 = hostapd.add_ap(apdev[1], params) bssid = hapd1.own_addr() @@ -174,7 +174,7 @@ def test_ap_roam_wpa2_psk_failed(dev, apdev, params): @remote_compatible def test_ap_reassociation_to_same_bss(dev, apdev): """Reassociate to the same BSS""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) dev[0].connect("test-open", key_mgmt="NONE") dev[0].request("REASSOCIATE") @@ -194,8 +194,8 @@ def test_ap_reassociation_to_same_bss(dev, apdev): @remote_compatible def test_ap_roam_set_bssid(dev, apdev): """Roam control""" - hostapd.add_ap(apdev[0], { "ssid": "test-open" }) - hostapd.add_ap(apdev[1], { "ssid": "test-open" }) + hostapd.add_ap(apdev[0], {"ssid": "test-open"}) + hostapd.add_ap(apdev[1], {"ssid": "test-open"}) id = dev[0].connect("test-open", key_mgmt="NONE", bssid=apdev[1]['bssid'], scan_freq="2412") if dev[0].get_status_field('bssid') != apdev[1]['bssid']: diff --git a/tests/hwsim/test_ap_tdls.py b/tests/hwsim/test_ap_tdls.py index 6f6f65a..fb74065 100644 --- a/tests/hwsim/test_ap_tdls.py +++ b/tests/hwsim/test_ap_tdls.py @@ -70,13 +70,13 @@ def wlantest_tdls_packet_counters(bssid, addr0, addr1): inv_dl = wt.get_tdls_counter("invalid_direct_link", bssid, addr0, addr1) ap = wt.get_tdls_counter("valid_ap_path", bssid, addr0, addr1) inv_ap = wt.get_tdls_counter("invalid_ap_path", bssid, addr0, addr1) - return [dl,inv_dl,ap,inv_ap] + return [dl, inv_dl, ap, inv_ap] def tdls_check_dl(sta0, sta1, bssid, addr0, addr1): wt = Wlantest() wt.tdls_clear(bssid, addr0, addr1) hwsim_utils.test_connectivity_sta(sta0, sta1) - [dl,inv_dl,ap,inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1) + [dl, inv_dl, ap, inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1) if dl == 0: raise Exception("No valid frames through direct link") if inv_dl > 0: @@ -90,7 +90,7 @@ def tdls_check_ap(sta0, sta1, bssid, addr0, addr1): wt = Wlantest() wt.tdls_clear(bssid, addr0, addr1) hwsim_utils.test_connectivity_sta(sta0, sta1) - [dl,inv_dl,ap,inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1) + [dl, inv_dl, ap, inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1) if dl > 0: raise Exception("Unexpected frames through direct link") if inv_dl > 0: @@ -306,7 +306,7 @@ def test_ap_wpa_mixed_tdls(dev, apdev): def test_ap_wep_tdls(dev, apdev): """WEP AP and two stations using TDLS""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "test-wep", "wep_key0": '"hello"' }) + {"ssid": "test-wep", "wep_key0": '"hello"'}) wlantest_setup(hapd) connect_2sta_wep(dev, hapd) setup_tdls(dev[0], dev[1], hapd) @@ -315,7 +315,7 @@ def test_ap_wep_tdls(dev, apdev): def test_ap_open_tdls(dev, apdev): """Open AP and two stations using TDLS""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) wlantest_setup(hapd) connect_2sta_open(dev, hapd) setup_tdls(dev[0], dev[1], hapd) @@ -381,16 +381,16 @@ def tdls_clear_reg(hapd, dev): def test_ap_open_tdls_vht(dev, apdev): """Open AP and two stations using TDLS""" - params = { "ssid": "test-open", - "country_code": "DE", - "hw_mode": "a", - "channel": "36", - "ieee80211n": "1", - "ieee80211ac": "1", - "ht_capab": "", - "vht_capab": "", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "0" } + params = {"ssid": "test-open", + "country_code": "DE", + "hw_mode": "a", + "channel": "36", + "ieee80211n": "1", + "ieee80211ac": "1", + "ht_capab": "", + "vht_capab": "", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "0"} hapd = None try: hapd = hostapd.add_ap(apdev[0], params) @@ -405,16 +405,16 @@ def test_ap_open_tdls_vht(dev, apdev): def test_ap_open_tdls_vht80(dev, apdev): """Open AP and two stations using TDLS with VHT 80""" - params = { "ssid": "test-open", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_capab": "", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "test-open", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_capab": "", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42"} try: hapd = None hapd = hostapd.add_ap(apdev[0], params) @@ -442,17 +442,17 @@ def test_ap_open_tdls_vht80(dev, apdev): def test_ap_open_tdls_vht80plus80(dev, apdev): """Open AP and two stations using TDLS with VHT 80+80""" - params = { "ssid": "test-open", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_capab": "", - "vht_oper_chwidth": "3", - "vht_oper_centr_freq_seg0_idx": "42", - "vht_oper_centr_freq_seg1_idx": "155" } + params = {"ssid": "test-open", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_capab": "", + "vht_oper_chwidth": "3", + "vht_oper_centr_freq_seg0_idx": "42", + "vht_oper_centr_freq_seg1_idx": "155"} try: hapd = None hapd = hostapd.add_ap(apdev[0], params) @@ -486,15 +486,15 @@ def test_ap_open_tdls_vht80plus80(dev, apdev): def test_ap_open_tdls_vht160(dev, apdev): """Open AP and two stations using TDLS with VHT 160""" - params = { "ssid": "test-open", - "country_code": "ZA", - "hw_mode": "a", - "channel": "104", - "ht_capab": "[HT40-]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "vht_oper_centr_freq_seg0_idx": "114" } + params = {"ssid": "test-open", + "country_code": "ZA", + "hw_mode": "a", + "channel": "104", + "ht_capab": "[HT40-]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "vht_oper_centr_freq_seg0_idx": "114"} try: hapd = None hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) @@ -534,7 +534,7 @@ def test_tdls_chan_switch(dev, apdev): if flags & 0x800000000 == 0: raise HwsimSkip("Driver does not support TDLS channel switching") - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) wlantest_setup(hapd) connect_2sta_open(dev, hapd) setup_tdls(dev[0], dev[1], hapd) @@ -562,16 +562,16 @@ def test_ap_tdls_link_status(dev, apdev): def test_ap_tdls_prohibit(dev, apdev): """Open AP and TDLS prohibited""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open", - "tdls_prohibit": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open", + "tdls_prohibit": "1"}) connect_2sta_open(dev, hapd) if "FAIL" not in dev[0].request("TDLS_SETUP " + dev[1].own_addr()): raise Exception("TDLS_SETUP accepted unexpectedly") def test_ap_tdls_chan_switch_prohibit(dev, apdev): """Open AP and TDLS channel switch prohibited""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open", - "tdls_prohibit_chan_switch": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open", + "tdls_prohibit_chan_switch": "1"}) wlantest_setup(hapd) connect_2sta_open(dev, hapd) setup_tdls(dev[0], dev[1], hapd) @@ -584,7 +584,7 @@ def test_ap_open_tdls_external_control(dev, apdev): dev[0].set("tdls_external_control", "0") def _test_ap_open_tdls_external_control(dev, apdev): - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") dev[1].connect("test-open", key_mgmt="NONE", scan_freq="2412") addr0 = dev[0].own_addr() diff --git a/tests/hwsim/test_ap_track.py b/tests/hwsim/test_ap_track.py index 4444e39..25201e5 100644 --- a/tests/hwsim/test_ap_track.py +++ b/tests/hwsim/test_ap_track.py @@ -22,20 +22,20 @@ def test_ap_track_sta(dev, apdev): time.sleep(0.1) def _test_ap_track_sta(dev, apdev): - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "track_sta_max_num": "2" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "track_sta_max_num": "2"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "a", - "channel": "40", - "track_sta_max_num": "100", - "track_sta_max_age": "1" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "a", + "channel": "40", + "track_sta_max_num": "100", + "track_sta_max_age": "1"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -91,20 +91,20 @@ def test_ap_track_sta_no_probe_resp(dev, apdev): def _test_ap_track_sta_no_probe_resp(dev, apdev): dev[0].flush_scan_cache() - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "beacon_int": "10000", - "no_probe_resp_if_seen_on": apdev[1]['ifname'] } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "beacon_int": "10000", + "no_probe_resp_if_seen_on": apdev[1]['ifname']} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "a", - "channel": "40", - "track_sta_max_num": "100" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "a", + "channel": "40", + "track_sta_max_num": "100"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -132,20 +132,20 @@ def test_ap_track_sta_no_auth(dev, apdev): time.sleep(0.1) def _test_ap_track_sta_no_auth(dev, apdev): - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "track_sta_max_num": "100", - "no_auth_if_seen_on": apdev[1]['ifname'] } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "track_sta_max_num": "100", + "no_auth_if_seen_on": apdev[1]['ifname']} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "a", - "channel": "40", - "track_sta_max_num": "100" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "a", + "channel": "40", + "track_sta_max_num": "100"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -158,8 +158,8 @@ def _test_ap_track_sta_no_auth(dev, apdev): dev[0].connect("track", key_mgmt="NONE", scan_freq="2437", freq_list="2437", wait_connect=False) dev[1].request("DISCONNECT") - ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED", - "CTRL-EVENT-AUTH-REJECT" ], timeout=10) + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", + "CTRL-EVENT-AUTH-REJECT"], timeout=10) if ev is None: raise Exception("Unknown connection result") if "CTRL-EVENT-CONNECTED" in ev: @@ -181,21 +181,21 @@ def test_ap_track_sta_no_auth_passive(dev, apdev): def _test_ap_track_sta_no_auth_passive(dev, apdev): dev[0].flush_scan_cache() - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "no_auth_if_seen_on": apdev[1]['ifname'] } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "no_auth_if_seen_on": apdev[1]['ifname']} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "a", - "channel": "40", - "interworking": "1", - "venue_name": "eng:Venue", - "track_sta_max_num": "100" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "a", + "channel": "40", + "interworking": "1", + "venue_name": "eng:Venue", + "track_sta_max_num": "100"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -218,8 +218,8 @@ def _test_ap_track_sta_no_auth_passive(dev, apdev): dev[0].connect("track", key_mgmt="NONE", scan_freq="2437", freq_list="2437", wait_connect=False) - ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED", - "CTRL-EVENT-AUTH-REJECT" ], timeout=10) + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED", + "CTRL-EVENT-AUTH-REJECT"], timeout=10) if ev is None: raise Exception("Unknown connection result") if "CTRL-EVENT-CONNECTED" in ev: @@ -237,20 +237,20 @@ def test_ap_track_sta_force_5ghz(dev, apdev): time.sleep(0.1) def _test_ap_track_sta_force_5ghz(dev, apdev): - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "no_probe_resp_if_seen_on": apdev[1]['ifname'], - "no_auth_if_seen_on": apdev[1]['ifname'] } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "no_probe_resp_if_seen_on": apdev[1]['ifname'], + "no_auth_if_seen_on": apdev[1]['ifname']} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "a", - "channel": "40", - "track_sta_max_num": "100" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "a", + "channel": "40", + "track_sta_max_num": "100"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -272,20 +272,20 @@ def test_ap_track_sta_force_2ghz(dev, apdev): time.sleep(0.1) def _test_ap_track_sta_force_2ghz(dev, apdev): - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "track_sta_max_num": "100" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "track_sta_max_num": "100"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "a", - "channel": "40", - "no_probe_resp_if_seen_on": apdev[0]['ifname'], - "no_auth_if_seen_on": apdev[0]['ifname'] } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "a", + "channel": "40", + "no_probe_resp_if_seen_on": apdev[0]['ifname'], + "no_auth_if_seen_on": apdev[0]['ifname']} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -310,11 +310,11 @@ def test_ap_track_taxonomy(dev, apdev): dev[2].flush_scan_cache() def _test_ap_track_taxonomy(dev, apdev): - params = { "ssid": "track", - "country_code": "US", - "hw_mode": "g", - "channel": "6", - "track_sta_max_num": "2" } + params = {"ssid": "track", + "country_code": "US", + "hw_mode": "g", + "channel": "6", + "track_sta_max_num": "2"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] diff --git a/tests/hwsim/test_ap_vht.py b/tests/hwsim/test_ap_vht.py index df4be9b..e17b397 100644 --- a/tests/hwsim/test_ap_vht.py +++ b/tests/hwsim/test_ap_vht.py @@ -29,15 +29,15 @@ def test_ap_vht80(dev, apdev): """VHT with 80 MHz channel width""" try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] @@ -91,15 +91,15 @@ def test_ap_vht_wifi_generation(dev, apdev): """VHT and wifi_generation""" try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] @@ -138,15 +138,15 @@ def vht80_test(apdev, dev, channel, ht_capab): clear_scan_cache(apdev) try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": str(channel), - "ht_capab": ht_capab, - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": str(channel), + "ht_capab": ht_capab, + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42"} hapd = hostapd.add_ap(apdev, params) bssid = apdev['bssid'] @@ -180,17 +180,17 @@ def test_ap_vht80_params(dev, apdev): """VHT with 80 MHz channel width and number of optional features enabled""" try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]", - "vht_oper_centr_freq_seg0_idx": "42", - "require_vht": "1" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]", + "vht_oper_centr_freq_seg0_idx": "42", + "require_vht": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[1].connect("vht", key_mgmt="NONE", scan_freq="5180", @@ -225,18 +225,18 @@ def test_ap_vht80_invalid(dev, apdev): """VHT with invalid 80 MHz channel configuration (seg1)""" try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42", - "vht_oper_centr_freq_seg1_idx": "155", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42", + "vht_oper_centr_freq_seg1_idx": "155", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) # This fails due to unexpected seg1 configuration ev = hapd.wait_event(["AP-DISABLED"], timeout=5) @@ -257,17 +257,17 @@ def test_ap_vht80_invalid2(dev, apdev): """VHT with invalid 80 MHz channel configuration (seg0)""" try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "46", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "46", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) # This fails due to invalid seg0 configuration ev = hapd.wait_event(["AP-DISABLED"], timeout=5) @@ -290,19 +290,18 @@ def test_ap_vht_20(devs, apdevs): ap = apdevs[0] try: hapd = None - params = { "ssid": "test-vht20", - "country_code": "DE", - "hw_mode": "a", - "channel": "36", - "ieee80211n": "1", - "ieee80211ac": "1", - "ht_capab": "", - "vht_capab": "", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "0", - "supported_rates": "60 120 240 360 480 540", - "require_vht": "1", - } + params = {"ssid": "test-vht20", + "country_code": "DE", + "hw_mode": "a", + "channel": "36", + "ieee80211n": "1", + "ieee80211ac": "1", + "ht_capab": "", + "vht_capab": "", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "0", + "supported_rates": "60 120 240 360 480 540", + "require_vht": "1"} hapd = hostapd.add_ap(ap, params) dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE") hwsim_utils.test_connectivity(dev, hapd) @@ -319,17 +318,16 @@ def test_ap_vht_40(devs, apdevs): ap = apdevs[0] try: hapd = None - params = { "ssid": "test-vht40", - "country_code": "DE", - "hw_mode": "a", - "channel": "36", - "ieee80211n": "1", - "ieee80211ac": "1", - "ht_capab": "[HT40+]", - "vht_capab": "", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "0", - } + params = {"ssid": "test-vht40", + "country_code": "DE", + "hw_mode": "a", + "channel": "36", + "ieee80211n": "1", + "ieee80211ac": "1", + "ht_capab": "[HT40+]", + "vht_capab": "", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "0"} hapd = hostapd.add_ap(ap, params) dev.connect("test-vht40", scan_freq="5180", key_mgmt="NONE") hwsim_utils.test_connectivity(dev, hapd) @@ -343,17 +341,17 @@ def test_ap_vht_40(devs, apdevs): def test_ap_vht_capab_not_supported(dev, apdev): """VHT configuration with driver not supporting all vht_capab entries""" try: - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_capab": "[MAX-MPDU-7991][MAX-MPDU-11454][VHT160][VHT160-80PLUS80][RXLDPC][SHORT-GI-80][SHORT-GI-160][TX-STBC-2BY1][RX-STBC-1][RX-STBC-12][RX-STBC-123][RX-STBC-1234][SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][BF-ANTENNA-3][BF-ANTENNA-4][SOUNDING-DIMENSION-2][SOUNDING-DIMENSION-3][SOUNDING-DIMENSION-4][MU-BEAMFORMER][VHT-TXOP-PS][HTC-VHT][MAX-A-MPDU-LEN-EXP0][MAX-A-MPDU-LEN-EXP7][VHT-LINK-ADAPT2][VHT-LINK-ADAPT3][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN]", - "vht_oper_centr_freq_seg0_idx": "42", - "require_vht": "1" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_capab": "[MAX-MPDU-7991][MAX-MPDU-11454][VHT160][VHT160-80PLUS80][RXLDPC][SHORT-GI-80][SHORT-GI-160][TX-STBC-2BY1][RX-STBC-1][RX-STBC-12][RX-STBC-123][RX-STBC-1234][SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][BF-ANTENNA-3][BF-ANTENNA-4][SOUNDING-DIMENSION-2][SOUNDING-DIMENSION-3][SOUNDING-DIMENSION-4][MU-BEAMFORMER][VHT-TXOP-PS][HTC-VHT][MAX-A-MPDU-LEN-EXP0][MAX-A-MPDU-LEN-EXP7][VHT-LINK-ADAPT2][VHT-LINK-ADAPT3][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN]", + "vht_oper_centr_freq_seg0_idx": "42", + "require_vht": "1"} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = hapd.wait_event(["AP-DISABLED"], timeout=5) if ev is None: @@ -369,17 +367,17 @@ def test_ap_vht160(dev, apdev): """VHT with 160 MHz channel width (1)""" try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "vht_oper_centr_freq_seg0_idx": "50", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "vht_oper_centr_freq_seg0_idx": "50", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = wait_dfs_event(hapd, "DFS-CAC-START", 5) @@ -439,17 +437,17 @@ def test_ap_vht160b(dev, apdev): try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "104", - "ht_capab": "[HT40-]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "vht_oper_centr_freq_seg0_idx": "114", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "104", + "ht_capab": "[HT40-]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "vht_oper_centr_freq_seg0_idx": "114", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[1], params, wait_enabled=False) ev = wait_dfs_event(hapd, "DFS-CAC-START", 5) @@ -543,17 +541,17 @@ def test_ap_vht160_no_dfs_128_minus(dev, apdev): def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab): try: hapd = None - params = { "ssid": "vht", - "country_code": "ZA", - "hw_mode": "a", - "channel": channel, - "ht_capab": ht_capab, - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "vht_oper_centr_freq_seg0_idx": "114", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "ZA", + "hw_mode": "a", + "channel": channel, + "ht_capab": ht_capab, + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "vht_oper_centr_freq_seg0_idx": "114", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = hapd.wait_event(["AP-ENABLED"], timeout=2) if not ev: @@ -592,17 +590,17 @@ def test_ap_vht160_no_ht40(dev, apdev): """VHT with 160 MHz channel width and HT40 disabled""" try: hapd = None - params = { "ssid": "vht", - "country_code": "ZA", - "hw_mode": "a", - "channel": "108", - "ht_capab": "", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "vht_oper_centr_freq_seg0_idx": "114", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "ZA", + "hw_mode": "a", + "channel": "108", + "ht_capab": "", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "vht_oper_centr_freq_seg0_idx": "114", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=2) if not ev: @@ -631,33 +629,33 @@ def test_ap_vht80plus80(dev, apdev): try: hapd = None hapd2 = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "52", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "3", - "vht_oper_centr_freq_seg0_idx": "58", - "vht_oper_centr_freq_seg1_idx": "155", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "52", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "3", + "vht_oper_centr_freq_seg0_idx": "58", + "vht_oper_centr_freq_seg1_idx": "155", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) # This will actually fail since DFS on 80+80 is not yet supported ev = hapd.wait_event(["AP-DISABLED"], timeout=5) # ignore result to avoid breaking the test once 80+80 DFS gets enabled - params = { "ssid": "vht2", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "3", - "vht_oper_centr_freq_seg0_idx": "42", - "vht_oper_centr_freq_seg1_idx": "155" } + params = {"ssid": "vht2", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "3", + "vht_oper_centr_freq_seg0_idx": "42", + "vht_oper_centr_freq_seg1_idx": "155"} hapd2 = hostapd.add_ap(apdev[1], params, wait_enabled=False) ev = hapd2.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=5) @@ -702,18 +700,18 @@ def test_ap_vht80plus80_invalid(dev, apdev): """VHT with invalid 80+80 MHz channel""" try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "3", - "vht_oper_centr_freq_seg0_idx": "42", - "vht_oper_centr_freq_seg1_idx": "0", - 'ieee80211d': '1', - 'ieee80211h': '1' } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "3", + "vht_oper_centr_freq_seg0_idx": "42", + "vht_oper_centr_freq_seg1_idx": "0", + 'ieee80211d': '1', + 'ieee80211h': '1'} hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False) # This fails due to missing(invalid) seg1 configuration ev = hapd.wait_event(["AP-DISABLED"], timeout=5) @@ -735,15 +733,15 @@ def test_ap_vht80_csa(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "149", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "155" } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "149", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "155"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("vht", key_mgmt="NONE", scan_freq="5745") @@ -788,13 +786,13 @@ def test_ap_vht_csa_vht40(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "149", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "0" } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "149", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "0"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -836,13 +834,13 @@ def test_ap_vht_csa_vht20(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "149", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "0" } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "149", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "0"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -877,16 +875,16 @@ def test_ap_vht_csa_vht40_disable(dev, apdev): csa_supported(dev[0]) try: hapd = None - params = { "ssid": "vht", - "country_code": "US", - "hw_mode": "a", - "channel": "149", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_capab": "", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "0" } + params = {"ssid": "vht", + "country_code": "US", + "hw_mode": "a", + "channel": "149", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_capab": "", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "0"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -924,15 +922,14 @@ def test_ap_vht_csa_vht40_disable(dev, apdev): def test_ap_vht_on_24ghz(dev, apdev): """Subset of VHT features on 2.4 GHz""" hapd = None - params = { "ssid": "test-vht-2g", - "hw_mode": "g", - "channel": "1", - "ieee80211n": "1", - "vendor_vht": "1", - "vht_capab": "[MAX-MPDU-11454]", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "1" - } + params = {"ssid": "test-vht-2g", + "hw_mode": "g", + "channel": "1", + "ieee80211n": "1", + "vendor_vht": "1", + "vht_capab": "[MAX-MPDU-11454]", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "1"} hapd = hostapd.add_ap(apdev[0], params) try: if "OK" not in dev[0].request("VENDOR_ELEM_ADD 13 dd1300904c0400bf0c3240820feaff0000eaff0000"): @@ -955,26 +952,25 @@ def test_prefer_vht40(dev, apdev): try: hapd2 = None - params = { "ssid": "test", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ieee80211n": "1", - "ht_capab": "[HT40+]" } + params = {"ssid": "test", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ieee80211n": "1", + "ht_capab": "[HT40+]"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - params = { "ssid": "test", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ieee80211n": "1", - "ieee80211ac": "1", - "ht_capab": "[HT40+]", - "vht_capab": "", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "0", - } + params = {"ssid": "test", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ieee80211n": "1", + "ieee80211ac": "1", + "ht_capab": "[HT40+]", + "vht_capab": "", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "0"} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] @@ -1002,17 +998,17 @@ def test_ap_vht80_pwr_constraint(dev, apdev): """VHT with 80 MHz channel width and local power constraint""" hapd = None try: - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211d": "1", - "local_pwr_constraint": "3", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211d": "1", + "local_pwr_constraint": "3", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") @@ -1036,16 +1032,16 @@ def test_ap_vht_use_sta_nsts(dev, apdev): """VHT with 80 MHz channel width and use_sta_nsts=1""" try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42", - "use_sta_nsts": "1" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42", + "use_sta_nsts": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] @@ -1067,19 +1063,19 @@ def test_ap_vht_tkip(dev, apdev): """VHT and TKIP""" try: hapd = None - params = { "ssid": "vht", - "wpa": "1", - "wpa_key_mgmt": "WPA-PSK", - "wpa_pairwise": "TKIP", - "wpa_passphrase": "12345678", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "vht", + "wpa": "1", + "wpa_key_mgmt": "WPA-PSK", + "wpa_pairwise": "TKIP", + "wpa_passphrase": "12345678", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] @@ -1116,20 +1112,19 @@ def test_ap_vht_40_fallback_to_20(devs, apdevs): ap = apdevs[0] try: hapd = None - params = { "ssid": "test-vht40", - "country_code": "US", - "hw_mode": "a", - "basic_rates": "60 120 240", - "channel": "161", - "ieee80211d": "1", - "ieee80211h": "1", - "ieee80211n": "1", - "ieee80211ac": "1", - "ht_capab": "[HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]", - "vht_capab": "[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC1][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]", - "vht_oper_chwidth": "0", - "vht_oper_centr_freq_seg0_idx": "155", - } + params = {"ssid": "test-vht40", + "country_code": "US", + "hw_mode": "a", + "basic_rates": "60 120 240", + "channel": "161", + "ieee80211d": "1", + "ieee80211h": "1", + "ieee80211n": "1", + "ieee80211ac": "1", + "ht_capab": "[HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]", + "vht_capab": "[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC1][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]", + "vht_oper_chwidth": "0", + "vht_oper_centr_freq_seg0_idx": "155"} hapd = hostapd.add_ap(ap, params) dev.connect("test-vht40", scan_freq="5805", key_mgmt="NONE") dev.wait_regdom(country_ie=True) @@ -1148,16 +1143,16 @@ def test_ap_vht80_to_24g_ht(dev, apdev): """VHT with 80 MHz channel width reconfigured to 2.4 GHz HT""" try: hapd = None - params = { "ssid": "vht", - "country_code": "FI", - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_capab": "[MAX-MPDU-11454]", - "vht_oper_centr_freq_seg0_idx": "42" } + params = {"ssid": "vht", + "country_code": "FI", + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_capab": "[MAX-MPDU-11454]", + "vht_oper_centr_freq_seg0_idx": "42"} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] diff --git a/tests/hwsim/test_ap_vlan.py b/tests/hwsim/test_ap_vlan.py index 513273e..04bec3c 100644 --- a/tests/hwsim/test_ap_vlan.py +++ b/tests/hwsim/test_ap_vlan.py @@ -26,9 +26,9 @@ from tshark import run_tshark def test_ap_vlan_open(dev, apdev): """AP VLAN with open network""" - params = { "ssid": "test-vlan-open", - "dynamic_vlan": "1", - "accept_mac_file": "hostapd.accept" } + params = {"ssid": "test-vlan-open", + "dynamic_vlan": "1", + "accept_mac_file": "hostapd.accept"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") @@ -40,10 +40,10 @@ def test_ap_vlan_open(dev, apdev): def test_ap_vlan_file_open(dev, apdev): """AP VLAN with open network and vlan_file mapping""" - params = { "ssid": "test-vlan-open", - "dynamic_vlan": "1", - "vlan_file": "hostapd.vlan", - "accept_mac_file": "hostapd.accept" } + params = {"ssid": "test-vlan-open", + "dynamic_vlan": "1", + "vlan_file": "hostapd.vlan", + "accept_mac_file": "hostapd.accept"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") @@ -55,10 +55,10 @@ def test_ap_vlan_file_open(dev, apdev): def test_ap_vlan_file_open2(dev, apdev): """AP VLAN with open network and vlan_file mapping (2)""" - params = { "ssid": "test-vlan-open", - "dynamic_vlan": "1", - "vlan_file": "hostapd.vlan2", - "accept_mac_file": "hostapd.accept2" } + params = {"ssid": "test-vlan-open", + "dynamic_vlan": "1", + "vlan_file": "hostapd.vlan2", + "accept_mac_file": "hostapd.accept2"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") @@ -71,12 +71,12 @@ def test_ap_vlan_file_open2(dev, apdev): def test_ap_vlan_file_parsing(dev, apdev, params): """hostapd vlan_file/mac_file parsing""" tmp = os.path.join(params['logdir'], 'ap_vlan_file_parsing.tmp') - params = { "ssid": "test-vlan-open", "dynamic_vlan": "1" } + params = {"ssid": "test-vlan-open", "dynamic_vlan": "1"} hapd = hostapd.add_ap(apdev[0], params) - tests = [ "#\n\n0\t11\n", - "* ", - "1 netdev12345678901234567890" ] + tests = ["#\n\n0\t11\n", + "* ", + "1 netdev12345678901234567890"] for t in tests: with open(tmp, "w") as f: f.write(t) @@ -89,11 +89,11 @@ def test_ap_vlan_file_parsing(dev, apdev, params): if "FAIL" not in hapd.request("SET vlan_file " + tmp): raise Exception("vlan_file accepted during OOM") - tests = [ "#\n\n0\tvlan\n", - "4095\tvlan\n", - "vlan\n", - "1\t1234567890abcdef1234567890\n", - "1\n" ] + tests = ["#\n\n0\tvlan\n", + "4095\tvlan\n", + "vlan\n", + "1\t1234567890abcdef1234567890\n", + "1\n"] for t in tests: with open(tmp, "w") as f: f.write(t) @@ -207,15 +207,15 @@ def test_ap_vlan_tagged_wpa2_radius_id_change(dev, apdev): subprocess.call(['ip', 'link', 'del', ifname2]) def generic_ap_vlan_wpa2_radius_id_change(dev, apdev, tagged): - as_params = { "ssid": "as", - "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key" } + as_params = {"ssid": "as", + "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key"} authserv = hostapd.add_ap(apdev[1], as_params) params = hostapd.wpa2_eap_params(ssid="test-vlan") @@ -328,10 +328,10 @@ def test_ap_vlan_wpa2_radius_required(dev, apdev): def test_ap_vlan_tagged(dev, apdev): """AP VLAN with tagged interface""" - params = { "ssid": "test-vlan-open", - "dynamic_vlan": "1", - "vlan_tagged_interface": "lo", - "accept_mac_file": "hostapd.accept" } + params = {"ssid": "test-vlan-open", + "dynamic_vlan": "1", + "vlan_tagged_interface": "lo", + "accept_mac_file": "hostapd.accept"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") @@ -344,8 +344,8 @@ def test_ap_vlan_tagged(dev, apdev): def ap_vlan_iface_cleanup_multibss_cleanup(): subprocess.call(['ifconfig', 'dummy0', 'down'], stderr=open('/dev/null', 'w')) - ifnames = [ 'wlan3.1', 'wlan3.2', 'wlan3-2.1', 'wlan3-2.2', 'dummy0.2', - 'dummy0.1', 'dummy0', 'brvlan1', 'brvlan2' ] + ifnames = ['wlan3.1', 'wlan3.2', 'wlan3-2.1', 'wlan3-2.2', 'dummy0.2', + 'dummy0.1', 'dummy0', 'brvlan1', 'brvlan2'] for ifname in ifnames: subprocess.call(['ip', 'link', 'del', ifname], stderr=open('/dev/null', 'w')) @@ -394,16 +394,16 @@ def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile): ap_vlan_iface_cleanup_multibss_cleanup() ap_vlan_iface_test_and_prepare_environ() - as_params = { "ssid": "as", - "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key", - "vlan_naming": "1" } + as_params = {"ssid": "as", + "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key", + "vlan_naming": "1"} authserv = hostapd.add_ap(apdev[1], as_params) # start the actual test @@ -616,8 +616,8 @@ def test_ap_vlan_without_station(dev, apdev, p): @remote_compatible def test_ap_open_per_sta_vif(dev, apdev): """AP VLAN with open network""" - params = { "ssid": "test-vlan-open", - "per_sta_vif": "1" } + params = {"ssid": "test-vlan-open", + "per_sta_vif": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") @@ -627,9 +627,9 @@ def test_ap_open_per_sta_vif(dev, apdev): @remote_compatible def test_ap_vlan_open_per_sta_vif(dev, apdev): """AP VLAN (dynamic) with open network""" - params = { "ssid": "test-vlan-open", - "per_sta_vif": "1", - "dynamic_vlan": "1" } + params = {"ssid": "test-vlan-open", + "per_sta_vif": "1", + "dynamic_vlan": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412") @@ -738,9 +738,9 @@ def test_ap_vlan_sae(dev, apdev, params): raise HwsimSkip("SAE not supported") params = hostapd.wpa2_params(ssid="test-sae-vlan") params['wpa_key_mgmt'] = 'SAE' - params['sae_password'] = [ 'pw1|vlanid=1|id=id1', - 'pw2|mac=ff:ff:ff:ff:ff:ff|vlanid=2|id=id2', - 'pw3|vlanid=3|id=id3' ] + params['sae_password'] = ['pw1|vlanid=1|id=id1', + 'pw2|mac=ff:ff:ff:ff:ff:ff|vlanid=2|id=id2', + 'pw3|vlanid=3|id=id3'] params['dynamic_vlan'] = "1" hapd = hostapd.add_ap(apdev[0], params) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index f0f852b..df408f1 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -45,9 +45,9 @@ from utils import wait_fail_trigger from test_ap_eap import int_eap_server_params def wps_start_ap(apdev, 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" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"} return hostapd.add_ap(apdev, params) @remote_compatible @@ -55,7 +55,7 @@ def test_ap_wps_init(dev, apdev): """Initial AP configuration with first WPS Enrollee""" ssid = "test-wps" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1"}) logger.info("WPS provisioning step") hapd.request("WPS_PBC") if "PBC Status: Active" not in hapd.request("WPS_GET_STATUS"): @@ -109,7 +109,7 @@ def test_ap_wps_init(dev, apdev): def test_ap_wps_init_2ap_pbc(dev, apdev): """Initial two-radio AP configuration with first WPS PBC Enrollee""" ssid = "test-wps" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "1"} hapd = hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[1], params) logger.info("WPS provisioning step") @@ -145,7 +145,7 @@ def test_ap_wps_init_2ap_pbc(dev, apdev): def test_ap_wps_init_2ap_pin(dev, apdev): """Initial two-radio AP configuration with first WPS PIN Enrollee""" ssid = "test-wps" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "1"} hapd = hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[1], params) logger.info("WPS provisioning step") @@ -177,7 +177,7 @@ def test_ap_wps_init_through_wps_config(dev, apdev): """Initial AP configuration using wps_config command""" ssid = "test-wps-init-config" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1"}) if "FAIL" in hapd.request("WPS_CONFIG " + binascii.hexlify(ssid.encode()).decode() + " WPA2PSK CCMP " + binascii.hexlify(b"12345678").decode()): raise Exception("WPS_CONFIG command failed") ev = hapd.wait_event(["WPS-NEW-AP-SETTINGS"], timeout=5) @@ -199,8 +199,8 @@ def test_ap_wps_init_through_wps_config_2(dev, apdev): """AP configuration using wps_config and wps_cred_processing=2""" ssid = "test-wps-init-config" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1", - "wps_cred_processing": "2" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1", + "wps_cred_processing": "2"}) if "FAIL" in hapd.request("WPS_CONFIG " + binascii.hexlify(ssid.encode()).decode() + " WPA2PSK CCMP " + binascii.hexlify(b"12345678").decode()): raise Exception("WPS_CONFIG command failed") ev = hapd.wait_event(["WPS-NEW-AP-SETTINGS"], timeout=5) @@ -214,7 +214,7 @@ def test_ap_wps_invalid_wps_config_passphrase(dev, apdev): """AP configuration using wps_config command with invalid passphrase""" ssid = "test-wps-init-config" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1"}) if "FAIL" not in hapd.request("WPS_CONFIG " + binascii.hexlify(ssid.encode()).decode() + " WPA2PSK CCMP " + binascii.hexlify(b"1234567").decode()): raise Exception("Invalid WPS_CONFIG command accepted") @@ -222,9 +222,9 @@ def test_ap_wps_conf(dev, apdev): """WPS PBC provisioning with configured AP""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -252,10 +252,10 @@ def test_ap_wps_conf_5ghz(dev, apdev): try: hapd = None 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" } + 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], params) logger.info("WPS provisioning step") hapd.request("WPS_PBC") @@ -278,10 +278,10 @@ def test_ap_wps_conf_chan14(dev, apdev): try: hapd = None 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" } + 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], params) logger.info("WPS provisioning step") hapd.request("WPS_PBC") @@ -302,9 +302,9 @@ def test_ap_wps_conf_chan14(dev, apdev): def test_ap_wps_twice(dev, apdev): """WPS provisioning with twice to change passphrase""" ssid = "test-wps-twice" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) logger.info("WPS provisioning step") hapd.request("WPS_PBC") @@ -332,9 +332,9 @@ def test_ap_wps_incorrect_pin(dev, apdev): """WPS PIN provisioning with incorrect PIN""" ssid = "test-wps-incorrect-pin" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning attempt 1") hapd.request("WPS_PIN any 12345670") @@ -375,9 +375,9 @@ def test_ap_wps_conf_pin(dev, apdev): """WPS PIN provisioning with configured AP""" ssid = "test-wps-conf-pin" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -401,7 +401,7 @@ def test_ap_wps_conf_pin(dev, apdev): raise Exception("WPS-AUTH flag not cleared") logger.info("Try to connect from another station using the same PIN") pin = dev[1].request("WPS_PIN " + apdev[0]['bssid']) - ev = dev[1].wait_event(["WPS-M2D","CTRL-EVENT-CONNECTED"], timeout=30) + ev = dev[1].wait_event(["WPS-M2D", "CTRL-EVENT-CONNECTED"], timeout=30) if ev is None: raise Exception("Operation timed out") if "WPS-M2D" not in ev: @@ -413,10 +413,10 @@ def test_ap_wps_conf_pin_mixed_mode(dev, apdev): """WPS PIN provisioning with configured AP (WPA+WPA2)""" ssid = "test-wps-conf-pin-mixed" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "3", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wpa_pairwise": "TKIP" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "3", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wpa_pairwise": "TKIP"}) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() @@ -471,9 +471,9 @@ def test_ap_wps_conf_pin_v1(dev, apdev): """WPS PIN provisioning with configured WPS v1.0 AP""" ssid = "test-wps-conf-pin-v1" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("SET wps_version_number 0x10") @@ -497,9 +497,9 @@ def test_ap_wps_conf_pin_2sta(dev, apdev): """Two stations trying to use WPS PIN at the same time""" ssid = "test-wps-conf-pin2" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") pin = "12345670" pin2 = "55554444" @@ -519,9 +519,9 @@ def test_ap_wps_conf_pin_timeout(dev, apdev): """WPS PIN provisioning with configured AP timing out PIN""" ssid = "test-wps-conf-pin" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) addr = dev[0].p2p_interface_addr() pin = dev[0].wps_read_pin() if "FAIL" not in hapd.request("WPS_PIN "): @@ -547,10 +547,10 @@ def test_ap_wps_reg_connect(dev, apdev): ssid = "test-wps-reg-ap-pin" appin = "12345670" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin}) logger.info("WPS provisioning step") dev[0].dump_monitor() dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -570,10 +570,10 @@ def test_ap_wps_reg_connect_zero_len_ap_pin(dev, apdev): ssid = "test-wps-reg-ap-pin" appin = "" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin}) logger.info("WPS provisioning step") dev[0].dump_monitor() dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -589,10 +589,10 @@ def test_ap_wps_reg_connect_mixed_mode(dev, apdev): ssid = "test-wps-reg-ap-pin" appin = "12345670" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "3", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wpa_pairwise": "TKIP", "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "3", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wpa_pairwise": "TKIP", "ap_pin": appin}) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], appin) status = dev[0].get_status() @@ -624,11 +624,11 @@ def test_ap_wps_reg_override_ap_settings(dev, apdev): ssid = "test-wps-reg-ap-pin" appin = "12345670" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin, "ap_settings": ap_settings }) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "test" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin, "ap_settings": ap_settings}) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "test"}) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].scan_for_bss(apdev[1]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], appin) @@ -651,15 +651,15 @@ def test_ap_wps_random_ap_pin(dev, apdev): """WPS registrar using random AP PIN""" ssid = "test-wps-reg-random-ap-pin" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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", - "uuid": ap_uuid, "upnp_iface": "lo" } + params = {"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", + "uuid": ap_uuid, "upnp_iface": "lo"} hapd = hostapd.add_ap(apdev[0], params) appin = hapd.request("WPS_AP_PIN random") if "FAIL" in appin: @@ -719,8 +719,8 @@ def test_ap_wps_reg_config(dev, apdev): ssid = "test-wps-init-ap-pin" appin = "12345670" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "ap_pin": appin}) logger.info("WPS configuration step") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].dump_monitor() @@ -755,8 +755,8 @@ def test_ap_wps_reg_config_ext_processing(dev, apdev): """WPS registrar configuring an AP with external config processing""" ssid = "test-wps-init-ap-pin" appin = "12345670" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wps_cred_processing": "1", "ap_pin": appin} + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wps_cred_processing": "1", "ap_pin": appin} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) new_ssid = "wps-new-ssid" @@ -782,8 +782,8 @@ def test_ap_wps_reg_config_tkip(dev, apdev): ssid = "test-wps-init-ap" appin = "12345670" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "1", + "ap_pin": appin}) logger.info("WPS configuration step") dev[0].request("SET wps_version_number 0x10") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -813,15 +813,15 @@ def test_ap_wps_setup_locked(dev, apdev): ssid = "test-wps-incorrect-ap-pin" appin = "12345670" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin}) new_ssid = "wps-new-ssid-test" new_passphrase = "1234567890" dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) - ap_setup_locked=False + ap_setup_locked = False for pin in ["55554444", "1234", "12345678", "00000000", "11111111"]: dev[0].dump_monitor() logger.info("Try incorrect AP PIN - attempt " + pin) @@ -834,7 +834,7 @@ def test_ap_wps_setup_locked(dev, apdev): raise Exception("Unexpected connection") if "config_error=15" in ev: logger.info("AP Setup Locked") - ap_setup_locked=True + ap_setup_locked = True elif "config_error=18" not in ev: raise Exception("config_error=18 not reported") dev[0].wait_disconnected(timeout=10) @@ -878,15 +878,15 @@ def test_ap_wps_setup_locked_timeout(dev, apdev): ssid = "test-wps-incorrect-ap-pin" appin = "12345670" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin}) new_ssid = "wps-new-ssid-test" new_passphrase = "1234567890" dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) - ap_setup_locked=False + ap_setup_locked = False for pin in ["55554444", "1234", "12345678", "00000000", "11111111"]: dev[0].dump_monitor() logger.info("Try incorrect AP PIN - attempt " + pin) @@ -899,7 +899,7 @@ def test_ap_wps_setup_locked_timeout(dev, apdev): raise Exception("Unexpected connection") if "config_error=15" in ev: logger.info("AP Setup Locked") - ap_setup_locked=True + ap_setup_locked = True break elif "config_error=18" not in ev: raise Exception("config_error=18 not reported") @@ -915,10 +915,10 @@ def test_ap_wps_setup_locked_2(dev, apdev): """WPS AP configured for special ap_setup_locked=2 mode""" ssid = "test-wps-ap-pin" appin = "12345670" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin, "ap_setup_locked": "2" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin, "ap_setup_locked": "2"} hapd = hostapd.add_ap(apdev[0], params) new_ssid = "wps-new-ssid-test" new_passphrase = "1234567890" @@ -952,15 +952,15 @@ def test_ap_wps_setup_locked_2(dev, apdev): @remote_compatible def test_ap_wps_pbc_overlap_2ap(dev, apdev): """WPS PBC session overlap with two active APs""" - params = { "ssid": "wps1", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wps_independent": "1"} + params = {"ssid": "wps1", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_independent": "1"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "wps2", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "123456789", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wps_independent": "1"} + params = {"ssid": "wps2", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "123456789", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_independent": "1"} hapd2 = hostapd.add_ap(apdev[1], params) hapd.request("WPS_PBC") hapd2.request("WPS_PBC") @@ -980,9 +980,9 @@ def test_ap_wps_pbc_overlap_2sta(dev, apdev): """WPS PBC session overlap with two active STAs""" ssid = "test-wps-pbc-overlap" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -1018,9 +1018,9 @@ def test_ap_wps_cancel(dev, apdev): """WPS AP cancelling enabled config method""" ssid = "test-wps-ap-cancel" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) bssid = apdev[0]['bssid'] logger.info("Verify PBC enable/cancel") @@ -1065,14 +1065,14 @@ def _test_ap_wps_er_add_enrollee(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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", - 'friendly_name': "WPS AP - <>&'\" - TEST", - "config_methods": "label push_button", - "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) + {"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", + 'friendly_name': "WPS AP - <>&'\" - TEST", + "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() @@ -1198,15 +1198,15 @@ def _test_ap_wps_er_add_enrollee_uuid(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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"}) + {"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("WPS configuration step") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1290,16 +1290,16 @@ def _test_ap_wps_er_multi_add_enrollee(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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", - 'friendly_name': "WPS AP", - "config_methods": "label push_button", - "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) + {"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", + 'friendly_name': "WPS AP", + "config_methods": "label push_button", + "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) for i in range(2): dev[i].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -1350,15 +1350,15 @@ def _test_ap_wps_er_add_enrollee_pbc(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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"}) + {"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].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].dump_monitor() @@ -1421,15 +1421,15 @@ def _test_ap_wps_er_pbc_overlap(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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"}) + {"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"}) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].dump_monitor() dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1496,15 +1496,15 @@ def _test_ap_wps_er_v10_add_enrollee_pin(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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"}) + {"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].request("SET wps_version_number 0x10") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -1551,15 +1551,15 @@ def _test_ap_wps_er_config_ap(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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"}) + {"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("Connect ER to the AP") dev[0].connect(ssid, psk="12345678", scan_freq="2412") @@ -1605,15 +1605,15 @@ def _test_ap_wps_er_cache_ap_settings(dev, apdev): ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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" } + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1640,15 +1640,14 @@ def _test_ap_wps_er_cache_ap_settings(dev, apdev): hapd.disable() for i in range(2): - ev = dev[0].wait_event([ "WPS-ER-AP-REMOVE", - "CTRL-EVENT-DISCONNECTED" ], + ev = dev[0].wait_event(["WPS-ER-AP-REMOVE", "CTRL-EVENT-DISCONNECTED"], timeout=15) if ev is None: raise Exception("AP removal or disconnection timed out") hapd = hostapd.add_ap(apdev[0], params) for i in range(2): - ev = dev[0].wait_event([ "WPS-ER-AP-ADD", "CTRL-EVENT-CONNECTED" ], + ev = dev[0].wait_event(["WPS-ER-AP-ADD", "CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("AP discovery or connection timed out") @@ -1684,15 +1683,15 @@ def _test_ap_wps_er_cache_ap_settings_oom(dev, apdev): ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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" } + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1720,15 +1719,15 @@ def _test_ap_wps_er_cache_ap_settings_oom(dev, apdev): hapd.disable() for i in range(2): - ev = dev[0].wait_event([ "WPS-ER-AP-REMOVE", - "CTRL-EVENT-DISCONNECTED" ], + ev = dev[0].wait_event(["WPS-ER-AP-REMOVE", + "CTRL-EVENT-DISCONNECTED"], timeout=15) if ev is None: raise Exception("AP removal or disconnection timed out") hapd = hostapd.add_ap(apdev[0], params) for i in range(2): - ev = dev[0].wait_event([ "WPS-ER-AP-ADD", "CTRL-EVENT-CONNECTED" ], + ev = dev[0].wait_event(["WPS-ER-AP-ADD", "CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("AP discovery or connection timed out") @@ -1746,15 +1745,15 @@ def _test_ap_wps_er_cache_ap_settings_oom2(dev, apdev): ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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" } + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1782,15 +1781,15 @@ def _test_ap_wps_er_cache_ap_settings_oom2(dev, apdev): hapd.disable() for i in range(2): - ev = dev[0].wait_event([ "WPS-ER-AP-REMOVE", - "CTRL-EVENT-DISCONNECTED" ], + ev = dev[0].wait_event(["WPS-ER-AP-REMOVE", + "CTRL-EVENT-DISCONNECTED"], timeout=15) if ev is None: raise Exception("AP removal or disconnection timed out") hapd = hostapd.add_ap(apdev[0], params) for i in range(2): - ev = dev[0].wait_event([ "WPS-ER-AP-ADD", "CTRL-EVENT-CONNECTED" ], + ev = dev[0].wait_event(["WPS-ER-AP-ADD", "CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("AP discovery or connection timed out") @@ -1808,15 +1807,15 @@ def _test_ap_wps_er_subscribe_oom(dev, apdev): ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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" } + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1847,15 +1846,15 @@ def _test_ap_wps_er_set_sel_reg_oom(dev, apdev): ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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" } + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1874,10 +1873,10 @@ def _test_ap_wps_er_set_sel_reg_oom(dev, apdev): raise Exception("WPS-FAIL timed out") time.sleep(0.1) - for func in [ "http_client_url_parse;wps_er_send_set_sel_reg", - "wps_er_soap_hdr;wps_er_send_set_sel_reg", - "http_client_addr;wps_er_send_set_sel_reg", - "wpabuf_alloc;wps_er_set_sel_reg" ]: + for func in ["http_client_url_parse;wps_er_send_set_sel_reg", + "wps_er_soap_hdr;wps_er_send_set_sel_reg", + "http_client_addr;wps_er_send_set_sel_reg", + "wpabuf_alloc;wps_er_set_sel_reg"]: with alloc_fail(dev[0], 1, func): if "OK" not in dev[0].request("WPS_ER_PBC " + ap_uuid): raise Exception("WPS_ER_PBC failed") @@ -1899,15 +1898,15 @@ def _test_ap_wps_er_learn_oom(dev, apdev): ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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" } + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], ap_pin) @@ -1917,11 +1916,11 @@ def _test_ap_wps_er_learn_oom(dev, apdev): if ev is None: raise Exception("AP not discovered") - for func in [ "wps_er_http_put_message_cb", - "xml_get_base64_item;wps_er_http_put_message_cb", - "http_client_url_parse;wps_er_ap_put_message", - "wps_er_soap_hdr;wps_er_ap_put_message", - "http_client_addr;wps_er_ap_put_message" ]: + for func in ["wps_er_http_put_message_cb", + "xml_get_base64_item;wps_er_http_put_message_cb", + "http_client_url_parse;wps_er_ap_put_message", + "wps_er_soap_hdr;wps_er_ap_put_message", + "http_client_addr;wps_er_ap_put_message"]: with alloc_fail(dev[0], 1, func): dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin) ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=1) @@ -1943,11 +1942,11 @@ def test_ap_wps_fragmentation(dev, apdev): ssid = "test-wps-fragmentation" appin = "12345670" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "3", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wpa_pairwise": "TKIP", "ap_pin": appin, - "fragment_size": "50" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "3", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wpa_pairwise": "TKIP", "ap_pin": appin, + "fragment_size": "50"}) logger.info("WPS provisioning step (PBC)") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -1995,9 +1994,9 @@ def test_ap_wps_new_version_sta(dev, apdev): """WPS compatibility with new version number on the station""" ssid = "test-wps-ver" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -2012,9 +2011,9 @@ def test_ap_wps_new_version_ap(dev, apdev): """WPS compatibility with new version number on the AP""" ssid = "test-wps-ver" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") if "FAIL" in hapd.request("SET wps_version_number 0x43"): raise Exception("Failed to enable test functionality") @@ -2029,16 +2028,16 @@ def test_ap_wps_new_version_ap(dev, apdev): def test_ap_wps_check_pin(dev, apdev): """Verify PIN checking through control interface""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "wps", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) - for t in [ ("12345670", "12345670"), - ("12345678", "FAIL-CHECKSUM"), - ("12345", "FAIL"), - ("123456789", "FAIL"), - ("1234-5670", "12345670"), - ("1234 5670", "12345670"), - ("1-2.3:4 5670", "12345670") ]: + {"ssid": "wps", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + for t in [("12345670", "12345670"), + ("12345678", "FAIL-CHECKSUM"), + ("12345", "FAIL"), + ("123456789", "FAIL"), + ("1234-5670", "12345670"), + ("1234 5670", "12345670"), + ("1-2.3:4 5670", "12345670")]: res = hapd.request("WPS_CHECK_PIN " + t[0]).rstrip('\n') res2 = dev[0].request("WPS_CHECK_PIN " + t[0]).rstrip('\n') if res != res2: @@ -2069,8 +2068,8 @@ def test_ap_wps_wep_config(dev, apdev): ssid = "test-wps-config" appin = "12345670" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "ap_pin": appin}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "ap_pin": appin}) dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) dev[0].wps_reg(apdev[0]['bssid'], appin, "wps-new-ssid-wep", "OPEN", "WEP", "hello", no_wait=True) @@ -2090,8 +2089,8 @@ def test_ap_wps_wep_config(dev, apdev): def test_ap_wps_wep_enroll(dev, apdev): """WPS 2.0 STA rejecting WEP configuration""" ssid = "test-wps-wep" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "skip_cred_build": "1", "extra_cred": "wps-wep-cred" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "skip_cred_build": "1", "extra_cred": "wps-wep-cred"} hapd = hostapd.add_ap(apdev[0], params) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) @@ -2106,14 +2105,14 @@ def test_ap_wps_wep_enroll(dev, apdev): def test_ap_wps_ie_fragmentation(dev, apdev): """WPS AP using fragmented WPS IE""" ssid = "test-wps-ie-fragmentation" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "device_name": "1234567890abcdef1234567890abcdef", - "manufacturer": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", - "model_name": "1234567890abcdef1234567890abcdef", - "model_number": "1234567890abcdef1234567890abcdef", - "serial_number": "1234567890abcdef1234567890abcdef" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "device_name": "1234567890abcdef1234567890abcdef", + "manufacturer": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", + "model_name": "1234567890abcdef1234567890abcdef", + "model_number": "1234567890abcdef1234567890abcdef", + "serial_number": "1234567890abcdef1234567890abcdef"} hapd = hostapd.add_ap(apdev[0], params) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -2142,7 +2141,7 @@ def get_psk(pskfile): for l in lines: if l == "# WPA PSKs": continue - (addr,psk) = l.split(' ') + (addr, psk) = l.split(' ') psks[addr] = psk return psks @@ -2164,10 +2163,10 @@ def test_ap_wps_per_station_psk(dev, apdev): with open(pskfile, "w") as f: f.write("# WPA PSKs\n") - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa": "2", "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "CCMP", "ap_pin": appin, - "wpa_psk_file": pskfile } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa": "2", "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "CCMP", "ap_pin": appin, + "wpa_psk_file": pskfile} hapd = hostapd.add_ap(apdev[0], params) logger.info("First enrollee") @@ -2239,10 +2238,10 @@ def test_ap_wps_per_station_psk_failure(dev, apdev): with open(pskfile, "w") as f: f.write("# WPA PSKs\n") - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa": "2", "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": "CCMP", "ap_pin": appin, - "wpa_psk_file": pskfile } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa": "2", "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": "CCMP", "ap_pin": appin, + "wpa_psk_file": pskfile} hapd = hostapd.add_ap(apdev[0], params) if "FAIL" in hapd.request("SET wpa_psk_file /tmp/does/not/exists/ap_wps_per_enrollee_psk_failure.psk_file"): raise Exception("Failed to set wpa_psk_file") @@ -2283,10 +2282,10 @@ def test_ap_wps_pin_request_file(dev, apdev): if os.path.exists(pinfile): os.remove(pinfile) hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wps_pin_requests": pinfile, - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wps_pin_requests": pinfile, + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) uuid = dev[0].get_status_field("uuid") pin = dev[0].wps_read_pin() try: @@ -2338,7 +2337,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev): vals = dict() for l in lines: try: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value except ValueError as e: if "# WPS configuration" in l: @@ -2377,9 +2376,9 @@ def test_ap_wps_pbc_timeout(dev, apdev, params): server = MyTCPServer(("127.0.0.1", 12345), WPSERHTTPServer) server.timeout = 1 - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -2397,7 +2396,7 @@ VFi5hrLk ''' - headers = { "Content-type": 'text/xml; charset="utf-8"' } + headers = {"Content-type": 'text/xml; charset="utf-8"'} headers["SOAPAction"] = '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1#%s"' % "SetSelectedRegistrar" conn.request("POST", ctrlurl.path, msg, headers) resp = conn.getresponse() @@ -2465,20 +2464,20 @@ VFi5hrLk def add_ssdp_ap(ap, ap_uuid): ssid = "wps-ssdp" ap_pin = "12345670" - params = { "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", - "friendly_name": "WPS Access Point", - "manufacturer_url": "http://www.example.com/", - "model_description": "Wireless Access Point", - "model_url": "http://www.example.com/model/", - "upc": "123456789012" } + params = {"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", + "friendly_name": "WPS Access Point", + "manufacturer_url": "http://www.example.com/", + "model_description": "Wireless Access Point", + "model_url": "http://www.example.com/model/", + "upc": "123456789012"} return hostapd.add_ap(ap, params) def ssdp_send(msg, no_recv=False): @@ -2807,7 +2806,7 @@ def upnp_soap_action(conn, path, action, include_soap_action=True, msg = ET.SubElement(act, "NewWLANEventMAC") msg.text = neweventmac - headers = { "Content-type": 'text/xml; charset="utf-8"' } + headers = {"Content-type": 'text/xml; charset="utf-8"'} if include_soap_action: headers["SOAPAction"] = '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1#%s"' % action elif soap_action_override: @@ -2845,8 +2844,8 @@ def test_ap_wps_upnp(dev, apdev): url = urlparse(location) conn = HTTPConnection(url.netloc) #conn.set_debuglevel(1) - headers = { "Content-type": 'text/xml; charset="utf-8"', - "SOAPAction": '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1#GetDeviceInfo"' } + headers = {"Content-type": 'text/xml; charset="utf-8"', + "SOAPAction": '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1#GetDeviceInfo"'} conn.request("POST", "hello", "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 404: @@ -2857,8 +2856,8 @@ def test_ap_wps_upnp(dev, apdev): if resp.status != 501: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "Content-type": 'text/xml; charset="utf-8"', - "SOAPAction": '"urn:some-unknown-action#GetDeviceInfo"' } + headers = {"Content-type": 'text/xml; charset="utf-8"', + "SOAPAction": '"urn:some-unknown-action#GetDeviceInfo"'} ctrlurl = urlparse(urls['control_url']) conn.request("POST", ctrlurl.path, "\r\n\r\n", headers) resp = conn.getresponse() @@ -2872,10 +2871,10 @@ def test_ap_wps_upnp(dev, apdev): raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("GetDeviceInfo with invalid SOAPAction header") - for act in [ "foo", - "urn:schemas-wifialliance-org:service:WFAWLANConfig:1#GetDeviceInfo", - '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1"', - '"urn:schemas-wifialliance-org:service:WFAWLANConfig:123#GetDevice']: + for act in ["foo", + "urn:schemas-wifialliance-org:service:WFAWLANConfig:1#GetDeviceInfo", + '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1"', + '"urn:schemas-wifialliance-org:service:WFAWLANConfig:123#GetDevice']: resp = upnp_soap_action(conn, ctrlurl.path, "GetDeviceInfo", include_soap_action=False, soap_action_override=act) @@ -2921,8 +2920,8 @@ def test_ap_wps_upnp_subscribe(dev, apdev): url = urlparse(location) conn = HTTPConnection(url.netloc) #conn.set_debuglevel(1) - headers = { "callback": '', - "timeout": "Second-1234" } + headers = {"callback": '', + "timeout": "Second-1234"} conn.request("SUBSCRIBE", "hello", "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 412: @@ -2933,25 +2932,25 @@ def test_ap_wps_upnp_subscribe(dev, apdev): if resp.status != 412: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 412: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "callback": '', - "NT": "upnp:foobar", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:foobar", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Valid subscription") - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -2960,46 +2959,46 @@ def test_ap_wps_upnp_subscribe(dev, apdev): logger.debug("Subscription SID " + sid) logger.debug("Invalid re-subscription") - headers = { "NT": "upnp:event", - "sid": "123456734567854", - "timeout": "Second-1234" } + headers = {"NT": "upnp:event", + "sid": "123456734567854", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Invalid re-subscription") - headers = { "NT": "upnp:event", - "sid": "uuid:123456734567854", - "timeout": "Second-1234" } + headers = {"NT": "upnp:event", + "sid": "uuid:123456734567854", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Invalid re-subscription") - headers = { "callback": '', - "NT": "upnp:event", - "sid": sid, - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "sid": sid, + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("SID mismatch in re-subscription") - headers = { "NT": "upnp:event", - "sid": "uuid:4c2bca79-1ff4-4e43-85d4-952a2b8a51fb", - "timeout": "Second-1234" } + headers = {"NT": "upnp:event", + "sid": "uuid:4c2bca79-1ff4-4e43-85d4-952a2b8a51fb", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 412: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Valid re-subscription") - headers = { "NT": "upnp:event", - "sid": sid, - "timeout": "Second-1234" } + headers = {"NT": "upnp:event", + "sid": sid, + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -3011,72 +3010,72 @@ def test_ap_wps_upnp_subscribe(dev, apdev): raise Exception("Unexpected SID change") logger.debug("Valid re-subscription") - headers = { "NT": "upnp:event", - "sid": "uuid: \t \t" + sid.split(':')[1], - "timeout": "Second-1234" } + headers = {"NT": "upnp:event", + "sid": "uuid: \t \t" + sid.split(':')[1], + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Invalid unsubscription") - headers = { "sid": sid } + headers = {"sid": sid} conn.request("UNSUBSCRIBE", "/hello", "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 412: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "foo": "bar" } + headers = {"foo": "bar"} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 412: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Valid unsubscription") - headers = { "sid": sid } + headers = {"sid": sid} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Unsubscription for not existing SID") - headers = { "sid": sid } + headers = {"sid": sid} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 412: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Invalid unsubscription") - headers = { "sid": " \t \tfoo" } + headers = {"sid": " \t \tfoo"} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Invalid unsubscription") - headers = { "sid": "uuid:\t \tfoo" } + headers = {"sid": "uuid:\t \tfoo"} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Invalid unsubscription") - headers = { "NT": "upnp:event", - "sid": sid } + headers = {"NT": "upnp:event", + "sid": sid} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "callback": '', - "sid": sid } + headers = {"callback": '', + "sid": sid} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 400: raise Exception("Unexpected HTTP response: %d" % resp.status) logger.debug("Valid subscription with multiple callbacks") - headers = { "callback": ' \t', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": ' \t', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -3103,15 +3102,15 @@ def test_ap_wps_upnp_subscribe(dev, apdev): time.sleep(0.1) time.sleep(0.2) - headers = { "sid": sid } + headers = {"sid": sid} conn.request("UNSUBSCRIBE", eventurl.path, "", headers) resp = conn.getresponse() if resp.status != 200 and resp.status != 412: raise Exception("Unexpected HTTP response for UNSUBSCRIBE: %d" % resp.status) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} with alloc_fail(hapd, 1, "http_client_addr;event_send_start"): conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() @@ -3120,15 +3119,15 @@ def test_ap_wps_upnp_subscribe(dev, apdev): sid = resp.getheader("sid") logger.debug("Subscription SID " + sid) - headers = { "sid": sid } + headers = {"sid": sid} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: raise Exception("Unexpected HTTP response for UNSUBSCRIBE: %d" % resp.status) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -3179,25 +3178,25 @@ def test_ap_wps_upnp_subscribe(dev, apdev): if resp.status != 500: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 500: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "callback": ' <', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": ' <', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 500: raise Exception("Unexpected HTTP response: %d" % resp.status) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} with alloc_fail(hapd, 1, "wpabuf_alloc;subscription_first_event"): conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() @@ -3223,9 +3222,9 @@ def test_ap_wps_upnp_subscribe(dev, apdev): raise Exception("Unexpected HTTP response: %d" % resp.status) for i in range(6): - headers = { "callback": '' % (12345 + i), - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '' % (12345 + i), + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -3279,9 +3278,9 @@ def test_ap_wps_upnp_subscribe_events(dev, apdev): url = urlparse(location) conn = HTTPConnection(url.netloc) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -3342,7 +3341,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev): raise Exception("Unexpected response to HEAD: " + str(resp.status)) conn.close() - for cmd in [ "PUT", "DELETE", "TRACE", "CONNECT", "M-SEARCH", "M-POST" ]: + for cmd in ["PUT", "DELETE", "TRACE", "CONNECT", "M-SEARCH", "M-POST"]: try: conn.request(cmd, "hello") resp = conn.getresponse() @@ -3350,7 +3349,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev): pass conn.close() - headers = { "Content-Length": 'abc' } + headers = {"Content-Length": 'abc'} conn.request("HEAD", "hello", "\r\n\r\n", headers) try: resp = conn.getresponse() @@ -3358,7 +3357,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev): pass conn.close() - headers = { "Content-Length": '-10' } + headers = {"Content-Length": '-10'} conn.request("HEAD", "hello", "\r\n\r\n", headers) try: resp = conn.getresponse() @@ -3366,7 +3365,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev): pass conn.close() - headers = { "Content-Length": '10000000000000' } + headers = {"Content-Length": '10000000000000'} conn.request("HEAD", "hello", "\r\n\r\nhello", headers) try: resp = conn.getresponse() @@ -3374,14 +3373,14 @@ def test_ap_wps_upnp_http_proto(dev, apdev): pass conn.close() - headers = { "Transfer-Encoding": 'abc' } + headers = {"Transfer-Encoding": 'abc'} conn.request("HEAD", "hello", "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 501: raise Exception("Unexpected response to HEAD: " + str(resp.status)) conn.close() - headers = { "Transfer-Encoding": 'chunked' } + headers = {"Transfer-Encoding": 'chunked'} conn.request("HEAD", "hello", "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 501: @@ -3403,7 +3402,7 @@ def test_ap_wps_upnp_http_proto(dev, apdev): raise Exception("Unexpected response to HEAD: " + str(resp.status)) conn.close() - headers = { "Content-Length": '20' } + headers = {"Content-Length": '20'} conn.request("POST", "hello", 10 * 'A' + "\r\n\r\n", headers) try: resp = conn.getresponse() @@ -3435,7 +3434,7 @@ def test_ap_wps_upnp_http_proto_chunked(dev, apdev): conn = HTTPConnection(url.netloc) #conn.set_debuglevel(1) - headers = { "Transfer-Encoding": 'chunked' } + headers = {"Transfer-Encoding": 'chunked'} conn.request("POST", "hello", "a\r\nabcdefghij\r\n" + "2\r\nkl\r\n" + "0\r\n\r\n", headers) @@ -3472,7 +3471,7 @@ def test_ap_wps_upnp_http_proto_chunked(dev, apdev): if completed: raise Exception("Too long chunked request did not result in connection reset") - headers = { "Transfer-Encoding": 'chunked' } + headers = {"Transfer-Encoding": 'chunked'} conn.request("POST", "hello", "80000000\r\na", headers) try: resp = conn.getresponse() @@ -3491,7 +3490,7 @@ def test_ap_wps_upnp_http_proto_chunked(dev, apdev): def test_ap_wps_disabled(dev, apdev): """WPS operations while WPS is disabled""" ssid = "test-wps-disabled" - hapd = hostapd.add_ap(apdev[0], { "ssid": ssid }) + hapd = hostapd.add_ap(apdev[0], {"ssid": ssid}) if "FAIL" not in hapd.request("WPS_PBC"): raise Exception("WPS_PBC succeeded unexpectedly") if "FAIL" not in hapd.request("WPS_CANCEL"): @@ -3500,8 +3499,8 @@ def test_ap_wps_disabled(dev, apdev): def test_ap_wps_mixed_cred(dev, apdev): """WPS 2.0 STA merging mixed mode WPA/WPA2 credentials""" ssid = "test-wps-wep" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "skip_cred_build": "1", "extra_cred": "wps-mixed-cred" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "skip_cred_build": "1", "extra_cred": "wps-mixed-cred"} hapd = hostapd.add_ap(apdev[0], params) hapd.request("WPS_PBC") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -3526,11 +3525,11 @@ def test_ap_wps_while_connected(dev, apdev): """WPS PBC provisioning while connected to another AP""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hostapd.add_ap(apdev[1], { "ssid": "open" }) + hostapd.add_ap(apdev[1], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") logger.info("WPS provisioning step") @@ -3547,11 +3546,11 @@ def test_ap_wps_while_connected_no_autoconnect(dev, apdev): """WPS PBC provisioning while connected to another AP and STA_AUTOCONNECT disabled""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) - hostapd.add_ap(apdev[1], { "ssid": "open" }) + hostapd.add_ap(apdev[1], {"ssid": "open"}) try: dev[0].request("STA_AUTOCONNECT 0") @@ -3573,9 +3572,9 @@ def test_ap_wps_from_event(dev, apdev): """WPS PBC event on AP to enable PBC""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].dump_monitor() hapd.dump_monitor() @@ -3596,9 +3595,9 @@ def test_ap_wps_ap_scan_2(dev, apdev): """AP_SCAN 2 for WPS""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) hapd.request("WPS_PBC") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -3643,7 +3642,7 @@ def test_ap_wps_eapol_workaround(dev, apdev): """EAPOL workaround code path for 802.1X header length mismatch""" ssid = "test-wps" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1"}) bssid = apdev[0]['bssid'] hapd.request("SET ext_eapol_frame_io 1") dev[0].request("SET ext_eapol_frame_io 1") @@ -3662,15 +3661,15 @@ def test_ap_wps_iteration(dev, apdev): """WPS PIN and iterate through APs without selected registrar""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) ssid2 = "test-wps-conf2" hapd2 = hostapd.add_ap(apdev[1], - { "ssid": ssid2, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid2, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412") @@ -3704,10 +3703,10 @@ def test_ap_wps_iteration_error(dev, apdev): """WPS AP iteration on no Selected Registrar and error case with an AP""" ssid = "test-wps-conf-pin" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wps_independent": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_independent": "1"}) hapd.request("SET ext_eapol_frame_io 1") bssid = apdev[0]['bssid'] pin = dev[0].wps_read_pin() @@ -3730,10 +3729,10 @@ def test_ap_wps_iteration_error(dev, apdev): # Start the real target AP and activate registrar on it. hapd2 = hostapd.add_ap(apdev[1], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wps_independent": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_independent": "1"}) hapd2.request("WPS_PIN any " + pin) dev[0].wait_disconnected(timeout=15) @@ -3750,9 +3749,9 @@ def test_ap_wps_priority(dev, apdev): """WPS PIN provisioning with configured AP and wps_priority""" ssid = "test-wps-conf-pin" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -3772,10 +3771,10 @@ def test_ap_wps_priority(dev, apdev): @remote_compatible def test_ap_wps_and_non_wps(dev, apdev): """WPS and non-WPS AP in single hostapd process""" - params = { "ssid": "wps", "eap_server": "1", "wps_state": "1" } + params = {"ssid": "wps", "eap_server": "1", "wps_state": "1"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "no wps" } + params = {"ssid": "no wps"} hapd2 = hostapd.add_ap(apdev[1], params) appin = hapd.request("WPS_AP_PIN random") @@ -3792,7 +3791,7 @@ def test_ap_wps_and_non_wps(dev, apdev): def test_ap_wps_init_oom(dev, apdev): """Initial AP configuration and OOM during PSK generation""" ssid = "test-wps" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "1"} hapd = hostapd.add_ap(apdev[0], params) with alloc_fail(hapd, 1, "base64_gen_encode;?base64_encode;wps_build_cred"): @@ -3820,15 +3819,15 @@ def _test_ap_wps_er_oom(dev, apdev): ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0], - { "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"}) + {"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"}) dev[0].connect(ssid, psk="12345678", scan_freq="2412") @@ -3908,18 +3907,18 @@ def test_ap_wps_wpa_cli_action(dev, apdev, test_params): ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) prg = os.path.join(test_params['logdir'], 'alt-wpa_supplicant/wpa_supplicant/wpa_cli') if not os.path.exists(prg): prg = '../../wpa_supplicant/wpa_cli' - arg = [ prg, '-P', pidfile, '-B', '-i', dev[0].ifname, '-a', actionfile ] + arg = [prg, '-P', pidfile, '-B', '-i', dev[0].ifname, '-a', actionfile] subprocess.call(arg) - arg = [ 'ps', 'ax' ] + arg = ['ps', 'ax'] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE) out = cmd.communicate()[0].decode() cmd.wait() @@ -3945,7 +3944,7 @@ def test_ap_wps_wpa_cli_action(dev, apdev, test_params): if "WPS-SUCCESS" not in res: raise Exception("WPS-SUCCESS event not seen in action file") - arg = [ 'ps', 'ax' ] + arg = ['ps', 'ax'] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE) out = cmd.communicate()[0].decode() cmd.wait() @@ -3972,7 +3971,7 @@ def _test_ap_wps_er_ssdp_proto(dev, apdev): raise Exception("Invalid filter accepted") if "OK" not in dev[0].request("WPS_ER_START ifname=lo 1.2.3.4"): raise Exception("WPS_ER_START with filter failed") - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) msg = msg.decode() logger.debug("Received SSDP message from %s: %s" % (str(addr), msg)) if "M-SEARCH" not in msg: @@ -3982,7 +3981,7 @@ def _test_ap_wps_er_ssdp_proto(dev, apdev): dev[0].request("WPS_ER_STOP") dev[0].request("WPS_ER_START ifname=lo") - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) msg = msg.decode() logger.debug("Received SSDP message from %s: %s" % (str(addr), msg)) if "M-SEARCH" not in msg: @@ -4155,7 +4154,7 @@ def wps_er_start(dev, http_server, max_age=1, wait_m_search=False, sock.bind(("239.255.255.250", 1900)) dev.request("WPS_ER_START ifname=lo") for i in range(100): - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) msg = msg.decode() logger.debug("Received SSDP message from %s: %s" % (str(addr), msg)) if "M-SEARCH" in msg: @@ -4171,7 +4170,7 @@ def wps_er_start(dev, http_server, max_age=1, wait_m_search=False, location_url = 'http://127.0.0.1:12345/foo.xml' sock.sendto(("HTTP/1.1 200 OK\r\nST: urn:schemas-wifialliance-org:device:WFADevice:1\r\nlocation:%s\r\ncache-control:max-age=%d\r\n\r\n" % (location_url, max_age)).encode(), addr) server.timeout = 1 - return server,sock + return server, sock def wps_er_stop(dev, sock, server, on_alloc_fail=False): sock.close() @@ -4196,7 +4195,7 @@ def wps_er_stop(dev, sock, server, on_alloc_fail=False): def run_wps_er_proto_test(dev, handler, no_event_url=False, location_url=None): try: uuid = '27ea801a-9e5c-4e73-bd82-f89cbcd10d7e' - server,sock = wps_er_start(dev, handler, location_url=location_url) + server, sock = wps_er_start(dev, handler, location_url=location_url) global wps_event_url wps_event_url = None server.handle_request() @@ -4222,13 +4221,13 @@ def send_wlanevent(url, uuid, data, no_response=False): ''' payload += base64.b64encode(data).decode() payload += '' - headers = { "Content-type": 'text/xml; charset="utf-8"', - "Server": "Unspecified, UPnP/1.0, Unspecified", - "HOST": url.netloc, - "NT": "upnp:event", - "SID": "uuid:" + uuid, - "SEQ": "0", - "Content-Length": str(len(payload)) } + headers = {"Content-type": 'text/xml; charset="utf-8"', + "Server": "Unspecified, UPnP/1.0, Unspecified", + "HOST": url.netloc, + "NT": "upnp:event", + "SID": "uuid:" + uuid, + "SEQ": "0", + "Content-Length": str(len(payload))} conn.request("NOTIFY", url.path, payload, headers) if no_response: try: @@ -4249,7 +4248,7 @@ def test_ap_wps_er_http_proto(dev, apdev): def _test_ap_wps_er_http_proto(dev, apdev): uuid = '27ea801a-9e5c-4e73-bd82-f89cbcd10d7e' - server,sock = wps_er_start(dev[0], WPSAPHTTPServer, max_age=15) + server, sock = wps_er_start(dev[0], WPSAPHTTPServer, max_age=15) global wps_event_url wps_event_url = None server.handle_request() @@ -4281,13 +4280,13 @@ RGV2aWNlIEEQSQAGADcqAAEg ''' - headers = { "Content-type": 'text/xml; charset="utf-8"', - "Server": "Unspecified, UPnP/1.0, Unspecified", - "HOST": url.netloc, - "NT": "upnp:event", - "SID": "uuid:" + uuid, - "SEQ": "0", - "Content-Length": str(len(payload)) } + headers = {"Content-type": 'text/xml; charset="utf-8"', + "Server": "Unspecified, UPnP/1.0, Unspecified", + "HOST": url.netloc, + "NT": "upnp:event", + "SID": "uuid:" + uuid, + "SEQ": "0", + "Content-Length": str(len(payload))} conn.request("NOTIFY", url.path, payload, headers) resp = conn.getresponse() if resp.status != 200: @@ -4524,10 +4523,10 @@ RGV2aWNlIEEQSQAGADcqAAEg raise Exception("Too few concurrent HTTP connections accepted") logger.info("OOM in HTTP server") - for func in [ "http_request_init", "httpread_create", - "eloop_register_timeout;httpread_create", - "eloop_sock_table_add_sock;?eloop_register_sock;httpread_create", - "httpread_hdr_analyze" ]: + for func in ["http_request_init", "httpread_create", + "eloop_register_timeout;httpread_create", + "eloop_sock_table_add_sock;?eloop_register_sock;httpread_create", + "httpread_hdr_analyze"]: with alloc_fail(dev[0], 1, func): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) @@ -4540,17 +4539,17 @@ RGV2aWNlIEEQSQAGADcqAAEg sock.close() logger.info("Invalid HTTP header") - for req in [ " GET / HTTP/1.1\r\n\r\n", - "HTTP/1.1 200 OK\r\n\r\n", - "HTTP/\r\n\r\n", - "GET %%a%aa% HTTP/1.1\r\n\r\n", - "GET / HTTP/1.1\r\n FOO\r\n\r\n", - "NOTIFY / HTTP/1.1\r\n" + 4097*'a' + '\r\n\r\n', - "NOTIFY / HTTP/1.1\r\n\r\n" + 8193*'a', - "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n foo\r\n", - "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n1\r\nfoo\r\n", - "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n0\r\n", - "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n0\r\naa\ra\r\n\ra" ]: + for req in [" GET / HTTP/1.1\r\n\r\n", + "HTTP/1.1 200 OK\r\n\r\n", + "HTTP/\r\n\r\n", + "GET %%a%aa% HTTP/1.1\r\n\r\n", + "GET / HTTP/1.1\r\n FOO\r\n\r\n", + "NOTIFY / HTTP/1.1\r\n" + 4097*'a' + '\r\n\r\n', + "NOTIFY / HTTP/1.1\r\n\r\n" + 8193*'a', + "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n foo\r\n", + "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n1\r\nfoo\r\n", + "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n0\r\n", + "POST / HTTP/1.1\r\nTransfer-Encoding: CHUNKED\r\n\r\n0\r\naa\ra\r\n\ra"]: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) sock.settimeout(0.1) @@ -4575,13 +4574,13 @@ RGV2aWNlIEEQSQAGADcqAAEg conn = HTTPConnection(url.netloc) payload = '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 200: @@ -5983,16 +5982,16 @@ def test_ap_wps_set_selected_registrar_proto(dev, apdev): logger.debug("Subscription SID " + sid) server.handle_request() - tests = [ (500, "10"), - (200, "104a000110" + "1041000101" + "101200020000" + - "105300023148" + - "1049002c00372a0001200124111111111111222222222222333333333333444444444444555555555555666666666666" + - "10480010362db47ba53a519188fb5458b986b2e4"), - (200, "104a000110" + "1041000100" + "101200020000" + - "105300020000"), - (200, "104a000110" + "1041000100"), - (200, "104a000110") ] - for status,test in tests: + tests = [(500, "10"), + (200, "104a000110" + "1041000101" + "101200020000" + + "105300023148" + + "1049002c00372a0001200124111111111111222222222222333333333333444444444444555555555555666666666666" + + "10480010362db47ba53a519188fb5458b986b2e4"), + (200, "104a000110" + "1041000100" + "101200020000" + + "105300020000"), + (200, "104a000110" + "1041000100"), + (200, "104a000110")] + for status, test in tests: tlvs = binascii.unhexlify(test) newmsg = base64.b64encode(tlvs).decode() msg = '\n' @@ -6002,7 +6001,7 @@ def test_ap_wps_set_selected_registrar_proto(dev, apdev): msg += '' msg += newmsg msg += "" - headers = { "Content-type": 'text/xml; charset="utf-8"' } + headers = {"Content-type": 'text/xml; charset="utf-8"'} headers["SOAPAction"] = '"urn:schemas-wifialliance-org:service:WFAWLANConfig:1#%s"' % "SetSelectedRegistrar" conn.request("POST", ctrlurl.path, msg, headers) resp = conn.getresponse() @@ -6171,7 +6170,7 @@ def get_wsc_msg(dev): # Parse EAPOL header if len(data) < 4: raise Exception("No room for EAPOL header") - version,type,length = struct.unpack('>BBH', data[0:4]) + version, type, length = struct.unpack('>BBH', data[0:4]) msg['eapol_version'] = version msg['eapol_type'] = type msg['eapol_length'] = length @@ -6184,7 +6183,7 @@ def get_wsc_msg(dev): # Parse EAP header if len(data) < 4: raise Exception("No room for EAP header") - code,identifier,length = struct.unpack('>BBH', data[0:4]) + code, identifier, length = struct.unpack('>BBH', data[0:4]) msg['eap_code'] = code msg['eap_identifier'] = identifier msg['eap_length'] = length @@ -6223,7 +6222,7 @@ def get_wsc_msg(dev): while len(data) > 0: if len(data) < 4: raise Exception("Truncated attribute header") - attr,length = struct.unpack('>HH', data[0:4]) + attr, length = struct.unpack('>HH', data[0:4]) data = data[4:] if length > len(data): raise Exception("Truncated attribute 0x%04x" % attr) @@ -6304,7 +6303,7 @@ def wsc_keys(kdk): authkey = keys[0:32] keywrapkey = keys[32:48] emsk = keys[48:80] - return authkey,keywrapkey,emsk + return authkey, keywrapkey, emsk def wsc_dev_pw_half_psk(authkey, dev_pw): m = hmac.new(authkey, dev_pw.encode(), hashlib.sha256) @@ -6315,7 +6314,7 @@ def wsc_dev_pw_psk(authkey, dev_pw): dev_pw_2 = dev_pw[len(dev_pw) // 2:] psk1 = wsc_dev_pw_half_psk(authkey, dev_pw_1) psk2 = wsc_dev_pw_half_psk(authkey, dev_pw_2) - return psk1,psk2 + return psk1, psk2 def build_attr_authenticator(authkey, prev_msg, curr_msg): m = hmac.new(authkey, prev_msg + curr_msg, hashlib.sha256) @@ -6352,7 +6351,7 @@ def decrypt_attr_encr_settings(authkey, keywrapkey, data): if len(decrypted) < 12: raise Exception("Truncated Encrypted Settings plaintext") kwa = decrypted[-12:] - attr,length = struct.unpack(">HH", kwa[0:4]) + attr, length = struct.unpack(">HH", kwa[0:4]) if attr != ATTR_KEY_WRAP_AUTH or length != 8: raise Exception("Invalid KWA header") kwa = kwa[4:] @@ -6395,14 +6394,14 @@ def wsc_dh_kdf(peer_pk, own_private, mac_addr, e_nonce, r_nonce): m = hmac.new(dhkey, e_nonce + mac_addr + r_nonce, hashlib.sha256) kdk = m.digest() logger.debug("KDK: " + binascii.hexlify(kdk).decode()) - authkey,keywrapkey,emsk = wsc_keys(kdk) + authkey, keywrapkey, emsk = wsc_keys(kdk) logger.debug("AuthKey: " + binascii.hexlify(authkey).decode()) logger.debug("KeyWrapKey: " + binascii.hexlify(keywrapkey).decode()) logger.debug("EMSK: " + binascii.hexlify(emsk).decode()) - return authkey,keywrapkey + return authkey, keywrapkey def wsc_dev_pw_hash(authkey, dev_pw, e_pk, r_pk): - psk1,psk2 = wsc_dev_pw_psk(authkey, dev_pw) + psk1, psk2 = wsc_dev_pw_psk(authkey, dev_pw) logger.debug("PSK1: " + binascii.hexlify(psk1).decode()) logger.debug("PSK2: " + binascii.hexlify(psk2).decode()) @@ -6417,7 +6416,7 @@ def wsc_dev_pw_hash(authkey, dev_pw, e_pk, r_pk): m = hmac.new(authkey, s2 + psk2 + e_pk + r_pk, hashlib.sha256) hash2 = m.digest() logger.debug("Hash2: " + binascii.hexlify(hash2).decode()) - return s1,s2,hash1,hash2 + return s1, s2, hash1, hash2 def build_m1(eap_id, uuid_e, mac_addr, e_nonce, e_pk, manufacturer='', model_name='', config_methods='\x00\x00'): @@ -6529,7 +6528,7 @@ def build_nack(eap_id, e_nonce, r_nonce, config_error='\x00\x00', def test_wps_ext(dev, apdev): """WPS against external implementation""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -6552,11 +6551,11 @@ def test_wps_ext(dev, apdev): logger.debug("Receive M2 from AP") msg, m2_attrs, raw_m2_attrs = recv_wsc_msg(hapd, WSC_MSG, WPS_M2) - authkey,keywrapkey = wsc_dh_kdf(m2_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, e_nonce, - m2_attrs[ATTR_REGISTRAR_NONCE]) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, - m2_attrs[ATTR_PUBLIC_KEY]) + authkey, keywrapkey = wsc_dh_kdf(m2_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, e_nonce, + m2_attrs[ATTR_REGISTRAR_NONCE]) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, + m2_attrs[ATTR_PUBLIC_KEY]) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -6628,11 +6627,12 @@ def test_wps_ext(dev, apdev): logger.debug("Receive M1 from STA") msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -6711,7 +6711,7 @@ def test_wps_ext(dev, apdev): def wps_start_kwa(dev, apdev): pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -6725,11 +6725,12 @@ def wps_start_kwa(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -6767,7 +6768,7 @@ def wps_stop_kwa(dev, bssid, attrs, authkey, raw_m3_attrs, eap_id): def test_wps_ext_kwa_proto_no_kwa(dev, apdev): """WPS and KWA error: No KWA attribute""" - r_s1,keywrapkey,authkey,raw_m3_attrs,eap_id,bssid,attrs = wps_start_kwa(dev, apdev) + r_s1, keywrapkey, authkey, raw_m3_attrs, eap_id, bssid, attrs = wps_start_kwa(dev, apdev) data = build_wsc_attr(ATTR_R_SNONCE1, r_s1) # Encrypted Settings without KWA iv = 16*b'\x99' @@ -6781,7 +6782,7 @@ def test_wps_ext_kwa_proto_no_kwa(dev, apdev): def test_wps_ext_kwa_proto_data_after_kwa(dev, apdev): """WPS and KWA error: Data after KWA""" - r_s1,keywrapkey,authkey,raw_m3_attrs,eap_id,bssid,attrs = wps_start_kwa(dev, apdev) + r_s1, keywrapkey, authkey, raw_m3_attrs, eap_id, bssid, attrs = wps_start_kwa(dev, apdev) data = build_wsc_attr(ATTR_R_SNONCE1, r_s1) # Encrypted Settings and data after KWA m = hmac.new(authkey, data, hashlib.sha256) @@ -6799,7 +6800,7 @@ def test_wps_ext_kwa_proto_data_after_kwa(dev, apdev): def test_wps_ext_kwa_proto_kwa_mismatch(dev, apdev): """WPS and KWA error: KWA mismatch""" - r_s1,keywrapkey,authkey,raw_m3_attrs,eap_id,bssid,attrs = wps_start_kwa(dev, apdev) + r_s1, keywrapkey, authkey, raw_m3_attrs, eap_id, bssid, attrs = wps_start_kwa(dev, apdev) data = build_wsc_attr(ATTR_R_SNONCE1, r_s1) # Encrypted Settings and KWA with incorrect value data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, 8*'\x00') @@ -6814,7 +6815,7 @@ def test_wps_ext_kwa_proto_kwa_mismatch(dev, apdev): def wps_run_cred_proto(dev, apdev, m8_cred, connect=False, no_connect=False): pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -6828,11 +6829,12 @@ def wps_run_cred_proto(dev, apdev, m8_cred, connect=False, no_connect=False): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7016,7 +7018,7 @@ def test_wps_ext_cred_proto_missing_cred(dev, apdev): def test_wps_ext_proto_m2_no_public_key(dev, apdev): """WPS and no Public Key in M2""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7030,11 +7032,12 @@ def test_wps_ext_proto_m2_no_public_key(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7054,7 +7057,7 @@ def test_wps_ext_proto_m2_no_public_key(dev, apdev): def test_wps_ext_proto_m2_invalid_public_key(dev, apdev): """WPS and invalid Public Key in M2""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7068,11 +7071,12 @@ def test_wps_ext_proto_m2_invalid_public_key(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7092,7 +7096,7 @@ def test_wps_ext_proto_m2_invalid_public_key(dev, apdev): def test_wps_ext_proto_m2_public_key_oom(dev, apdev): """WPS and Public Key OOM in M2""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7106,11 +7110,12 @@ def test_wps_ext_proto_m2_public_key_oom(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7131,7 +7136,7 @@ def test_wps_ext_proto_m2_public_key_oom(dev, apdev): def test_wps_ext_proto_nack_m3(dev, apdev): """WPS and NACK M3""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7145,11 +7150,12 @@ def test_wps_ext_proto_nack_m3(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7174,7 +7180,7 @@ def test_wps_ext_proto_nack_m3(dev, apdev): def test_wps_ext_proto_nack_m5(dev, apdev): """WPS and NACK M5""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7188,11 +7194,12 @@ def test_wps_ext_proto_nack_m5(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7233,7 +7240,7 @@ def test_wps_ext_proto_nack_m5(dev, apdev): def wps_nack_m3(dev, apdev): pin = "00000000" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pbc=True) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pbc=True) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7247,11 +7254,12 @@ def wps_nack_m3(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7428,7 +7436,7 @@ def test_wps_ext_proto_ack_m3(dev, apdev): def wps_to_m3_helper(dev, apdev): pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start") @@ -7442,11 +7450,12 @@ def wps_to_m3_helper(dev, apdev): msg, m1_attrs, raw_m1_attrs = recv_wsc_msg(dev[0], WSC_MSG, WPS_M1) eap_id = (msg['eap_identifier'] + 1) % 256 - authkey,keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, - mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, pin, - m1_attrs[ATTR_PUBLIC_KEY], e_pk) + authkey, keywrapkey = wsc_dh_kdf(m1_attrs[ATTR_PUBLIC_KEY], own_private, + mac_addr, m1_attrs[ATTR_ENROLLEE_NONCE], + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, pin, + m1_attrs[ATTR_PUBLIC_KEY], + e_pk) logger.debug("Send M2 to STA") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id, @@ -7754,10 +7763,10 @@ def wps_start_ext_reg(apdev, dev): bssid = apdev['bssid'] ssid = "test-wps-conf" appin = "12345670" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": appin } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": appin} hapd = hostapd.add_ap(apdev, params) dev.scan_for_bss(bssid, freq="2412") @@ -7766,10 +7775,10 @@ def wps_start_ext_reg(apdev, dev): dev.request("WPS_REG " + bssid + " " + appin) - return addr,bssid,hapd + return addr, bssid, hapd def wps_run_ap_settings_proto(dev, apdev, ap_settings, success): - addr,bssid,hapd = wps_start_ext_reg(apdev[0], dev[0]) + addr, bssid, hapd = wps_start_ext_reg(apdev[0], dev[0]) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -7783,9 +7792,9 @@ def wps_run_ap_settings_proto(dev, apdev, ap_settings, success): uuid_r = 16*b'\x33' r_nonce = 16*b'\x44' own_private, r_pk = wsc_dh_init() - authkey,keywrapkey = wsc_dh_kdf(e_pk, own_private, mac_addr, e_nonce, - r_nonce) - r_s1,r_s2,r_hash1,r_hash2 = wsc_dev_pw_hash(authkey, appin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(e_pk, own_private, mac_addr, e_nonce, + r_nonce) + r_s1, r_s2, r_hash1, r_hash2 = wsc_dev_pw_hash(authkey, appin, e_pk, r_pk) logger.debug("Send M2 to AP") m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, msg['eap_identifier'], @@ -7846,8 +7855,8 @@ def wps_run_ap_settings_proto(dev, apdev, ap_settings, success): raise Exception("Unexpected message - expected WSC_Done") logger.debug("Send WSC_ACK to AP") - ack,attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, - eap_code=2) + ack, attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, + eap_code=2) send_wsc_msg(hapd, addr, ack) dev[0].wait_disconnected() else: @@ -7860,8 +7869,8 @@ def wps_run_ap_settings_proto(dev, apdev, ap_settings, success): raise Exception("Unexpected message - expected WSC_NACK") logger.debug("Send WSC_NACK to AP") - nack,attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, - eap_code=2) + nack, attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, + eap_code=2) send_wsc_msg(hapd, addr, nack) dev[0].wait_disconnected() @@ -7915,7 +7924,7 @@ def test_wps_ext_ap_settings_reject_encr_type(dev, apdev): @remote_compatible def test_wps_ext_ap_settings_m2d(dev, apdev): """WPS and AP Settings: M2D""" - addr,bssid,hapd = wps_start_ext_reg(apdev[0], dev[0]) + addr, bssid, hapd = wps_start_ext_reg(apdev[0], dev[0]) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -7945,8 +7954,8 @@ def wps_wait_ap_nack(hapd, dev, e_nonce, r_nonce): raise Exception("Unexpected message - expected WSC_NACK") logger.debug("Send WSC_NACK to AP") - nack,attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, - eap_code=2) + nack, attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, + eap_code=2) send_wsc_msg(hapd, dev.own_addr(), nack) dev.wait_disconnected() @@ -7954,7 +7963,7 @@ def wps_wait_ap_nack(hapd, dev, e_nonce, r_nonce): def test_wps_ext_m3_missing_e_hash1(dev, apdev): """WPS proto: M3 missing E-Hash1""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -7978,9 +7987,9 @@ def test_wps_ext_m3_missing_e_hash1(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -7999,7 +8008,7 @@ def test_wps_ext_m3_missing_e_hash1(dev, apdev): def test_wps_ext_m3_missing_e_hash2(dev, apdev): """WPS proto: M3 missing E-Hash2""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8023,9 +8032,9 @@ def test_wps_ext_m3_missing_e_hash2(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8044,7 +8053,7 @@ def test_wps_ext_m3_missing_e_hash2(dev, apdev): def test_wps_ext_m5_missing_e_snonce1(dev, apdev): """WPS proto: M5 missing E-SNonce1""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8068,9 +8077,9 @@ def test_wps_ext_m5_missing_e_snonce1(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8104,7 +8113,7 @@ def test_wps_ext_m5_missing_e_snonce1(dev, apdev): def test_wps_ext_m5_e_snonce1_mismatch(dev, apdev): """WPS proto: M5 E-SNonce1 mismatch""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8128,9 +8137,9 @@ def test_wps_ext_m5_e_snonce1_mismatch(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8162,7 +8171,7 @@ def test_wps_ext_m5_e_snonce1_mismatch(dev, apdev): def test_wps_ext_m7_missing_e_snonce2(dev, apdev): """WPS proto: M7 missing E-SNonce2""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8186,9 +8195,9 @@ def test_wps_ext_m7_missing_e_snonce2(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8236,7 +8245,7 @@ def test_wps_ext_m7_missing_e_snonce2(dev, apdev): def test_wps_ext_m7_e_snonce2_mismatch(dev, apdev): """WPS proto: M7 E-SNonce2 mismatch""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8260,9 +8269,9 @@ def test_wps_ext_m7_e_snonce2_mismatch(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8309,7 +8318,7 @@ def test_wps_ext_m7_e_snonce2_mismatch(dev, apdev): def test_wps_ext_m1_pubkey_oom(dev, apdev): """WPS proto: M1 PubKey OOM""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8340,7 +8349,7 @@ def wps_wait_eap_failure(hapd, dev): def test_wps_ext_m3_m1(dev, apdev): """WPS proto: M3 replaced with M1""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8364,9 +8373,9 @@ def test_wps_ext_m3_m1(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3(M1) to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8385,7 +8394,7 @@ def test_wps_ext_m3_m1(dev, apdev): def test_wps_ext_m5_m3(dev, apdev): """WPS proto: M5 replaced with M3""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8409,9 +8418,9 @@ def test_wps_ext_m5_m3(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8444,7 +8453,7 @@ def test_wps_ext_m5_m3(dev, apdev): def test_wps_ext_m3_m2(dev, apdev): """WPS proto: M3 replaced with M2""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8468,9 +8477,9 @@ def test_wps_ext_m3_m2(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3(M2) to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8487,7 +8496,7 @@ def test_wps_ext_m3_m2(dev, apdev): def test_wps_ext_m3_m5(dev, apdev): """WPS proto: M3 replaced with M5""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8511,9 +8520,9 @@ def test_wps_ext_m3_m5(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3(M5) to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8532,7 +8541,7 @@ def test_wps_ext_m3_m5(dev, apdev): def test_wps_ext_m3_m7(dev, apdev): """WPS proto: M3 replaced with M7""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8556,9 +8565,9 @@ def test_wps_ext_m3_m7(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3(M7) to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8577,7 +8586,7 @@ def test_wps_ext_m3_m7(dev, apdev): def test_wps_ext_m3_done(dev, apdev): """WPS proto: M3 replaced with WSC_Done""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8601,9 +8610,9 @@ def test_wps_ext_m3_done(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3(WSC_Done) to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -8619,7 +8628,7 @@ def test_wps_ext_m3_done(dev, apdev): def test_wps_ext_m2_nack_invalid(dev, apdev): """WPS proto: M2 followed by invalid NACK""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8643,9 +8652,9 @@ def test_wps_ext_m2_nack_invalid(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_NACK to AP") attrs = b'\x10\x00\x00' @@ -8658,7 +8667,7 @@ def test_wps_ext_m2_nack_invalid(dev, apdev): def test_wps_ext_m2_nack_no_msg_type(dev, apdev): """WPS proto: M2 followed by NACK without Msg Type""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8682,13 +8691,13 @@ def test_wps_ext_m2_nack_no_msg_type(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_NACK to AP") - nack,attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, - msg_type=None, eap_code=2) + nack, attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, + msg_type=None, eap_code=2) send_wsc_msg(hapd, addr, nack) wps_wait_eap_failure(hapd, dev[0]) @@ -8697,7 +8706,7 @@ def test_wps_ext_m2_nack_no_msg_type(dev, apdev): def test_wps_ext_m2_nack_invalid_msg_type(dev, apdev): """WPS proto: M2 followed by NACK with invalid Msg Type""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8721,13 +8730,13 @@ def test_wps_ext_m2_nack_invalid_msg_type(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_NACK to AP") - nack,attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, - msg_type=WPS_WSC_ACK, eap_code=2) + nack, attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, + msg_type=WPS_WSC_ACK, eap_code=2) send_wsc_msg(hapd, addr, nack) wps_wait_eap_failure(hapd, dev[0]) @@ -8736,7 +8745,7 @@ def test_wps_ext_m2_nack_invalid_msg_type(dev, apdev): def test_wps_ext_m2_nack_e_nonce_mismatch(dev, apdev): """WPS proto: M2 followed by NACK with e-nonce mismatch""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8760,13 +8769,13 @@ def test_wps_ext_m2_nack_e_nonce_mismatch(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_NACK to AP") - nack,attrs = build_nack(msg['eap_identifier'], 16*b'\x00', r_nonce, - eap_code=2) + nack, attrs = build_nack(msg['eap_identifier'], 16*b'\x00', r_nonce, + eap_code=2) send_wsc_msg(hapd, addr, nack) wps_wait_eap_failure(hapd, dev[0]) @@ -8775,7 +8784,7 @@ def test_wps_ext_m2_nack_e_nonce_mismatch(dev, apdev): def test_wps_ext_m2_nack_no_config_error(dev, apdev): """WPS proto: M2 followed by NACK without Config Error""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8799,13 +8808,13 @@ def test_wps_ext_m2_nack_no_config_error(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_NACK to AP") - nack,attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, - config_error=None, eap_code=2) + nack, attrs = build_nack(msg['eap_identifier'], e_nonce, r_nonce, + config_error=None, eap_code=2) send_wsc_msg(hapd, addr, nack) wps_wait_eap_failure(hapd, dev[0]) @@ -8814,7 +8823,7 @@ def test_wps_ext_m2_nack_no_config_error(dev, apdev): def test_wps_ext_m2_ack_invalid(dev, apdev): """WPS proto: M2 followed by invalid ACK""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8838,9 +8847,9 @@ def test_wps_ext_m2_ack_invalid(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_ACK to AP") attrs = b'\x10\x00\x00' @@ -8853,7 +8862,7 @@ def test_wps_ext_m2_ack_invalid(dev, apdev): def test_wps_ext_m2_ack(dev, apdev): """WPS proto: M2 followed by ACK""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8877,12 +8886,12 @@ def test_wps_ext_m2_ack(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_ACK to AP") - ack,attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, eap_code=2) + ack, attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, eap_code=2) send_wsc_msg(hapd, addr, ack) wps_wait_eap_failure(hapd, dev[0]) @@ -8891,7 +8900,7 @@ def test_wps_ext_m2_ack(dev, apdev): def test_wps_ext_m2_ack_no_msg_type(dev, apdev): """WPS proto: M2 followed by ACK missing Msg Type""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8915,13 +8924,13 @@ def test_wps_ext_m2_ack_no_msg_type(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_ACK to AP") - ack,attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, - msg_type=None, eap_code=2) + ack, attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, + msg_type=None, eap_code=2) send_wsc_msg(hapd, addr, ack) wps_wait_eap_failure(hapd, dev[0]) @@ -8930,7 +8939,7 @@ def test_wps_ext_m2_ack_no_msg_type(dev, apdev): def test_wps_ext_m2_ack_invalid_msg_type(dev, apdev): """WPS proto: M2 followed by ACK with invalid Msg Type""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8954,12 +8963,12 @@ def test_wps_ext_m2_ack_invalid_msg_type(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_ACK to AP") - ack,attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, + ack, attrs = build_ack(msg['eap_identifier'], e_nonce, r_nonce, msg_type=WPS_WSC_NACK, eap_code=2) send_wsc_msg(hapd, addr, ack) @@ -8969,7 +8978,7 @@ def test_wps_ext_m2_ack_invalid_msg_type(dev, apdev): def test_wps_ext_m2_ack_e_nonce_mismatch(dev, apdev): """WPS proto: M2 followed by ACK with e-nonce mismatch""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -8993,13 +9002,13 @@ def test_wps_ext_m2_ack_e_nonce_mismatch(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send WSC_ACK to AP") - ack,attrs = build_ack(msg['eap_identifier'], 16*b'\x00', r_nonce, - eap_code=2) + ack, attrs = build_ack(msg['eap_identifier'], 16*b'\x00', r_nonce, + eap_code=2) send_wsc_msg(hapd, addr, ack) wps_wait_eap_failure(hapd, dev[0]) @@ -9008,7 +9017,7 @@ def test_wps_ext_m2_ack_e_nonce_mismatch(dev, apdev): def test_wps_ext_m1_invalid(dev, apdev): """WPS proto: M1 failing parsing""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -9027,7 +9036,7 @@ def test_wps_ext_m1_invalid(dev, apdev): def test_wps_ext_m1_missing_msg_type(dev, apdev): """WPS proto: M1 missing Msg Type""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -9045,7 +9054,7 @@ def test_wps_ext_m1_missing_msg_type(dev, apdev): def wps_ext_wsc_done(dev, apdev): pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -9069,9 +9078,9 @@ def wps_ext_wsc_done(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -9191,7 +9200,7 @@ def test_wps_ext_wsc_done_no_r_nonce(dev, apdev): def test_wps_ext_m7_no_encr_settings(dev, apdev): """WPS proto: M7 without Encr Settings""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -9215,9 +9224,9 @@ def test_wps_ext_m7_no_encr_settings(dev, apdev): r_nonce = m2_attrs[ATTR_REGISTRAR_NONCE] r_pk = m2_attrs[ATTR_PUBLIC_KEY] - authkey,keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, - r_nonce) - e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) + authkey, keywrapkey = wsc_dh_kdf(r_pk, own_private, mac_addr, e_nonce, + r_nonce) + e_s1, e_s2, e_hash1, e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk) logger.debug("Send M3 to AP") attrs = build_wsc_attr(ATTR_VERSION, '\x10') @@ -9264,7 +9273,7 @@ def test_wps_ext_m7_no_encr_settings(dev, apdev): def test_wps_ext_m1_workaround(dev, apdev): """WPS proto: M1 Manufacturer/Model workaround""" pin = "12345670" - addr,bssid,hapd = wps_start_ext(apdev[0], dev[0], pin=pin) + addr, bssid, hapd = wps_start_ext(apdev[0], dev[0], pin=pin) wps_ext_eap_identity_req(dev[0], hapd, bssid) wps_ext_eap_identity_resp(hapd, dev[0], addr) @@ -9403,9 +9412,9 @@ def test_ap_wps_upnp_web_oom(dev, apdev, params): with alloc_fail(hapd, 1, "web_connection_parse_subscribe"): conn = HTTPConnection(url.netloc) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) try: resp = conn.getresponse() @@ -9414,9 +9423,9 @@ def test_ap_wps_upnp_web_oom(dev, apdev, params): with alloc_fail(hapd, 1, "dup_binstr;web_connection_parse_subscribe"): conn = HTTPConnection(url.netloc) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("SUBSCRIBE", eventurl.path, "\r\n\r\n", headers) resp = conn.getresponse() if resp.status != 500: @@ -9424,9 +9433,9 @@ def test_ap_wps_upnp_web_oom(dev, apdev, params): with alloc_fail(hapd, 1, "wpabuf_alloc;web_connection_parse_unsubscribe"): conn = HTTPConnection(url.netloc) - headers = { "callback": '', - "NT": "upnp:event", - "timeout": "Second-1234" } + headers = {"callback": '', + "NT": "upnp:event", + "timeout": "Second-1234"} conn.request("UNSUBSCRIBE", eventurl.path, "\r\n\r\n", headers) try: resp = conn.getresponse() @@ -9462,10 +9471,10 @@ def test_ap_wps_eap_wsc_errors(dev, apdev): """WPS and EAP-WSC error cases""" ssid = "test-wps-conf-pin" appin = "12345670" - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "fragment_size": "300", "ap_pin": appin } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "fragment_size": "300", "ap_pin": appin} hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] @@ -9514,9 +9523,9 @@ def test_ap_wps_eap_wsc_errors(dev, apdev): wait_scan_stopped(dev[0]) dev[0].dump_monitor() - tests = [ "eap_wsc_init", - "eap_msg_alloc;eap_wsc_build_msg", - "wpabuf_alloc;eap_wsc_process_fragment" ] + tests = ["eap_wsc_init", + "eap_msg_alloc;eap_wsc_build_msg", + "wpabuf_alloc;eap_wsc_process_fragment"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].request("WPS_PIN %s %s" % (bssid, pin)) @@ -9656,14 +9665,14 @@ def test_ap_wps_and_bss_limit(dev, apdev): pass def _test_ap_wps_and_bss_limit(dev, apdev): - params = { "ssid": "test-wps", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" } + params = {"ssid": "test-wps", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "test-wps-2", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "1234567890", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" } + params = {"ssid": "test-wps-2", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "1234567890", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"} hapd2 = hostapd.add_ap(apdev[1], params) id = dev[1].add_network() @@ -9722,15 +9731,15 @@ def _test_ap_wps_and_bss_limit(dev, apdev): def test_ap_wps_pbc_2ap(dev, apdev): """WPS PBC with two APs advertising same SSID""" - params = { "ssid": "wps", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wps_independent": "1"} + params = {"ssid": "wps", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_independent": "1"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "wps", "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "123456789", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "wps_independent": "1"} + params = {"ssid": "wps", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "123456789", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_independent": "1"} hapd2 = hostapd.add_ap(apdev[1], params) hapd.request("WPS_PBC") @@ -9759,15 +9768,15 @@ def _test_ap_wps_er_enrollee_to_conf_ap(dev, apdev): ssid = "wps-er-enrollee-to-conf-ap" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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"} + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -9816,15 +9825,15 @@ def _test_ap_wps_er_enrollee_to_conf_ap2(dev, apdev): ssid = "wps-er-enrollee-to-conf-ap" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" - params = { "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"} + params = {"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"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -9868,8 +9877,8 @@ def test_ap_wps_ignore_broadcast_ssid(dev, apdev): """WPS AP trying to ignore broadcast SSID""" ssid = "test-wps" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1", - "ignore_broadcast_ssid": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1", + "ignore_broadcast_ssid": "1"}) if "FAIL" not in hapd.request("WPS_PBC"): raise Exception("WPS unexpectedly enabled") @@ -9877,8 +9886,8 @@ def test_ap_wps_wep(dev, apdev): """WPS AP trying to enable WEP""" ssid = "test-wps" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1", - "ieee80211n": "0", "wep_key0": '"hello"' }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1", + "ieee80211n": "0", "wep_key0": '"hello"'}) if "FAIL" not in hapd.request("WPS_PBC"): raise Exception("WPS unexpectedly enabled") @@ -9886,10 +9895,10 @@ def test_ap_wps_tkip(dev, apdev): """WPS AP trying to enable TKIP""" ssid = "test-wps" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1", - "ieee80211n": "0", "wpa": '1', - "wpa_key_mgmt": "WPA-PSK", - "wpa_passphrase": "12345678" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1", + "ieee80211n": "0", "wpa": '1', + "wpa_key_mgmt": "WPA-PSK", + "wpa_passphrase": "12345678"}) if "FAIL" not in hapd.request("WPS_PBC"): raise Exception("WPS unexpectedly enabled") @@ -9897,9 +9906,9 @@ def test_ap_wps_conf_dummy_cred(dev, apdev): """WPS PIN provisioning with configured AP using dummy cred""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) hapd.request("WPS_PIN any 12345670") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") dev[0].dump_monitor() @@ -9917,10 +9926,10 @@ def test_ap_wps_conf_dummy_cred(dev, apdev): def test_ap_wps_rf_bands(dev, apdev): """WPS and wps_rf_bands configuration""" 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", - "wps_rf_bands": "ag" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "wps_rf_bands": "ag"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -9947,11 +9956,11 @@ def test_ap_wps_rf_bands(dev, apdev): def test_ap_wps_pbc_in_m1(dev, apdev): """WPS and pbc_in_m1""" 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", - "config_methods": "virtual_push_button virtual_display", - "pbc_in_m1": "1" } + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "config_methods": "virtual_push_button virtual_display", + "pbc_in_m1": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -10001,9 +10010,9 @@ def test_ap_wps_random_uuid(dev, apdev, params): """WPS and random UUID on Enrollee""" ssid = "test-wps-conf" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) config = os.path.join(params['logdir'], 'ap_wps_random_uuid.conf') with open(config, "w") as f: @@ -10051,10 +10060,10 @@ def run_ap_wps_conf_pin_cipher(dev, apdev, cipher): raise HwsimSkip("Cipher %s not supported" % cipher) ssid = "test-wps-conf-pin" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", - "rsn_pairwise": cipher }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", + "rsn_pairwise": cipher}) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -10072,8 +10081,8 @@ def test_ap_wps_and_sae(dev, apdev): def run_ap_wps_and_sae(dev, apdev): ssid = "test-wps-sae" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "1", - "wps_cred_add_sae": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "1", + "wps_cred_add_sae": "1"}) logger.info("WPS provisioning step") pin = dev[0].wps_read_pin() hapd.request("WPS_PIN any " + pin) @@ -10109,11 +10118,11 @@ def test_ap_wps_conf_and_sae(dev, apdev): def run_ap_wps_conf_and_sae(dev, apdev): ssid = "test-wps-conf-sae" hapd = hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "ieee80211w": "1", "sae_require_mfp": "1", - "wpa_key_mgmt": "WPA-PSK SAE", - "rsn_pairwise": "CCMP" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "ieee80211w": "1", "sae_require_mfp": "1", + "wpa_key_mgmt": "WPA-PSK SAE", + "rsn_pairwise": "CCMP"}) dev[0].set("wps_cred_add_sae", "1") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -10141,8 +10150,8 @@ def run_ap_wps_reg_config_and_sae(dev, apdev): ssid = "test-wps-init-ap-pin-sae" appin = "12345670" hostapd.add_ap(apdev[0], - { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "ap_pin": appin, "wps_cred_add_sae": "1" }) + {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "ap_pin": appin, "wps_cred_add_sae": "1"}) logger.info("WPS configuration step") dev[0].set("wps_cred_add_sae", "1") dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412) diff --git a/tests/hwsim/test_authsrv.py b/tests/hwsim/test_authsrv.py index ef11728..bdd47bf 100644 --- a/tests/hwsim/test_authsrv.py +++ b/tests/hwsim/test_authsrv.py @@ -8,16 +8,16 @@ import hostapd from utils import alloc_fail, fail_test, wait_fail_trigger def authsrv_params(): - params = { "ssid": "as", "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "eap_sim_db": "unix:/tmp/hlr_auc_gw.sock", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key", - "eap_message": "hello" } + params = {"ssid": "as", "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "eap_sim_db": "unix:/tmp/hlr_auc_gw.sock", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key", + "eap_message": "hello"} return params def test_authsrv_oom(dev, apdev): @@ -84,8 +84,8 @@ def test_authsrv_oom(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ "radius_server_encapsulate_eap", - "radius_server_receive_auth" ] + tests = ["radius_server_encapsulate_eap", + "radius_server_receive_auth"] for t in tests: with alloc_fail(authsrv, 1, t): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -98,9 +98,9 @@ def test_authsrv_oom(dev, apdev): dev[0].wait_disconnected() dev[0].dump_monitor() - tests = [ "radius_msg_add_attr;radius_server_encapsulate_eap", - "radius_msg_add_eap;radius_server_encapsulate_eap", - "radius_msg_finish_srv;radius_server_encapsulate_eap" ] + tests = ["radius_msg_add_attr;radius_server_encapsulate_eap", + "radius_msg_add_eap;radius_server_encapsulate_eap", + "radius_msg_finish_srv;radius_server_encapsulate_eap"] for t in tests: with fail_test(authsrv, 1, t): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -204,16 +204,16 @@ def test_authsrv_testing_options(dev, apdev): # The first two would be fine to run with any server build; the rest are # actually supposed to fail, but they don't fail when using a server build # that does not support the TLS protocol tests. - tests = [ "foo@test-unknown", - "foo@test-tls-unknown", - "foo@test-tls-1", - "foo@test-tls-2", - "foo@test-tls-3", - "foo@test-tls-4", - "foo@test-tls-5", - "foo@test-tls-6", - "foo@test-tls-7", - "foo@test-tls-8" ] + tests = ["foo@test-unknown", + "foo@test-tls-unknown", + "foo@test-tls-1", + "foo@test-tls-2", + "foo@test-tls-3", + "foo@test-tls-4", + "foo@test-tls-5", + "foo@test-tls-6", + "foo@test-tls-7", + "foo@test-tls-8"] for t in tests: dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS", identity="user", diff --git a/tests/hwsim/test_autoscan.py b/tests/hwsim/test_autoscan.py index 25db662..544cd00 100644 --- a/tests/hwsim/test_autoscan.py +++ b/tests/hwsim/test_autoscan.py @@ -14,7 +14,7 @@ import hostapd def test_autoscan_periodic(dev, apdev): """autoscan_periodic""" - hostapd.add_ap(apdev[0], { "ssid": "autoscan" }) + hostapd.add_ap(apdev[0], {"ssid": "autoscan"}) try: if "OK" not in dev[0].request("AUTOSCAN periodic:1"): @@ -55,7 +55,7 @@ def test_autoscan_periodic(dev, apdev): @remote_compatible def test_autoscan_exponential(dev, apdev): """autoscan_exponential""" - hostapd.add_ap(apdev[0], { "ssid": "autoscan" }) + hostapd.add_ap(apdev[0], {"ssid": "autoscan"}) try: if "OK" not in dev[0].request("AUTOSCAN exponential:2:10"): diff --git a/tests/hwsim/test_bgscan.py b/tests/hwsim/test_bgscan.py index 06eb126..f418f56 100644 --- a/tests/hwsim/test_bgscan.py +++ b/tests/hwsim/test_bgscan.py @@ -14,8 +14,8 @@ from utils import alloc_fail, fail_test def test_bgscan_simple(dev, apdev): """bgscan_simple""" - hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) - hostapd.add_ap(apdev[1], { "ssid": "bgscan" }) + hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) + hostapd.add_ap(apdev[1], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="simple:1:-20:2") @@ -71,7 +71,7 @@ def test_bgscan_simple(dev, apdev): def test_bgscan_simple_beacon_loss(dev, apdev): """bgscan_simple and beacon loss""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="simple:1:-20:2") @@ -84,7 +84,7 @@ def test_bgscan_simple_beacon_loss(dev, apdev): def test_bgscan_simple_scan_failure(dev, apdev): """bgscan_simple and scan failure""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="simple:1:-20:2") @@ -99,7 +99,7 @@ def test_bgscan_simple_scan_failure(dev, apdev): def test_bgscan_simple_scanning(dev, apdev): """bgscan_simple and scanning behavior""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="simple:1:-20:2") @@ -113,7 +113,7 @@ def test_bgscan_simple_scanning(dev, apdev): def test_bgscan_simple_same_scan_int(dev, apdev): """bgscan_simple and same short/long scan interval""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="simple:1:-20:1") @@ -124,7 +124,7 @@ def test_bgscan_simple_same_scan_int(dev, apdev): def test_bgscan_simple_oom(dev, apdev): """bgscan_simple OOM""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) with alloc_fail(dev[0], 1, "bgscan_simple_init"): dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", @@ -132,7 +132,7 @@ def test_bgscan_simple_oom(dev, apdev): def test_bgscan_simple_driver_conf_failure(dev, apdev): """bgscan_simple driver configuration failure""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) with fail_test(dev[0], 1, "bgscan_simple_init"): dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", @@ -140,8 +140,8 @@ def test_bgscan_simple_driver_conf_failure(dev, apdev): def test_bgscan_learn(dev, apdev): """bgscan_learn""" - hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) - hostapd.add_ap(apdev[1], { "ssid": "bgscan" }) + hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) + hostapd.add_ap(apdev[1], {"ssid": "bgscan"}) try: os.remove("/tmp/test_bgscan_learn.bgscan") @@ -238,7 +238,7 @@ def test_bgscan_learn(dev, apdev): def test_bgscan_learn_beacon_loss(dev, apdev): """bgscan_simple and beacon loss""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="learn:1:-20:2") @@ -251,7 +251,7 @@ def test_bgscan_learn_beacon_loss(dev, apdev): def test_bgscan_learn_scan_failure(dev, apdev): """bgscan_learn and scan failure""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="learn:1:-20:2") @@ -266,7 +266,7 @@ def test_bgscan_learn_scan_failure(dev, apdev): def test_bgscan_learn_oom(dev, apdev): """bgscan_learn OOM""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) with alloc_fail(dev[0], 1, "bgscan_learn_init"): dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", @@ -274,7 +274,7 @@ def test_bgscan_learn_oom(dev, apdev): def test_bgscan_learn_driver_conf_failure(dev, apdev): """bgscan_learn driver configuration failure""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) with fail_test(dev[0], 1, "bgscan_learn_init"): dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", @@ -282,6 +282,6 @@ def test_bgscan_learn_driver_conf_failure(dev, apdev): def test_bgscan_unknown_module(dev, apdev): """bgscan init failing due to unknown module""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"}) dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412", bgscan="unknown:-20:2") diff --git a/tests/hwsim/test_cfg80211.py b/tests/hwsim/test_cfg80211.py index 0890984..a461fe0 100644 --- a/tests/hwsim/test_cfg80211.py +++ b/tests/hwsim/test_cfg80211.py @@ -27,9 +27,9 @@ def nl80211_command(dev, cmd, attr): @remote_compatible def test_cfg80211_disassociate(dev, apdev): """cfg80211 disassociation command""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") @@ -39,7 +39,7 @@ def test_cfg80211_disassociate(dev, apdev): attrs += build_nl80211_attr_mac('MAC', apdev[0]['bssid']) nl80211_command(dev[0], 'DISASSOCIATE', attrs) - ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5) if ev is None: raise Exception("No disconnection event received from hostapd") @@ -102,10 +102,10 @@ def test_cfg80211_tx_frame(dev, apdev, params): def test_cfg80211_wep_key_idx_change(dev, apdev): """WEP Shared Key authentication and key index change without deauth""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-shared-key", - "wep_key0": '"hello12345678"', - "wep_key1": '"other12345678"', - "auth_algs": "2" }) + {"ssid": "wep-shared-key", + "wep_key0": '"hello12345678"', + "wep_key1": '"other12345678"', + "auth_algs": "2"}) id = dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", wep_key0='"hello12345678"', wep_key1='"other12345678"', @@ -131,8 +131,7 @@ def test_cfg80211_wep_key_idx_change(dev, apdev): @remote_compatible def test_cfg80211_hostapd_ext_sta_remove(dev, apdev): """cfg80211 DEL_STATION issued externally to hostapd""" - hapd = hostapd.add_ap(apdev[0], - { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") ifindex = int(hapd.get_driver_status_field("ifindex")) diff --git a/tests/hwsim/test_connect_cmd.py b/tests/hwsim/test_connect_cmd.py index 630ea22..87122aa 100644 --- a/tests/hwsim/test_connect_cmd.py +++ b/tests/hwsim/test_connect_cmd.py @@ -15,9 +15,9 @@ from p2p_utils import * def test_connect_cmd_open(dev, apdev): """Open connection using cfg80211 connect command""" - params = { "ssid": "sta-connect", - "manage_p2p": "1", - "allow_cross_connection": "1" } + params = {"ssid": "sta-connect", + "manage_p2p": "1", + "allow_cross_connection": "1"} hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -31,7 +31,7 @@ def test_connect_cmd_open(dev, apdev): def test_connect_cmd_wep(dev, apdev): """WEP Open System using cfg80211 connect command""" - params = { "ssid": "sta-connect-wep", "wep_key0": '"hello"' } + params = {"ssid": "sta-connect-wep", "wep_key0": '"hello"'} hapd = hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -46,8 +46,8 @@ def test_connect_cmd_wep(dev, apdev): def test_connect_cmd_wep_shared(dev, apdev): """WEP Shared key using cfg80211 connect command""" - params = { "ssid": "sta-connect-wep", "wep_key0": '"hello"', - "auth_algs": "2" } + params = {"ssid": "sta-connect-wep", "wep_key0": '"hello"', + "auth_algs": "2"} hapd = hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -68,9 +68,9 @@ def test_connect_cmd_wep_shared(dev, apdev): def test_connect_cmd_p2p_management(dev, apdev): """Open connection using cfg80211 connect command and AP using P2P management""" - params = { "ssid": "sta-connect", - "manage_p2p": "1", - "allow_cross_connection": "0" } + params = {"ssid": "sta-connect", + "manage_p2p": "1", + "allow_cross_connection": "0"} hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -97,7 +97,7 @@ def test_connect_cmd_wpa2_psk(dev, apdev): def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev): """Concurrent P2P group formation while connecting to an AP using cfg80211 connect command""" logger.info("Start connection to an infrastructure AP") - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") @@ -122,8 +122,8 @@ def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev): def test_connect_cmd_reject_assoc(dev, apdev): """Connection using cfg80211 connect command getting rejected""" - params = { "ssid": "sta-connect", - "require_ht": "1" } + params = {"ssid": "sta-connect", + "require_ht": "1"} hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -141,7 +141,7 @@ def test_connect_cmd_reject_assoc(dev, apdev): def test_connect_cmd_disconnect_event(dev, apdev): """Connection using cfg80211 connect command getting disconnected by the AP""" - params = { "ssid": "sta-connect" } + params = {"ssid": "sta-connect"} hapd = hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -170,7 +170,7 @@ def test_connect_cmd_disconnect_event(dev, apdev): def test_connect_cmd_roam(dev, apdev): """cfg80211 connect command to trigger roam""" - params = { "ssid": "sta-connect" } + params = {"ssid": "sta-connect"} hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') @@ -188,7 +188,7 @@ def test_connect_cmd_roam(dev, apdev): def test_connect_cmd_bssid_hint(dev, apdev): """cfg80211 connect command with bssid_hint""" - params = { "ssid": "sta-connect" } + params = {"ssid": "sta-connect"} hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[1], params) diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index 16fcf3c..55d74bb 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -55,7 +55,7 @@ def prepare_dbus(dev): wpas = dbus.Interface(wpas_obj, WPAS_DBUS_SERVICE) path = wpas.GetInterface(dev.ifname) if_obj = bus.get_object(WPAS_DBUS_SERVICE, path) - return (bus,wpas_obj,path,if_obj) + return (bus, wpas_obj, path, if_obj) except Exception as e: raise HwsimSkip("Could not connect to D-Bus: %s" % e) @@ -103,15 +103,15 @@ class alloc_fail_dbus(object): def start_ap(ap, ssid="test-wps", ap_uuid="27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"): - params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", - "wpa_passphrase": "12345678", "wpa": "2", - "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", - "ap_pin": "12345670", "uuid": ap_uuid} + params = {"ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "ap_pin": "12345670", "uuid": ap_uuid} return hostapd.add_ap(ap, params) def test_dbus_getall(dev, apdev): """D-Bus GetAll""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) props = wpas_obj.GetAll(WPAS_DBUS_SERVICE, dbus_interface=dbus.PROPERTIES_IFACE) @@ -135,7 +135,7 @@ def test_dbus_getall(dev, apdev): if len(res) != 0: raise Exception("Unexpected Networks entry: " + str(res)) - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) bssid = apdev[0]['bssid'] dev[0].scan_for_bss(bssid, freq=2412) id = dev[0].add_network() @@ -171,7 +171,7 @@ def test_dbus_getall(dev, apdev): def test_dbus_getall_oom(dev, apdev): """D-Bus GetAll wpa_config_get_all() OOM""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) id = dev[0].add_network() dev[0].set_network(id, "disabled", "0") @@ -205,13 +205,13 @@ def dbus_set(dbus, wpas_obj, prop, val): def test_dbus_properties(dev, apdev): """D-Bus Get/Set fi.w1.wpa_supplicant1 properties""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) dbus_get(dbus, wpas_obj, "DebugLevel", expect="msgdump") dbus_set(dbus, wpas_obj, "DebugLevel", "debug") dbus_get(dbus, wpas_obj, "DebugLevel", expect="debug") - for (val,err) in [ (3, "Error.Failed: wrong property type"), - ("foo", "Error.Failed: wrong debug level value") ]: + for (val, err) in [(3, "Error.Failed: wrong property type"), + ("foo", "Error.Failed: wrong debug level value")]: try: dbus_set(dbus, wpas_obj, "DebugLevel", val) raise Exception("Invalid DebugLevel value accepted: " + str(val)) @@ -328,10 +328,10 @@ def test_dbus_properties(dev, apdev): def test_dbus_set_global_properties(dev, apdev): """D-Bus Get/Set fi.w1.wpa_supplicant1 interface global properties""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) dev[0].set("model_name", "") - props = [ ('Okc', '0', '1'), ('ModelName', '', 'blahblahblah') ] + props = [('Okc', '0', '1'), ('ModelName', '', 'blahblahblah')] for p in props: res = if_obj.Get(WPAS_DBUS_IFACE, p[0], @@ -350,7 +350,7 @@ def test_dbus_set_global_properties(dev, apdev): def test_dbus_invalid_method(dev, apdev): """D-Bus invalid method""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) try: @@ -384,7 +384,7 @@ def test_dbus_get_set_wps(dev, apdev): dev[0].set("device_type", "0-00000000-0") def _test_dbus_get_set_wps(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) if_obj.Get(WPAS_DBUS_IFACE_WPS, "ConfigMethods", dbus_interface=dbus.PROPERTIES_IFACE) @@ -415,13 +415,13 @@ def _test_dbus_get_set_wps(dev, apdev): if val != expected_val: raise Exception("Unexpected Get(ProcessCredentials) result({}): {}".format(i, val)) - tests = [ ("device_name", "DeviceName"), - ("manufacturer", "Manufacturer"), - ("model_name", "ModelName"), - ("model_number", "ModelNumber"), - ("serial_number", "SerialNumber") ] + tests = [("device_name", "DeviceName"), + ("manufacturer", "Manufacturer"), + ("model_name", "ModelName"), + ("model_number", "ModelNumber"), + ("serial_number", "SerialNumber")] - for f1,f2 in tests: + for f1, f2 in tests: val2 = "test-value-test" dev[0].set(f1, val2) val = if_obj.Get(WPAS_DBUS_IFACE_WPS, f2, @@ -518,26 +518,26 @@ def _test_dbus_get_set_wps(dev, apdev): def test_dbus_wps_invalid(dev, apdev): """D-Bus invaldi WPS operation""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) - failures = [ {'Role': 'foo', 'Type': 'pbc'}, - {'Role': 123, 'Type': 'pbc'}, - {'Type': 'pbc'}, - {'Role': 'enrollee'}, - {'Role': 'registrar'}, - {'Role': 'enrollee', 'Type': 123}, - {'Role': 'enrollee', 'Type': 'foo'}, - {'Role': 'enrollee', 'Type': 'pbc', - 'Bssid': '02:33:44:55:66:77'}, - {'Role': 'enrollee', 'Type': 'pin', 'Pin': 123}, - {'Role': 'enrollee', 'Type': 'pbc', - 'Bssid': dbus.ByteArray(b'12345')}, - {'Role': 'enrollee', 'Type': 'pbc', - 'P2PDeviceAddress': 12345}, - {'Role': 'enrollee', 'Type': 'pbc', - 'P2PDeviceAddress': dbus.ByteArray(b'12345')}, - {'Role': 'enrollee', 'Type': 'pbc', 'Foo': 'bar'} ] + failures = [{'Role': 'foo', 'Type': 'pbc'}, + {'Role': 123, 'Type': 'pbc'}, + {'Type': 'pbc'}, + {'Role': 'enrollee'}, + {'Role': 'registrar'}, + {'Role': 'enrollee', 'Type': 123}, + {'Role': 'enrollee', 'Type': 'foo'}, + {'Role': 'enrollee', 'Type': 'pbc', + 'Bssid': '02:33:44:55:66:77'}, + {'Role': 'enrollee', 'Type': 'pin', 'Pin': 123}, + {'Role': 'enrollee', 'Type': 'pbc', + 'Bssid': dbus.ByteArray(b'12345')}, + {'Role': 'enrollee', 'Type': 'pbc', + 'P2PDeviceAddress': 12345}, + {'Role': 'enrollee', 'Type': 'pbc', + 'P2PDeviceAddress': dbus.ByteArray(b'12345')}, + {'Role': 'enrollee', 'Type': 'pbc', 'Foo': 'bar'}] for args in failures: try: wps.Start(args) @@ -548,14 +548,14 @@ def test_dbus_wps_invalid(dev, apdev): def test_dbus_wps_oom(dev, apdev): """D-Bus WPS operation (OOM)""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_getter_state", "Get"): if_obj.Get(WPAS_DBUS_IFACE, "State", dbus_interface=dbus.PROPERTIES_IFACE) - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) bssid = apdev[0]['bssid'] dev[0].scan_for_bss(bssid, freq=2412) @@ -614,7 +614,7 @@ def test_dbus_wps_pbc(dev, apdev): dev[0].request("SET wps_cred_processing 0") def _test_dbus_wps_pbc(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -685,7 +685,7 @@ def _test_dbus_wps_pbc(dev, apdev): def test_dbus_wps_pbc_overlap(dev, apdev): """D-Bus WPS/PBC operation and signal for PBC overlap""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -742,7 +742,7 @@ def test_dbus_wps_pin(dev, apdev): dev[0].request("SET wps_cred_processing 0") def _test_dbus_wps_pin(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -781,7 +781,7 @@ def _test_dbus_wps_pin(dev, apdev): def start_pin(self, *args): logger.debug("start_pin") - bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':', '').encode())) wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) return False @@ -803,7 +803,7 @@ def test_dbus_wps_pin2(dev, apdev): dev[0].request("SET wps_cred_processing 0") def _test_dbus_wps_pin2(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -841,7 +841,7 @@ def _test_dbus_wps_pin2(dev, apdev): def start_pin(self, *args): logger.debug("start_pin") - bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':', '').encode())) res = wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Bssid': bssid_ay}) pin = res['Pin'] @@ -866,7 +866,7 @@ def test_dbus_wps_pin_m2d(dev, apdev): dev[0].request("SET wps_cred_processing 0") def _test_dbus_wps_pin_m2d(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -907,7 +907,7 @@ def _test_dbus_wps_pin_m2d(dev, apdev): def start_pin(self, *args): logger.debug("start_pin") - bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':', '').encode())) wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) return False @@ -929,7 +929,7 @@ def test_dbus_wps_reg(dev, apdev): dev[0].request("SET wps_cred_processing 0") def _test_dbus_wps_reg(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -962,7 +962,7 @@ def _test_dbus_wps_reg(dev, apdev): def start_reg(self, *args): logger.debug("start_reg") - bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':', '').encode())) wps.Start({'Role': 'registrar', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) return False @@ -978,7 +978,7 @@ def _test_dbus_wps_reg(dev, apdev): def test_dbus_wps_cancel(dev, apdev): """D-Bus WPS Cancel operation""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wps = dbus.Interface(if_obj, WPAS_DBUS_IFACE_WPS) hapd = start_ap(apdev[0]) @@ -986,7 +986,7 @@ def test_dbus_wps_cancel(dev, apdev): wps.Cancel() dev[0].scan_for_bss(bssid, freq="2412") - bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':', '').encode())) wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) wps.Cancel() @@ -994,45 +994,45 @@ def test_dbus_wps_cancel(dev, apdev): def test_dbus_scan_invalid(dev, apdev): """D-Bus invalid scan method""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - tests = [ ({}, "InvalidArgs"), - ({'Type': 123}, "InvalidArgs"), - ({'Type': 'foo'}, "InvalidArgs"), - ({'Type': 'active', 'Foo': 'bar'}, "InvalidArgs"), - ({'Type': 'active', 'SSIDs': 'foo'}, "InvalidArgs"), - ({'Type': 'active', 'SSIDs': ['foo']}, "InvalidArgs"), - ({'Type': 'active', - 'SSIDs': [ dbus.ByteArray(b"1"), dbus.ByteArray(b"2"), - dbus.ByteArray(b"3"), dbus.ByteArray(b"4"), - dbus.ByteArray(b"5"), dbus.ByteArray(b"6"), - dbus.ByteArray(b"7"), dbus.ByteArray(b"8"), - dbus.ByteArray(b"9"), dbus.ByteArray(b"10"), - dbus.ByteArray(b"11"), dbus.ByteArray(b"12"), - dbus.ByteArray(b"13"), dbus.ByteArray(b"14"), - dbus.ByteArray(b"15"), dbus.ByteArray(b"16"), - dbus.ByteArray(b"17") ]}, - "InvalidArgs"), - ({'Type': 'active', - 'SSIDs': [ dbus.ByteArray(b"1234567890abcdef1234567890abcdef1") ]}, - "InvalidArgs"), - ({'Type': 'active', 'IEs': 'foo'}, "InvalidArgs"), - ({'Type': 'active', 'IEs': ['foo']}, "InvalidArgs"), - ({'Type': 'active', 'Channels': 2412 }, "InvalidArgs"), - ({'Type': 'active', 'Channels': [ 2412 ] }, "InvalidArgs"), - ({'Type': 'active', - 'Channels': [ (dbus.Int32(2412), dbus.UInt32(20)) ] }, - "InvalidArgs"), - ({'Type': 'active', - 'Channels': [ (dbus.UInt32(2412), dbus.Int32(20)) ] }, - "InvalidArgs"), - ({'Type': 'active', 'AllowRoam': "yes" }, "InvalidArgs"), - ({'Type': 'passive', 'IEs': [ dbus.ByteArray(b"\xdd\x00") ]}, - "InvalidArgs"), - ({'Type': 'passive', 'SSIDs': [ dbus.ByteArray(b"foo") ]}, - "InvalidArgs")] - for (t,err) in tests: + tests = [({}, "InvalidArgs"), + ({'Type': 123}, "InvalidArgs"), + ({'Type': 'foo'}, "InvalidArgs"), + ({'Type': 'active', 'Foo': 'bar'}, "InvalidArgs"), + ({'Type': 'active', 'SSIDs': 'foo'}, "InvalidArgs"), + ({'Type': 'active', 'SSIDs': ['foo']}, "InvalidArgs"), + ({'Type': 'active', + 'SSIDs': [dbus.ByteArray(b"1"), dbus.ByteArray(b"2"), + dbus.ByteArray(b"3"), dbus.ByteArray(b"4"), + dbus.ByteArray(b"5"), dbus.ByteArray(b"6"), + dbus.ByteArray(b"7"), dbus.ByteArray(b"8"), + dbus.ByteArray(b"9"), dbus.ByteArray(b"10"), + dbus.ByteArray(b"11"), dbus.ByteArray(b"12"), + dbus.ByteArray(b"13"), dbus.ByteArray(b"14"), + dbus.ByteArray(b"15"), dbus.ByteArray(b"16"), + dbus.ByteArray(b"17")]}, + "InvalidArgs"), + ({'Type': 'active', + 'SSIDs': [dbus.ByteArray(b"1234567890abcdef1234567890abcdef1")]}, + "InvalidArgs"), + ({'Type': 'active', 'IEs': 'foo'}, "InvalidArgs"), + ({'Type': 'active', 'IEs': ['foo']}, "InvalidArgs"), + ({'Type': 'active', 'Channels': 2412}, "InvalidArgs"), + ({'Type': 'active', 'Channels': [2412]}, "InvalidArgs"), + ({'Type': 'active', + 'Channels': [(dbus.Int32(2412), dbus.UInt32(20))]}, + "InvalidArgs"), + ({'Type': 'active', + 'Channels': [(dbus.UInt32(2412), dbus.Int32(20))]}, + "InvalidArgs"), + ({'Type': 'active', 'AllowRoam': "yes"}, "InvalidArgs"), + ({'Type': 'passive', 'IEs': [dbus.ByteArray(b"\xdd\x00")]}, + "InvalidArgs"), + ({'Type': 'passive', 'SSIDs': [dbus.ByteArray(b"foo")]}, + "InvalidArgs")] + for (t, err) in tests: try: iface.Scan(t) raise Exception("Invalid Scan() arguments accepted: " + str(t)) @@ -1042,42 +1042,42 @@ def test_dbus_scan_invalid(dev, apdev): def test_dbus_scan_oom(dev, apdev): """D-Bus scan method and OOM""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) with alloc_fail_dbus(dev[0], 1, "wpa_scan_clone_params;wpas_dbus_handler_scan", "Scan", expected="ScanError: Scan request rejected"): - iface.Scan({ 'Type': 'passive', - 'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] }) + iface.Scan({'Type': 'passive', + 'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]}) with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_get_scan_channels;wpas_dbus_handler_scan", "Scan"): - iface.Scan({ 'Type': 'passive', - 'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] }) + iface.Scan({'Type': 'passive', + 'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]}) with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_get_scan_ies;wpas_dbus_handler_scan", "Scan"): - iface.Scan({ 'Type': 'active', - 'IEs': [ dbus.ByteArray(b"\xdd\x00") ], - 'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] }) + iface.Scan({'Type': 'active', + 'IEs': [dbus.ByteArray(b"\xdd\x00")], + 'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]}) with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_get_scan_ssids;wpas_dbus_handler_scan", "Scan"): - iface.Scan({ 'Type': 'active', - 'SSIDs': [ dbus.ByteArray(b"open"), - dbus.ByteArray() ], - 'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] }) + iface.Scan({'Type': 'active', + 'SSIDs': [dbus.ByteArray(b"open"), + dbus.ByteArray()], + 'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]}) def test_dbus_scan(dev, apdev): """D-Bus scan and related signals""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) class TestDbusScan(TestDbus): def __init__(self, bus): @@ -1125,10 +1125,10 @@ def test_dbus_scan(dev, apdev): def run_scan(self, *args): logger.debug("run_scan") iface.Scan({'Type': 'active', - 'SSIDs': [ dbus.ByteArray(b"open"), - dbus.ByteArray() ], - 'IEs': [ dbus.ByteArray(b"\xdd\x00"), - dbus.ByteArray() ], + 'SSIDs': [dbus.ByteArray(b"open"), + dbus.ByteArray()], + 'IEs': [dbus.ByteArray(b"\xdd\x00"), + dbus.ByteArray()], 'AllowRoam': False, 'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]}) return False @@ -1155,7 +1155,7 @@ def test_dbus_scan(dev, apdev): def test_dbus_scan_busy(dev, apdev): """D-Bus scan trigger rejection when busy with previous scan""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) if "OK" not in dev[0].request("SCAN freq=2412-2462"): @@ -1177,7 +1177,7 @@ def test_dbus_scan_busy(dev, apdev): def test_dbus_scan_abort(dev, apdev): """D-Bus scan trigger and abort""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) iface.Scan({'Type': 'active', 'AllowRoam': False}) @@ -1199,7 +1199,7 @@ def test_dbus_scan_abort(dev, apdev): def test_dbus_connect(dev, apdev): """D-Bus AddNetwork and connect""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) ssid = "test-wpa2-psk" @@ -1280,10 +1280,10 @@ def test_dbus_connect(dev, apdev): def run_connect(self, *args): logger.debug("run_connect") - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'WPA-PSK', - 'psk': passphrase, - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'WPA-PSK', + 'psk': passphrase, + 'scan_freq': 2412}, signature='sv') self.netw = iface.AddNetwork(args) iface.SelectNetwork(self.netw) @@ -1302,7 +1302,7 @@ def test_dbus_connect(dev, apdev): def test_dbus_connect_psk_mem(dev, apdev): """D-Bus AddNetwork and connect with memory-only PSK""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) ssid = "test-wpa2-psk" @@ -1338,10 +1338,10 @@ def test_dbus_connect_psk_mem(dev, apdev): def run_connect(self, *args): logger.debug("run_connect") - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'WPA-PSK', - 'mem_only_psk': 1, - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'WPA-PSK', + 'mem_only_psk': 1, + 'scan_freq': 2412}, signature='sv') self.netw = iface.AddNetwork(args) iface.SelectNetwork(self.netw) @@ -1356,7 +1356,7 @@ def test_dbus_connect_psk_mem(dev, apdev): def test_dbus_connect_oom(dev, apdev): """D-Bus AddNetwork and connect when out-of-memory""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) if "OK" not in dev[0].request("TEST_ALLOC_FAIL 0:"): @@ -1434,10 +1434,10 @@ def test_dbus_connect_oom(dev, apdev): def run_connect(self, *args): logger.debug("run_connect") - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'WPA-PSK', - 'psk': passphrase, - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'WPA-PSK', + 'psk': passphrase, + 'scan_freq': 2412}, signature='sv') try: self.netw = iface.AddNetwork(args) @@ -1498,7 +1498,7 @@ def test_dbus_connect_oom(dev, apdev): def test_dbus_while_not_connected(dev, apdev): """D-Bus invalid operations while not connected""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) try: @@ -1518,7 +1518,7 @@ def test_dbus_while_not_connected(dev, apdev): def test_dbus_connect_eap(dev, apdev): """D-Bus AddNetwork and connect to EAP network""" check_altsubject_match_support(dev[0]) - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) ssid = "ieee8021x-open" @@ -1555,8 +1555,8 @@ def test_dbus_connect_eap(dev, apdev): iface.EAPLogoff() logger.info("Set dNSName constraint") net_obj = bus.get_object(WPAS_DBUS_SERVICE, self.netw) - args = dbus.Dictionary({ 'altsubject_match': - self.server_dnsname }, + args = dbus.Dictionary({'altsubject_match': + self.server_dnsname}, signature='sv') net_obj.Set(WPAS_DBUS_NETWORK, "Properties", args, dbus_interface=dbus.PROPERTIES_IFACE) @@ -1565,8 +1565,8 @@ def test_dbus_connect_eap(dev, apdev): iface.Disconnect() logger.info("Set non-matching dNSName constraint") net_obj = bus.get_object(WPAS_DBUS_SERVICE, self.netw) - args = dbus.Dictionary({ 'altsubject_match': - self.server_dnsname + "FOO" }, + args = dbus.Dictionary({'altsubject_match': + self.server_dnsname + "FOO"}, signature='sv') net_obj.Set(WPAS_DBUS_NETWORK, "Properties", args, dbus_interface=dbus.PROPERTIES_IFACE) @@ -1607,15 +1607,15 @@ def test_dbus_connect_eap(dev, apdev): def run_connect(self, *args): logger.debug("run_connect") - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'IEEE8021X', - 'eapol_flags': 0, - 'eap': 'TTLS', - 'anonymous_identity': 'ttls', - 'identity': 'pap user', - 'ca_cert': 'auth_serv/ca.pem', - 'phase2': 'auth=PAP', - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'IEEE8021X', + 'eapol_flags': 0, + 'eap': 'TTLS', + 'anonymous_identity': 'ttls', + 'identity': 'pap user', + 'ca_cert': 'auth_serv/ca.pem', + 'phase2': 'auth=PAP', + 'scan_freq': 2412}, signature='sv') self.netw = iface.AddNetwork(args) iface.SelectNetwork(self.netw) @@ -1632,15 +1632,15 @@ def test_dbus_connect_eap(dev, apdev): def test_dbus_network(dev, apdev): """D-Bus AddNetwork/RemoveNetwork parameters and error cases""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - args = dbus.Dictionary({ 'ssid': "foo", - 'key_mgmt': 'WPA-PSK', - 'psk': "12345678", - 'identity': dbus.ByteArray([ 1, 2 ]), - 'priority': dbus.Int32(0), - 'scan_freq': dbus.UInt32(2412) }, + args = dbus.Dictionary({'ssid': "foo", + 'key_mgmt': 'WPA-PSK', + 'psk': "12345678", + 'identity': dbus.ByteArray([1, 2]), + 'priority': dbus.Int32(0), + 'scan_freq': dbus.UInt32(2412)}, signature='sv') netw = iface.AddNetwork(args) id = int(dev[0].list_networks()[0]['id']) @@ -1649,10 +1649,10 @@ def test_dbus_network(dev, apdev): raise Exception("Invalid scan_freq value: " + str(val)) iface.RemoveNetwork(netw) - args = dbus.Dictionary({ 'ssid': "foo", - 'key_mgmt': 'NONE', - 'scan_freq': "2412 2432", - 'freq_list': "2412 2417 2432" }, + args = dbus.Dictionary({'ssid': "foo", + 'key_mgmt': 'NONE', + 'scan_freq': "2412 2432", + 'freq_list': "2412 2417 2432"}, signature='sv') netw = iface.AddNetwork(args) id = int(dev[0].list_networks()[0]['id']) @@ -1676,11 +1676,11 @@ def test_dbus_network(dev, apdev): if "NetworkUnknown" not in str(e): raise Exception("Unexpected error message for invalid RemoveNetwork: " + str(e)) - args = dbus.Dictionary({ 'ssid': "foo1", 'key_mgmt': 'NONE', - 'identity': "testuser", 'scan_freq': '2412' }, + args = dbus.Dictionary({'ssid': "foo1", 'key_mgmt': 'NONE', + 'identity': "testuser", 'scan_freq': '2412'}, signature='sv') netw1 = iface.AddNetwork(args) - args = dbus.Dictionary({ 'ssid': "foo2", 'key_mgmt': 'NONE' }, + args = dbus.Dictionary({'ssid': "foo2", 'key_mgmt': 'NONE'}, signature='sv') netw2 = iface.AddNetwork(args) res = if_obj.Get(WPAS_DBUS_IFACE, "Networks", @@ -1713,7 +1713,7 @@ def test_dbus_network(dev, apdev): if "Error.Failed: wrong property type" not in str(e): raise Exception("Unexpected error message for invalid Set(Enabled,1): " + str(e)) - args = dbus.Dictionary({ 'ssid': "foo1new" }, signature='sv') + args = dbus.Dictionary({'ssid': "foo1new"}, signature='sv') net_obj.Set(WPAS_DBUS_NETWORK, "Properties", args, dbus_interface=dbus.PROPERTIES_IFACE) res = net_obj.Get(WPAS_DBUS_NETWORK, "Properties", @@ -1730,11 +1730,11 @@ def test_dbus_network(dev, apdev): raise Exception("Unexpected number of networks") iface.RemoveAllNetworks() - tests = [ dbus.Dictionary({ 'psk': "1234567" }, signature='sv'), - dbus.Dictionary({ 'identity': dbus.ByteArray() }, - signature='sv'), - dbus.Dictionary({ 'identity': dbus.Byte(1) }, signature='sv'), - dbus.Dictionary({ 'identity': "" }, signature='sv') ] + tests = [dbus.Dictionary({'psk': "1234567"}, signature='sv'), + dbus.Dictionary({'identity': dbus.ByteArray()}, + signature='sv'), + dbus.Dictionary({'identity': dbus.Byte(1)}, signature='sv'), + dbus.Dictionary({'identity': ""}, signature='sv')] for args in tests: try: iface.AddNetwork(args) @@ -1745,11 +1745,11 @@ def test_dbus_network(dev, apdev): def test_dbus_network_oom(dev, apdev): """D-Bus AddNetwork/RemoveNetwork parameters and OOM error cases""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - args = dbus.Dictionary({ 'ssid': "foo1", 'key_mgmt': 'NONE', - 'identity': "testuser", 'scan_freq': '2412' }, + args = dbus.Dictionary({'ssid': "foo1", 'key_mgmt': 'NONE', + 'identity': "testuser", 'scan_freq': '2412'}, signature='sv') netw1 = iface.AddNetwork(args) net_obj = bus.get_object(WPAS_DBUS_SERVICE, netw1) @@ -1768,7 +1768,7 @@ def test_dbus_network_oom(dev, apdev): iface.RemoveNetwork(dbus.ObjectPath("/fi/w1/wpa_supplicant1/Interfaces/1234/Networks/1234")) with alloc_fail(dev[0], 1, "wpa_dbus_register_object_per_iface;wpas_dbus_register_network"): - args = dbus.Dictionary({ 'ssid': "foo2", 'key_mgmt': 'NONE' }, + args = dbus.Dictionary({'ssid': "foo2", 'key_mgmt': 'NONE'}, signature='sv') try: netw = iface.AddNetwork(args) @@ -1792,28 +1792,28 @@ def test_dbus_network_oom(dev, apdev): "=wpa_config_add_network;wpas_dbus_handler_add_network", "AddNetwork", "UnknownError: wpa_supplicant could not add a network"): - args = dbus.Dictionary({ 'ssid': "foo2", 'key_mgmt': 'NONE' }, + args = dbus.Dictionary({'ssid': "foo2", 'key_mgmt': 'NONE'}, signature='sv') netw = iface.AddNetwork(args) - tests = [ (1, - 'wpa_dbus_dict_get_entry;set_network_properties;wpas_dbus_handler_add_network', - dbus.Dictionary({ 'ssid': dbus.ByteArray(b' ') }, - signature='sv')), - (1, '=set_network_properties;wpas_dbus_handler_add_network', - dbus.Dictionary({ 'ssid': 'foo' }, signature='sv')), - (1, '=set_network_properties;wpas_dbus_handler_add_network', - dbus.Dictionary({ 'eap': 'foo' }, signature='sv')), - (1, '=set_network_properties;wpas_dbus_handler_add_network', - dbus.Dictionary({ 'priority': dbus.UInt32(1) }, - signature='sv')), - (1, '=set_network_properties;wpas_dbus_handler_add_network', - dbus.Dictionary({ 'priority': dbus.Int32(1) }, - signature='sv')), - (1, '=set_network_properties;wpas_dbus_handler_add_network', - dbus.Dictionary({ 'ssid': dbus.ByteArray(b' ') }, - signature='sv')) ] - for (count,funcs,args) in tests: + tests = [(1, + 'wpa_dbus_dict_get_entry;set_network_properties;wpas_dbus_handler_add_network', + dbus.Dictionary({'ssid': dbus.ByteArray(b' ')}, + signature='sv')), + (1, '=set_network_properties;wpas_dbus_handler_add_network', + dbus.Dictionary({'ssid': 'foo'}, signature='sv')), + (1, '=set_network_properties;wpas_dbus_handler_add_network', + dbus.Dictionary({'eap': 'foo'}, signature='sv')), + (1, '=set_network_properties;wpas_dbus_handler_add_network', + dbus.Dictionary({'priority': dbus.UInt32(1)}, + signature='sv')), + (1, '=set_network_properties;wpas_dbus_handler_add_network', + dbus.Dictionary({'priority': dbus.Int32(1)}, + signature='sv')), + (1, '=set_network_properties;wpas_dbus_handler_add_network', + dbus.Dictionary({'ssid': dbus.ByteArray(b' ')}, + signature='sv'))] + for (count, funcs, args) in tests: with alloc_fail_dbus(dev[0], count, funcs, "AddNetwork", "InvalidArgs"): netw = iface.AddNetwork(args) @@ -1843,10 +1843,10 @@ def test_dbus_interface(dev, apdev): subprocess.call(['iw', 'reg', 'set', '00']) def _test_dbus_interface(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wpas = dbus.Interface(wpas_obj, WPAS_DBUS_SERVICE) - params = dbus.Dictionary({ 'Ifname': 'lo', 'Driver': 'none' }, + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none'}, signature='sv') path = wpas.CreateInterface(params) logger.debug("New interface path: " + str(path)) @@ -1854,10 +1854,10 @@ def _test_dbus_interface(dev, apdev): if path != path2: raise Exception("Interface object mismatch") - params = dbus.Dictionary({ 'Ifname': 'lo', - 'Driver': 'none', - 'ConfigFile': 'foo', - 'BridgeIfname': 'foo', }, + params = dbus.Dictionary({'Ifname': 'lo', + 'Driver': 'none', + 'ConfigFile': 'foo', + 'BridgeIfname': 'foo',}, signature='sv') try: wpas.CreateInterface(params) @@ -1874,8 +1874,8 @@ def _test_dbus_interface(dev, apdev): if "InterfaceUnknown" not in str(e): raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e)) - params = dbus.Dictionary({ 'Ifname': 'lo', 'Driver': 'none', - 'Foo': 123 }, + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none', + 'Foo': 123}, signature='sv') try: wpas.CreateInterface(params) @@ -1884,7 +1884,7 @@ def _test_dbus_interface(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid CreateInterface: " + str(e)) - params = dbus.Dictionary({ 'Driver': 'none' }, signature='sv') + params = dbus.Dictionary({'Driver': 'none'}, signature='sv') try: wpas.CreateInterface(params) raise Exception("Invalid CreateInterface() accepted") @@ -1901,17 +1901,17 @@ def _test_dbus_interface(dev, apdev): def test_dbus_interface_oom(dev, apdev): """D-Bus CreateInterface/GetInterface/RemoveInterface OOM error cases""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wpas = dbus.Interface(wpas_obj, WPAS_DBUS_SERVICE) with alloc_fail_dbus(dev[0], 1, "wpa_dbus_dict_get_entry;wpas_dbus_handler_create_interface", "CreateInterface", "InvalidArgs"): - params = dbus.Dictionary({ 'Ifname': 'lo', 'Driver': 'none' }, + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none'}, signature='sv') wpas.CreateInterface(params) for i in range(1, 1000): dev[0].request("TEST_ALLOC_FAIL %d:wpa_supplicant_add_iface;wpas_dbus_handler_create_interface" % i) - params = dbus.Dictionary({ 'Ifname': 'lo', 'Driver': 'none' }, + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none'}, signature='sv') try: npath = wpas.CreateInterface(params) @@ -1928,15 +1928,15 @@ def test_dbus_interface_oom(dev, apdev): except dbus.exceptions.DBusException as e: pass - for arg in [ 'Driver', 'Ifname', 'ConfigFile', 'BridgeIfname' ]: + for arg in ['Driver', 'Ifname', 'ConfigFile', 'BridgeIfname']: with alloc_fail_dbus(dev[0], 1, "=wpas_dbus_handler_create_interface", "CreateInterface"): - params = dbus.Dictionary({ arg: 'foo' }, signature='sv') + params = dbus.Dictionary({arg: 'foo'}, signature='sv') wpas.CreateInterface(params) def test_dbus_blob(dev, apdev): """D-Bus AddNetwork/RemoveNetwork parameters and error cases""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) blob = dbus.ByteArray(b"\x01\x02\x03") @@ -2011,7 +2011,7 @@ def test_dbus_blob(dev, apdev): def test_dbus_blob_oom(dev, apdev): """D-Bus AddNetwork/RemoveNetwork OOM error cases""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) for i in range(1, 4): @@ -2021,7 +2021,7 @@ def test_dbus_blob_oom(dev, apdev): def test_dbus_autoscan(dev, apdev): """D-Bus Autoscan()""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) iface.AutoScan("foo") @@ -2031,7 +2031,7 @@ def test_dbus_autoscan(dev, apdev): def test_dbus_autoscan_oom(dev, apdev): """D-Bus Autoscan() OOM""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) with alloc_fail_dbus(dev[0], 1, "wpas_dbus_handler_autoscan", "AutoScan"): @@ -2040,10 +2040,10 @@ def test_dbus_autoscan_oom(dev, apdev): def test_dbus_tdls_invalid(dev, apdev): """D-Bus invalid TDLS operations""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) connect_2sta_open(dev, hapd) addr1 = dev[1].p2p_interface_addr() @@ -2102,7 +2102,7 @@ def test_dbus_tdls_invalid(dev, apdev): def test_dbus_tdls_oom(dev, apdev): """D-Bus TDLS operations during OOM""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) with alloc_fail_dbus(dev[0], 1, "wpa_tdls_add_peer", "TDLSSetup", @@ -2111,10 +2111,10 @@ def test_dbus_tdls_oom(dev, apdev): def test_dbus_tdls(dev, apdev): """D-Bus TDLS""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) connect_2sta_open(dev, hapd) addr1 = dev[1].p2p_interface_addr() @@ -2182,10 +2182,10 @@ def test_dbus_tdls_channel_switch(dev, apdev): if flags & 0x800000000 == 0: raise HwsimSkip("Driver does not support TDLS channel switching") - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-open"}) connect_2sta_open(dev, hapd) addr1 = dev[1].p2p_interface_addr() @@ -2228,7 +2228,7 @@ def test_dbus_tdls_channel_switch(dev, apdev): logger.info("Unexpected TDLSStatus: " + res) # Unknown dict entry - args = dbus.Dictionary({ 'Foobar': dbus.Byte(1) }, + args = dbus.Dictionary({'Foobar': dbus.Byte(1)}, signature='sv') try: iface.TDLSChannelSwitch(args) @@ -2245,7 +2245,7 @@ def test_dbus_tdls_channel_switch(dev, apdev): raise Exception("Unexpected exception") # Missing Frequency - args = dbus.Dictionary({ 'OperClass': dbus.Byte(1) }, + args = dbus.Dictionary({'OperClass': dbus.Byte(1)}, signature='sv') try: iface.TDLSChannelSwitch(args) @@ -2254,8 +2254,8 @@ def test_dbus_tdls_channel_switch(dev, apdev): raise Exception("Unexpected exception") # Missing PeerAddress - args = dbus.Dictionary({ 'OperClass': dbus.Byte(1), - 'Frequency': dbus.UInt32(2417) }, + args = dbus.Dictionary({'OperClass': dbus.Byte(1), + 'Frequency': dbus.UInt32(2417)}, signature='sv') try: iface.TDLSChannelSwitch(args) @@ -2264,15 +2264,15 @@ def test_dbus_tdls_channel_switch(dev, apdev): raise Exception("Unexpected exception") # Valid parameters - args = dbus.Dictionary({ 'OperClass': dbus.Byte(1), - 'Frequency': dbus.UInt32(2417), - 'PeerAddress': addr1, - 'SecChannelOffset': dbus.UInt32(0), - 'CenterFrequency1': dbus.UInt32(0), - 'CenterFrequency2': dbus.UInt32(0), - 'Bandwidth': dbus.UInt32(20), - 'HT': dbus.Boolean(False), - 'VHT': dbus.Boolean(False) }, + args = dbus.Dictionary({'OperClass': dbus.Byte(1), + 'Frequency': dbus.UInt32(2417), + 'PeerAddress': addr1, + 'SecChannelOffset': dbus.UInt32(0), + 'CenterFrequency1': dbus.UInt32(0), + 'CenterFrequency2': dbus.UInt32(0), + 'Bandwidth': dbus.UInt32(20), + 'HT': dbus.Boolean(False), + 'VHT': dbus.Boolean(False)}, signature='sv') iface.TDLSChannelSwitch(args) @@ -2295,7 +2295,7 @@ def test_dbus_tdls_channel_switch(dev, apdev): def test_dbus_pkcs11(dev, apdev): """D-Bus SetPKCS11EngineAndModulePath()""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) try: @@ -2338,7 +2338,7 @@ def test_dbus_apscan(dev, apdev): dev[0].request("AP_SCAN 1") def _test_dbus_apscan(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) res = if_obj.Get(WPAS_DBUS_IFACE, "ApScan", dbus_interface=dbus.PROPERTIES_IFACE) @@ -2380,7 +2380,7 @@ def test_dbus_pmf(dev, apdev): dev[0].request("SET pmf 0") def _test_dbus_pmf(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) dev[0].set("pmf", "0") res = if_obj.Get(WPAS_DBUS_IFACE, "Pmf", @@ -2401,14 +2401,14 @@ def _test_dbus_pmf(dev, apdev): def test_dbus_fastreauth(dev, apdev): """D-Bus Get/Set FastReauth""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) res = if_obj.Get(WPAS_DBUS_IFACE, "FastReauth", dbus_interface=dbus.PROPERTIES_IFACE) if res != True: raise Exception("Unexpected initial FastReauth value: " + str(res)) - for i in [ False, True ]: + for i in [False, True]: if_obj.Set(WPAS_DBUS_IFACE, "FastReauth", dbus.Boolean(i), dbus_interface=dbus.PROPERTIES_IFACE) res = if_obj.Get(WPAS_DBUS_IFACE, "FastReauth", @@ -2429,7 +2429,7 @@ def test_dbus_fastreauth(dev, apdev): def test_dbus_bss_expire(dev, apdev): """D-Bus Get/Set BSSExpireAge and BSSExpireCount""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) if_obj.Set(WPAS_DBUS_IFACE, "BSSExpireAge", dbus.UInt32(179), dbus_interface=dbus.PROPERTIES_IFACE) @@ -2491,7 +2491,7 @@ def test_dbus_country(dev, apdev): subprocess.call(['iw', 'reg', 'set', '00']) def _test_dbus_country(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) # work around issues with possible pending regdom event from the end of # the previous test case @@ -2552,7 +2552,7 @@ def test_dbus_scan_interval(dev, apdev): dev[0].request("SCAN_INTERVAL 5") def _test_dbus_scan_interval(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) if_obj.Set(WPAS_DBUS_IFACE, "ScanInterval", dbus.Int32(3), dbus_interface=dbus.PROPERTIES_IFACE) @@ -2582,7 +2582,7 @@ def _test_dbus_scan_interval(dev, apdev): def test_dbus_probe_req_reporting(dev, apdev): """D-Bus Probe Request reporting""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) dev[1].p2p_find(social=True) @@ -2617,7 +2617,7 @@ def test_dbus_probe_req_reporting(dev, apdev): def run_test(self, *args): logger.debug("run_test") p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) - params = dbus.Dictionary({ 'frequency': 2412 }) + params = dbus.Dictionary({'frequency': 2412}) p2p.GroupAdd(params) return False @@ -2646,7 +2646,7 @@ def test_dbus_probe_req_reporting(dev, apdev): def test_dbus_probe_req_reporting_oom(dev, apdev): """D-Bus Probe Request reporting (OOM)""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) # Need to make sure this process has not already subscribed to avoid false @@ -2670,7 +2670,7 @@ def test_dbus_probe_req_reporting_oom(dev, apdev): def test_dbus_p2p_invalid(dev, apdev): """D-Bus invalid P2P operations""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) try: @@ -2687,11 +2687,11 @@ def test_dbus_p2p_invalid(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid RejectPeer(): " + str(e)) - tests = [ { }, - { 'peer': 'foo' }, - { 'foo': "bar" }, - { 'iface': "abc" }, - { 'iface': 123 } ] + tests = [{}, + {'peer': 'foo'}, + {'foo': "bar"}, + {'iface': "abc"}, + {'iface': 123}] for t in tests: try: p2p.RemoveClient(t) @@ -2700,24 +2700,24 @@ def test_dbus_p2p_invalid(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid RemoveClient(): " + str(e)) - tests = [ {'DiscoveryType': 'foo'}, - {'RequestedDeviceTypes': 'foo'}, - {'RequestedDeviceTypes': ['foo']}, - {'RequestedDeviceTypes': ['1','2','3','4','5','6','7','8','9', - '10','11','12','13','14','15','16', - '17']}, - {'RequestedDeviceTypes': dbus.Array([], signature="s")}, - {'RequestedDeviceTypes': dbus.Array([['foo']], signature="as")}, - {'RequestedDeviceTypes': dbus.Array([], signature="i")}, - {'RequestedDeviceTypes': [dbus.ByteArray(b'12345678'), - dbus.ByteArray(b'1234567')]}, - {'Foo': dbus.Int16(1)}, - {'Foo': dbus.UInt16(1)}, - {'Foo': dbus.Int64(1)}, - {'Foo': dbus.UInt64(1)}, - {'Foo': dbus.Double(1.23)}, - {'Foo': dbus.Signature('s')}, - {'Foo': 'bar'}] + tests = [{'DiscoveryType': 'foo'}, + {'RequestedDeviceTypes': 'foo'}, + {'RequestedDeviceTypes': ['foo']}, + {'RequestedDeviceTypes': ['1', '2', '3', '4', '5', '6', '7', '8', + '9', '10', '11', '12', '13', '14', '15', + '16', '17']}, + {'RequestedDeviceTypes': dbus.Array([], signature="s")}, + {'RequestedDeviceTypes': dbus.Array([['foo']], signature="as")}, + {'RequestedDeviceTypes': dbus.Array([], signature="i")}, + {'RequestedDeviceTypes': [dbus.ByteArray(b'12345678'), + dbus.ByteArray(b'1234567')]}, + {'Foo': dbus.Int16(1)}, + {'Foo': dbus.UInt16(1)}, + {'Foo': dbus.Int64(1)}, + {'Foo': dbus.UInt64(1)}, + {'Foo': dbus.Double(1.23)}, + {'Foo': dbus.Signature('s')}, + {'Foo': 'bar'}] for t in tests: try: p2p.Find(dbus.Dictionary(t)) @@ -2726,9 +2726,9 @@ def test_dbus_p2p_invalid(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid Find(): " + str(e)) - for p in [ "/foo", - "/fi/w1/wpa_supplicant1/Interfaces/1234", - "/fi/w1/wpa_supplicant1/Interfaces/1234/Networks/1234" ]: + for p in ["/foo", + "/fi/w1/wpa_supplicant1/Interfaces/1234", + "/fi/w1/wpa_supplicant1/Interfaces/1234/Networks/1234"]: try: p2p.RemovePersistentGroup(dbus.ObjectPath(p)) raise Exception("Invalid RemovePersistentGroup accepted") @@ -2767,8 +2767,8 @@ def test_dbus_p2p_invalid(dev, apdev): try: dev[0].request("P2P_SET disabled 1") - args = { 'duration1': 30000, 'interval1': 102400, - 'duration2': 20000, 'interval2': 102400 } + args = {'duration1': 30000, 'interval1': 102400, + 'duration2': 20000, 'interval2': 102400} p2p.PresenceRequest(args) raise Exception("Invalid PresenceRequest accepted") except dbus.exceptions.DBusException as e: @@ -2814,10 +2814,10 @@ def test_dbus_p2p_invalid(dev, apdev): try: dev[0].request("P2P_SET disabled 1") - args = { 'peer': path, - 'join': True, - 'wps_method': 'pbc', - 'frequency': 2412 } + args = {'peer': path, + 'join': True, + 'wps_method': 'pbc', + 'frequency': 2412} pin = p2p.Connect(args) raise Exception("Invalid Connect accepted") except dbus.exceptions.DBusException as e: @@ -2826,9 +2826,9 @@ def test_dbus_p2p_invalid(dev, apdev): finally: dev[0].request("P2P_SET disabled 0") - tests = [ { 'frequency': dbus.Int32(-1) }, - { 'wps_method': 'pbc' }, - { 'wps_method': 'foo' } ] + tests = [{'frequency': dbus.Int32(-1)}, + {'wps_method': 'pbc'}, + {'wps_method': 'foo'}] for args in tests: try: pin = p2p.Connect(args) @@ -2839,7 +2839,7 @@ def test_dbus_p2p_invalid(dev, apdev): try: dev[0].request("P2P_SET disabled 1") - args = { 'peer': path } + args = {'peer': path} pin = p2p.Invite(args) raise Exception("Invalid Invite accepted") except dbus.exceptions.DBusException as e: @@ -2849,29 +2849,29 @@ def test_dbus_p2p_invalid(dev, apdev): dev[0].request("P2P_SET disabled 0") try: - args = { 'foo': 'bar' } + args = {'foo': 'bar'} pin = p2p.Invite(args) raise Exception("Invalid Invite accepted") except dbus.exceptions.DBusException as e: if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid Connect: " + str(e)) - tests = [ (path, 'display', "InvalidArgs"), - (dbus.ObjectPath(path + "/Peers/00112233445566"), - 'display', - "UnknownError: Failed to send provision discovery request"), - (dbus.ObjectPath(path + "/Peers/00112233445566"), - 'keypad', - "UnknownError: Failed to send provision discovery request"), - (dbus.ObjectPath(path + "/Peers/00112233445566"), - 'pbc', - "UnknownError: Failed to send provision discovery request"), - (dbus.ObjectPath(path + "/Peers/00112233445566"), - 'pushbutton', - "UnknownError: Failed to send provision discovery request"), - (dbus.ObjectPath(path + "/Peers/00112233445566"), - 'foo', "InvalidArgs") ] - for (p,method,err) in tests: + tests = [(path, 'display', "InvalidArgs"), + (dbus.ObjectPath(path + "/Peers/00112233445566"), + 'display', + "UnknownError: Failed to send provision discovery request"), + (dbus.ObjectPath(path + "/Peers/00112233445566"), + 'keypad', + "UnknownError: Failed to send provision discovery request"), + (dbus.ObjectPath(path + "/Peers/00112233445566"), + 'pbc', + "UnknownError: Failed to send provision discovery request"), + (dbus.ObjectPath(path + "/Peers/00112233445566"), + 'pushbutton', + "UnknownError: Failed to send provision discovery request"), + (dbus.ObjectPath(path + "/Peers/00112233445566"), + 'foo', "InvalidArgs")] + for (p, method, err) in tests: try: p2p.ProvisionDiscoveryRequest(p, method) raise Exception("Invalid ProvisionDiscoveryRequest accepted") @@ -2892,55 +2892,56 @@ def test_dbus_p2p_invalid(dev, apdev): def test_dbus_p2p_oom(dev, apdev): """D-Bus P2P operations and OOM""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_string_array", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ 'bar' ] })) + p2p.Find(dbus.Dictionary({'Foo': ['bar']})) with alloc_fail_dbus(dev[0], 2, "_wpa_dbus_dict_entry_get_string_array", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ 'bar' ] })) + p2p.Find(dbus.Dictionary({'Foo': ['bar']})) with alloc_fail_dbus(dev[0], 10, "_wpa_dbus_dict_entry_get_string_array", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ '1','2','3','4','5','6','7','8','9' ] })) + p2p.Find(dbus.Dictionary({'Foo': ['1', '2', '3', '4', '5', '6', '7', + '8', '9']})) with alloc_fail_dbus(dev[0], 1, ":=_wpa_dbus_dict_entry_get_binarray", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123') ] })) + p2p.Find(dbus.Dictionary({'Foo': [dbus.ByteArray(b'123')]})) with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_byte_array;_wpa_dbus_dict_entry_get_binarray", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123') ] })) + p2p.Find(dbus.Dictionary({'Foo': [dbus.ByteArray(b'123')]})) with alloc_fail_dbus(dev[0], 2, "=_wpa_dbus_dict_entry_get_binarray", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123'), - dbus.ByteArray(b'123') ] })) + p2p.Find(dbus.Dictionary({'Foo': [dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123'), + dbus.ByteArray(b'123')]})) with alloc_fail_dbus(dev[0], 1, "wpabuf_alloc_ext_data;_wpa_dbus_dict_entry_get_binarray", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123') ] })) + p2p.Find(dbus.Dictionary({'Foo': [dbus.ByteArray(b'123')]})) with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_fill_value_from_variant;wpas_dbus_handler_p2p_find", "Find", "InvalidArgs"): - p2p.Find(dbus.Dictionary({ 'Foo': path })) + p2p.Find(dbus.Dictionary({'Foo': path})) with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_byte_array", "AddService", "InvalidArgs"): - args = { 'service_type': 'bonjour', - 'response': dbus.ByteArray(500*b'b') } + args = {'service_type': 'bonjour', + 'response': dbus.ByteArray(500*b'b')} p2p.AddService(args) with alloc_fail_dbus(dev[0], 2, "_wpa_dbus_dict_entry_get_byte_array", @@ -2955,7 +2956,7 @@ def test_dbus_p2p_discovery(dev, apdev): dev[1].request("VENDOR_ELEM_REMOVE 1 *") def run_dbus_p2p_discovery(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -2965,7 +2966,7 @@ def run_dbus_p2p_discovery(dev, apdev): dev[1].request("VENDOR_ELEM_ADD 1 dd06001122335566") dev[1].p2p_listen() addr1 = dev[1].p2p_dev_addr() - a1 = binascii.unhexlify(addr1.replace(':','')) + a1 = binascii.unhexlify(addr1.replace(':', '')) wfd_devinfo = "00001c440028" dev[2].request("SET wifi_display 1") @@ -2973,7 +2974,7 @@ def run_dbus_p2p_discovery(dev, apdev): wfd = binascii.unhexlify('000006' + wfd_devinfo) dev[2].p2p_listen() addr2 = dev[2].p2p_dev_addr() - a2 = binascii.unhexlify(addr2.replace(':','')) + a2 = binascii.unhexlify(addr2.replace(':', '')) res = if_obj.GetAll(WPAS_DBUS_IFACE_P2PDEVICE, dbus_interface=dbus.PROPERTIES_IFACE) @@ -2984,7 +2985,7 @@ def run_dbus_p2p_discovery(dev, apdev): args = {'DiscoveryType': 'social', 'RequestedDeviceTypes': [dbus.ByteArray(b'12345678')], - 'Timeout': dbus.Int32(1) } + 'Timeout': dbus.Int32(1)} p2p.Find(dbus.Dictionary(args)) p2p.StopFind() @@ -3136,7 +3137,7 @@ def run_dbus_p2p_discovery(dev, apdev): def test_dbus_p2p_discovery_freq(dev, apdev): """D-Bus P2P discovery on a specific non-social channel""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr1 = dev[1].p2p_dev_addr() @@ -3177,7 +3178,7 @@ def test_dbus_p2p_discovery_freq(dev, apdev): def test_dbus_p2p_service_discovery(dev, apdev): """D-Bus P2P service discovery""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -3186,9 +3187,9 @@ def test_dbus_p2p_service_discovery(dev, apdev): bonjour_query = dbus.ByteArray(binascii.unhexlify('0b5f6166706f766572746370c00c000c01')) bonjour_response = dbus.ByteArray(binascii.unhexlify('074578616d706c65c027')) - args = { 'service_type': 'bonjour', - 'query': bonjour_query, - 'response': bonjour_response } + args = {'service_type': 'bonjour', + 'query': bonjour_query, + 'response': bonjour_response} p2p.AddService(args) p2p.FlushService() p2p.AddService(args) @@ -3200,8 +3201,8 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) - args = { 'service_type': 'bonjour', - 'query': bonjour_query } + args = {'service_type': 'bonjour', + 'query': bonjour_query} p2p.DeleteService(args) try: p2p.DeleteService(args) @@ -3210,9 +3211,9 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) - args = { 'service_type': 'upnp', - 'version': 0x10, - 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice' } + args = {'service_type': 'upnp', + 'version': 0x10, + 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice'} p2p.AddService(args) p2p.DeleteService(args) try: @@ -3222,18 +3223,18 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) - tests = [ { 'service_type': 'foo' }, - { 'service_type': 'foo', 'query': bonjour_query }, - { 'service_type': 'upnp' }, - { 'service_type': 'upnp', 'version': 0x10 }, - { 'service_type': 'upnp', - 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice' }, - { 'version': 0x10, - 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice' }, - { 'service_type': 'upnp', 'foo': 'bar' }, - { 'service_type': 'bonjour' }, - { 'service_type': 'bonjour', 'query': 'foo' }, - { 'service_type': 'bonjour', 'foo': 'bar' } ] + tests = [{'service_type': 'foo'}, + {'service_type': 'foo', 'query': bonjour_query}, + {'service_type': 'upnp'}, + {'service_type': 'upnp', 'version': 0x10}, + {'service_type': 'upnp', + 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice'}, + {'version': 0x10, + 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice'}, + {'service_type': 'upnp', 'foo': 'bar'}, + {'service_type': 'bonjour'}, + {'service_type': 'bonjour', 'query': 'foo'}, + {'service_type': 'bonjour', 'foo': 'bar'}] for args in tests: try: p2p.DeleteService(args) @@ -3242,21 +3243,21 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid DeleteService(): " + str(e)) - tests = [ { 'service_type': 'foo' }, - { 'service_type': 'upnp' }, - { 'service_type': 'upnp', 'version': 0x10 }, - { 'service_type': 'upnp', - 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice' }, - { 'version': 0x10, - 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice' }, - { 'service_type': 'upnp', 'foo': 'bar' }, - { 'service_type': 'bonjour' }, - { 'service_type': 'bonjour', 'query': 'foo' }, - { 'service_type': 'bonjour', 'response': 'foo' }, - { 'service_type': 'bonjour', 'query': bonjour_query }, - { 'service_type': 'bonjour', 'response': bonjour_response }, - { 'service_type': 'bonjour', 'query': dbus.ByteArray(500*b'a') }, - { 'service_type': 'bonjour', 'foo': 'bar' } ] + tests = [{'service_type': 'foo'}, + {'service_type': 'upnp'}, + {'service_type': 'upnp', 'version': 0x10}, + {'service_type': 'upnp', + 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice'}, + {'version': 0x10, + 'service': 'uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice'}, + {'service_type': 'upnp', 'foo': 'bar'}, + {'service_type': 'bonjour'}, + {'service_type': 'bonjour', 'query': 'foo'}, + {'service_type': 'bonjour', 'response': 'foo'}, + {'service_type': 'bonjour', 'query': bonjour_query}, + {'service_type': 'bonjour', 'response': bonjour_response}, + {'service_type': 'bonjour', 'query': dbus.ByteArray(500*b'a')}, + {'service_type': 'bonjour', 'foo': 'bar'}] for args in tests: try: p2p.AddService(args) @@ -3265,7 +3266,7 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid AddService(): " + str(e)) - args = { 'tlv': dbus.ByteArray(b"\x02\x00\x00\x01") } + args = {'tlv': dbus.ByteArray(b"\x02\x00\x00\x01")} ref = p2p.ServiceDiscoveryRequest(args) p2p.ServiceDiscoveryCancelRequest(ref) try: @@ -3281,33 +3282,33 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid AddService(): " + str(e)) - args = { 'service_type': 'upnp', - 'version': 0x10, - 'service': 'ssdp:foo' } + args = {'service_type': 'upnp', + 'version': 0x10, + 'service': 'ssdp:foo'} ref = p2p.ServiceDiscoveryRequest(args) p2p.ServiceDiscoveryCancelRequest(ref) - tests = [ { 'service_type': 'foo' }, - { 'foo': 'bar' }, - { 'tlv': 'foo' }, - { }, - { 'version': 0 }, - { 'service_type': 'upnp', - 'service': 'ssdp:foo' }, - { 'service_type': 'upnp', - 'version': 0x10 }, - { 'service_type': 'upnp', - 'version': 0x10, - 'service': 'ssdp:foo', - 'peer_object': dbus.ObjectPath(path + "/Peers") }, - { 'service_type': 'upnp', - 'version': 0x10, - 'service': 'ssdp:foo', - 'peer_object': path + "/Peers" }, - { 'service_type': 'upnp', - 'version': 0x10, - 'service': 'ssdp:foo', - 'peer_object': dbus.ObjectPath(path + "/Peers/00112233445566") } ] + tests = [{'service_type': 'foo'}, + {'foo': 'bar'}, + {'tlv': 'foo'}, + {}, + {'version': 0}, + {'service_type': 'upnp', + 'service': 'ssdp:foo'}, + {'service_type': 'upnp', + 'version': 0x10}, + {'service_type': 'upnp', + 'version': 0x10, + 'service': 'ssdp:foo', + 'peer_object': dbus.ObjectPath(path + "/Peers")}, + {'service_type': 'upnp', + 'version': 0x10, + 'service': 'ssdp:foo', + 'peer_object': path + "/Peers"}, + {'service_type': 'upnp', + 'version': 0x10, + 'service': 'ssdp:foo', + 'peer_object': dbus.ObjectPath(path + "/Peers/00112233445566")}] for args in tests: try: p2p.ServiceDiscoveryRequest(args) @@ -3316,7 +3317,7 @@ def test_dbus_p2p_service_discovery(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid ServiceDiscoveryRequest(): " + str(e)) - args = { 'foo': 'bar' } + args = {'foo': 'bar'} try: p2p.ServiceDiscoveryResponse(dbus.Dictionary(args, signature='sv')) raise Exception("Invalid ServiceDiscoveryResponse accepted") @@ -3326,7 +3327,7 @@ def test_dbus_p2p_service_discovery(dev, apdev): def test_dbus_p2p_service_discovery_query(dev, apdev): """D-Bus P2P service discovery query""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -3352,8 +3353,8 @@ def test_dbus_p2p_service_discovery_query(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) - args = { 'peer_object': path, - 'tlv': dbus.ByteArray(b"\x02\x00\x00\x01") } + args = {'peer_object': path, + 'tlv': dbus.ByteArray(b"\x02\x00\x00\x01")} p2p.ServiceDiscoveryRequest(args) def serviceDiscoveryResponse(self, sd_request): @@ -3384,7 +3385,7 @@ def test_dbus_p2p_service_discovery_external(dev, apdev): dev[0].request("P2P_SERV_DISC_EXTERNAL 0") def _test_dbus_p2p_service_discovery_external(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -3417,10 +3418,10 @@ def _test_dbus_p2p_service_discovery_external(dev, apdev): def serviceDiscoveryRequest(self, sd_request): logger.debug("serviceDiscoveryRequest: sd_request=%s" % str(sd_request)) self.sd = True - args = { 'peer_object': sd_request['peer_object'], - 'frequency': sd_request['frequency'], - 'dialog_token': sd_request['dialog_token'], - 'tlvs': dbus.ByteArray(binascii.unhexlify(resp)) } + args = {'peer_object': sd_request['peer_object'], + 'frequency': sd_request['frequency'], + 'dialog_token': sd_request['dialog_token'], + 'tlvs': dbus.ByteArray(binascii.unhexlify(resp))} p2p.ServiceDiscoveryResponse(dbus.Dictionary(args, signature='sv')) self.loop.quit() @@ -3452,7 +3453,7 @@ def _test_dbus_p2p_service_discovery_external(dev, apdev): def test_dbus_p2p_autogo(dev, apdev): """D-Bus P2P autonomous GO""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -3554,12 +3555,12 @@ def test_dbus_p2p_autogo(dev, apdev): logger.debug("provisionDiscoveryRequestDisplayPin - peer=%s pin=%s" % (peer_object, pin)) self.peer_path = peer_object peer = binascii.unhexlify(peer_object.split('/')[-1]) - addr = ':'.join([ "%02x" % i for i in struct.unpack('6B', peer) ]) + addr = ':'.join(["%02x" % i for i in struct.unpack('6B', peer)]) - params = { 'Role': 'registrar', - 'P2PDeviceAddress': self.peer['DeviceAddress'], - 'Bssid': self.peer['DeviceAddress'], - 'Type': 'pin' } + params = {'Role': 'registrar', + 'P2PDeviceAddress': self.peer['DeviceAddress'], + 'Bssid': self.peer['DeviceAddress'], + 'Type': 'pin'} wps = dbus.Interface(self.g_if_obj, WPAS_DBUS_IFACE_WPS) try: wps.Start(params) @@ -3569,10 +3570,10 @@ def test_dbus_p2p_autogo(dev, apdev): if "InvalidArgs" not in str(e): self.exceptions = True raise Exception("Unexpected error message: " + str(e)) - params = { 'Role': 'registrar', - 'P2PDeviceAddress': self.peer['DeviceAddress'], - 'Type': 'pin', - 'Pin': '12345670' } + params = {'Role': 'registrar', + 'P2PDeviceAddress': self.peer['DeviceAddress'], + 'Type': 'pin', + 'Pin': '12345670'} logger.info("Authorize peer to connect to the group") wps.Start(params) @@ -3606,7 +3607,7 @@ def test_dbus_p2p_autogo(dev, apdev): # dictionary with 'WPSVendorExtensions' as the key surrounding these # values.. The current implementations maintains support for that # for backwards compability reasons. Verify that encoding first. - vals = dbus.Dictionary({ 'WPSVendorExtensions': [ ext ]}, + vals = dbus.Dictionary({'WPSVendorExtensions': [ext]}, signature='sv') g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', vals, dbus_interface=dbus.PROPERTIES_IFACE) @@ -3647,7 +3648,7 @@ def test_dbus_p2p_autogo(dev, apdev): self.exceptions = True raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) - vals = dbus.Dictionary({ 'Foo': [ ext ]}, signature='sv') + vals = dbus.Dictionary({'Foo': [ext]}, signature='sv') try: g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', vals, dbus_interface=dbus.PROPERTIES_IFACE) @@ -3658,7 +3659,7 @@ def test_dbus_p2p_autogo(dev, apdev): self.exceptions = True raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) - vals = [ "foo" ] + vals = ["foo"] try: g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', vals, dbus_interface=dbus.PROPERTIES_IFACE) @@ -3669,7 +3670,7 @@ def test_dbus_p2p_autogo(dev, apdev): self.exceptions = True raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) - vals = [ [ "foo" ] ] + vals = [["foo"]] try: g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', vals, dbus_interface=dbus.PROPERTIES_IFACE) @@ -3680,7 +3681,7 @@ def test_dbus_p2p_autogo(dev, apdev): self.exceptions = True raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) - p2p.RemoveClient({ 'peer': self.peer_path }) + p2p.RemoveClient({'peer': self.peer_path}) self.waiting_end = True group_p2p = dbus.Interface(self.g_if_obj, @@ -3710,7 +3711,7 @@ def test_dbus_p2p_autogo(dev, apdev): def test_dbus_p2p_autogo_pbc(dev, apdev): """D-Bus P2P autonomous GO and PBC""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -3764,10 +3765,10 @@ def test_dbus_p2p_autogo_pbc(dev, apdev): logger.debug("provisionDiscoveryPBCRequest - peer=%s" % peer_object) self.peer_path = peer_object peer = binascii.unhexlify(peer_object.split('/')[-1]) - addr = ':'.join([ "%02x" % i for i in struct.unpack('6B', peer) ]) - params = { 'Role': 'registrar', - 'P2PDeviceAddress': self.peer['DeviceAddress'], - 'Type': 'pbc' } + addr = ':'.join(["%02x" % i for i in struct.unpack('6B', peer)]) + params = {'Role': 'registrar', + 'P2PDeviceAddress': self.peer['DeviceAddress'], + 'Type': 'pbc'} logger.info("Authorize peer to connect to the group") wps = dbus.Interface(self.g_if_obj, WPAS_DBUS_IFACE_WPS) wps.Start(params) @@ -3796,7 +3797,7 @@ def test_dbus_p2p_autogo_pbc(dev, apdev): def test_dbus_p2p_autogo_legacy(dev, apdev): """D-Bus P2P autonomous GO and legacy STA""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -3825,12 +3826,12 @@ def test_dbus_p2p_autogo_legacy(dev, apdev): res = g_obj.GetAll(WPAS_DBUS_GROUP, dbus_interface=dbus.PROPERTIES_IFACE, byte_arrays=True) - bssid = ':'.join([ "%02x" % i for i in struct.unpack('6B', res['BSSID']) ]) + bssid = ':'.join(["%02x" % i for i in struct.unpack('6B', res['BSSID'])]) pin = '12345670' - params = { 'Role': 'enrollee', - 'Type': 'pin', - 'Pin': pin } + params = {'Role': 'enrollee', + 'Type': 'pin', + 'Pin': pin} g_if_obj = bus.get_object(WPAS_DBUS_SERVICE, properties['interface_object']) wps = dbus.Interface(g_if_obj, WPAS_DBUS_IFACE_WPS) @@ -3866,7 +3867,7 @@ def test_dbus_p2p_autogo_legacy(dev, apdev): def test_dbus_p2p_join(dev, apdev): """D-Bus P2P join an autonomous GO""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr1 = dev[1].p2p_dev_addr() @@ -3903,17 +3904,17 @@ def test_dbus_p2p_join(dev, apdev): dbus_interface=dbus.PROPERTIES_IFACE, byte_arrays=True) logger.debug('peer properties: ' + str(res)) - if addr2.replace(':','') in path: + if addr2.replace(':', '') in path: self.peer = path - elif addr1.replace(':','') in path: + elif addr1.replace(':', '') in path: self.go = path if self.peer and self.go: logger.info("Join the group") p2p.StopFind() - args = { 'peer': self.go, - 'join': True, - 'wps_method': 'pin', - 'frequency': 2412 } + args = {'peer': self.go, + 'join': True, + 'wps_method': 'pin', + 'frequency': 2412} pin = p2p.Connect(args) dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') @@ -3955,11 +3956,11 @@ def test_dbus_p2p_join(dev, apdev): raise Exception("Unexpected error message for invalid Set(WPSVendorExtensions): " + str(e)) group_p2p = dbus.Interface(g_if_obj, WPAS_DBUS_IFACE_P2PDEVICE) - args = { 'duration1': 30000, 'interval1': 102400, - 'duration2': 20000, 'interval2': 102400 } + args = {'duration1': 30000, 'interval1': 102400, + 'duration2': 20000, 'interval2': 102400} group_p2p.PresenceRequest(args) - args = { 'peer': self.peer } + args = {'peer': self.peer} group_p2p.Invite(args) def groupFinished(self, properties): @@ -3991,7 +3992,7 @@ def test_dbus_p2p_join(dev, apdev): def test_dbus_p2p_invitation_received(dev, apdev): """D-Bus P2P and InvitationReceived""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) form(dev[0], dev[1]) @@ -4046,7 +4047,7 @@ def test_dbus_p2p_config(dev, apdev): dev[0].request("P2P_SET ssid_postfix ") def _test_dbus_p2p_config(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) res = if_obj.Get(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig", @@ -4064,9 +4065,9 @@ def _test_dbus_p2p_config(dev, apdev): if res[k] != res2[k]: raise Exception("Parameter %s value changes" % k) - changes = { 'SsidPostfix': 'foo', - 'VendorExtension': [ dbus.ByteArray(b'\x11\x22\x33\x44') ], - 'SecondaryDeviceTypes': [ dbus.ByteArray(b'\x11\x22\x33\x44\x55\x66\x77\x88') ]} + changes = {'SsidPostfix': 'foo', + 'VendorExtension': [dbus.ByteArray(b'\x11\x22\x33\x44')], + 'SecondaryDeviceTypes': [dbus.ByteArray(b'\x11\x22\x33\x44\x55\x66\x77\x88')]} if_obj.Set(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig", dbus.Dictionary(changes, signature='sv'), dbus_interface=dbus.PROPERTIES_IFACE) @@ -4080,9 +4081,9 @@ def _test_dbus_p2p_config(dev, apdev): if 'SecondaryDeviceTypes' not in res2 or len(res2['SecondaryDeviceTypes']) != 1: raise Exception("SecondaryDeviceType does not match") - changes = { 'SsidPostfix': '', - 'VendorExtension': dbus.Array([], signature="ay"), - 'SecondaryDeviceTypes': dbus.Array([], signature="ay") } + changes = {'SsidPostfix': '', + 'VendorExtension': dbus.Array([], signature="ay"), + 'SecondaryDeviceTypes': dbus.Array([], signature="ay")} if_obj.Set(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig", dbus.Dictionary(changes, signature='sv'), dbus_interface=dbus.PROPERTIES_IFACE) @@ -4110,7 +4111,7 @@ def _test_dbus_p2p_config(dev, apdev): try: dev[0].request("P2P_SET disabled 1") - changes = { 'SsidPostfix': 'foo' } + changes = {'SsidPostfix': 'foo'} if_obj.Set(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig", dbus.Dictionary(changes, signature='sv'), dbus_interface=dbus.PROPERTIES_IFACE) @@ -4121,9 +4122,9 @@ def _test_dbus_p2p_config(dev, apdev): finally: dev[0].request("P2P_SET disabled 0") - tests = [ { 'DeviceName': 123 }, - { 'SsidPostfix': 123 }, - { 'Foo': 'Bar' } ] + tests = [{'DeviceName': 123}, + {'SsidPostfix': 123}, + {'Foo': 'Bar'}] for changes in tests: try: if_obj.Set(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig", @@ -4136,7 +4137,7 @@ def _test_dbus_p2p_config(dev, apdev): def test_dbus_p2p_persistent(dev, apdev): """D-Bus P2P persistent group""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) class TestDbusP2p(TestDbus): @@ -4191,7 +4192,7 @@ def test_dbus_p2p_persistent(dev, apdev): res = p_obj.Get(WPAS_DBUS_PERSISTENT_GROUP, "Properties", dbus_interface=dbus.PROPERTIES_IFACE, byte_arrays=True) logger.info("Persistent group Properties: " + str(res)) - vals = dbus.Dictionary({ 'ssid': 'DIRECT-foo' }, signature='sv') + vals = dbus.Dictionary({'ssid': 'DIRECT-foo'}, signature='sv') p_obj.Set(WPAS_DBUS_PERSISTENT_GROUP, "Properties", vals, dbus_interface=dbus.PROPERTIES_IFACE) res2 = p_obj.Get(WPAS_DBUS_PERSISTENT_GROUP, "Properties", @@ -4204,8 +4205,8 @@ def test_dbus_p2p_persistent(dev, apdev): if res2['ssid'] != '"DIRECT-foo"': raise Exception("Unexpected ssid") - args = dbus.Dictionary({ 'ssid': 'DIRECT-testing', - 'psk': '1234567890' }, signature='sv') + args = dbus.Dictionary({'ssid': 'DIRECT-testing', + 'psk': '1234567890'}, signature='sv') group = p2p.AddPersistentGroup(args) groups = if_obj.Get(WPAS_DBUS_IFACE_P2PDEVICE, "PersistentGroups", @@ -4229,7 +4230,7 @@ def test_dbus_p2p_persistent(dev, apdev): def test_dbus_p2p_reinvoke_persistent(dev, apdev): """D-Bus P2P reinvoke persistent group""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -4272,7 +4273,7 @@ def test_dbus_p2p_reinvoke_persistent(dev, apdev): res = g_obj.GetAll(WPAS_DBUS_GROUP, dbus_interface=dbus.PROPERTIES_IFACE, byte_arrays=True) - bssid = ':'.join([ "%02x" % i for i in struct.unpack('6B', res['BSSID']) ]) + bssid = ':'.join(["%02x" % i for i in struct.unpack('6B', res['BSSID'])]) dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') dev1.scan_for_bss(bssid, freq=2412) dev1.global_request("P2P_CONNECT " + addr0 + " 12345670 join") @@ -4287,8 +4288,8 @@ def test_dbus_p2p_reinvoke_persistent(dev, apdev): dev1.global_request("SET persistent_reconnect 1") dev1.p2p_listen() - args = { 'persistent_group_object': dbus.ObjectPath(path), - 'peer': self.peer_path } + args = {'persistent_group_object': dbus.ObjectPath(path), + 'peer': self.peer_path} try: pin = p2p.Invite(args) raise Exception("Invalid Invite accepted") @@ -4296,8 +4297,8 @@ def test_dbus_p2p_reinvoke_persistent(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid Invite: " + str(e)) - args = { 'persistent_group_object': self.persistent, - 'peer': self.peer_path } + args = {'persistent_group_object': self.persistent, + 'peer': self.peer_path} pin = p2p.Invite(args) self.invited = True @@ -4321,12 +4322,12 @@ def test_dbus_p2p_reinvoke_persistent(dev, apdev): logger.debug("provisionDiscoveryRequestDisplayPin - peer=%s pin=%s" % (peer_object, pin)) self.peer_path = peer_object peer = binascii.unhexlify(peer_object.split('/')[-1]) - addr = ':'.join([ "%02x" % i for i in struct.unpack('6B', peer) ]) - params = { 'Role': 'registrar', - 'P2PDeviceAddress': self.peer['DeviceAddress'], - 'Bssid': self.peer['DeviceAddress'], - 'Type': 'pin', - 'Pin': '12345670' } + addr = ':'.join(["%02x" % i for i in struct.unpack('6B', peer)]) + params = {'Role': 'registrar', + 'P2PDeviceAddress': self.peer['DeviceAddress'], + 'Bssid': self.peer['DeviceAddress'], + 'Type': 'pin', + 'Pin': '12345670'} logger.info("Authorize peer to connect to the group") dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') wps = dbus.Interface(self.g_if_obj, WPAS_DBUS_IFACE_WPS) @@ -4364,7 +4365,7 @@ def test_dbus_p2p_reinvoke_persistent(dev, apdev): def test_dbus_p2p_go_neg_rx(dev, apdev): """D-Bus P2P GO Negotiation receive""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -4400,8 +4401,8 @@ def test_dbus_p2p_go_neg_rx(dev, apdev): logger.debug("goNegotiationRequest: path=%s dev_passwd_id=%d go_intent=%d" % (path, dev_passwd_id, go_intent)) if dev_passwd_id != 1: raise Exception("Unexpected dev_passwd_id=%d" % dev_passwd_id) - args = { 'peer': path, 'wps_method': 'display', 'pin': '12345670', - 'go_intent': 15, 'persistent': False, 'frequency': 5175 } + args = {'peer': path, 'wps_method': 'display', 'pin': '12345670', + 'go_intent': 15, 'persistent': False, 'frequency': 5175} try: p2p.Connect(args) raise Exception("Invalid Connect accepted") @@ -4409,8 +4410,8 @@ def test_dbus_p2p_go_neg_rx(dev, apdev): if "ConnectChannelUnsupported" not in str(e): raise Exception("Unexpected error message for invalid Connect: " + str(e)) - args = { 'peer': path, 'wps_method': 'display', 'pin': '12345670', - 'go_intent': 15, 'persistent': False } + args = {'peer': path, 'wps_method': 'display', 'pin': '12345670', + 'go_intent': 15, 'persistent': False} p2p.Connect(args) def goNegotiationSuccess(self, properties): @@ -4446,7 +4447,7 @@ def test_dbus_p2p_go_neg_rx(dev, apdev): def test_dbus_p2p_go_neg_auth(dev, apdev): """D-Bus P2P GO Negotiation authorized""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() dev[1].p2p_listen() @@ -4482,8 +4483,8 @@ def test_dbus_p2p_go_neg_auth(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) - args = { 'peer': path, 'wps_method': 'keypad', - 'go_intent': 15, 'authorize_only': True } + args = {'peer': path, 'wps_method': 'keypad', + 'go_intent': 15, 'authorize_only': True} try: p2p.Connect(args) raise Exception("Invalid Connect accepted") @@ -4491,8 +4492,8 @@ def test_dbus_p2p_go_neg_auth(dev, apdev): if "InvalidArgs" not in str(e): raise Exception("Unexpected error message for invalid Connect: " + str(e)) - args = { 'peer': path, 'wps_method': 'keypad', 'pin': '12345670', - 'go_intent': 15, 'authorize_only': True } + args = {'peer': path, 'wps_method': 'keypad', 'pin': '12345670', + 'go_intent': 15, 'authorize_only': True} p2p.Connect(args) p2p.Listen(10) dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') @@ -4547,7 +4548,7 @@ def test_dbus_p2p_go_neg_auth(dev, apdev): def test_dbus_p2p_go_neg_init(dev, apdev): """D-Bus P2P GO Negotiation initiation""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() dev[1].p2p_listen() @@ -4580,8 +4581,8 @@ def test_dbus_p2p_go_neg_init(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') - args = { 'peer': path, 'wps_method': 'keypad', 'pin': '12345670', - 'go_intent': 0 } + args = {'peer': path, 'wps_method': 'keypad', 'pin': '12345670', + 'go_intent': 0} p2p.Connect(args) ev = dev1.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15) @@ -4642,7 +4643,7 @@ def test_dbus_p2p_go_neg_init(dev, apdev): def test_dbus_p2p_group_termination_by_go(dev, apdev): """D-Bus P2P group removal on GO terminating the group""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() dev[1].p2p_listen() @@ -4675,8 +4676,8 @@ def test_dbus_p2p_group_termination_by_go(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') - args = { 'peer': path, 'wps_method': 'keypad', 'pin': '12345670', - 'go_intent': 0 } + args = {'peer': path, 'wps_method': 'keypad', 'pin': '12345670', + 'go_intent': 0} p2p.Connect(args) ev = dev1.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15) @@ -4737,7 +4738,7 @@ def test_dbus_p2p_group_idle_timeout(dev, apdev): dev[0].global_request("SET p2p_group_idle 0") def _test_dbus_p2p_group_idle_timeout(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() dev[1].p2p_listen() @@ -4771,8 +4772,8 @@ def _test_dbus_p2p_group_idle_timeout(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') - args = { 'peer': path, 'wps_method': 'keypad', 'pin': '12345670', - 'go_intent': 0 } + args = {'peer': path, 'wps_method': 'keypad', 'pin': '12345670', + 'go_intent': 0} p2p.Connect(args) ev = dev1.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15) @@ -4834,7 +4835,7 @@ def _test_dbus_p2p_group_idle_timeout(dev, apdev): def test_dbus_p2p_wps_failure(dev, apdev): """D-Bus P2P WPS failure""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) addr0 = dev[0].p2p_dev_addr() @@ -4869,8 +4870,8 @@ def test_dbus_p2p_wps_failure(dev, apdev): logger.debug("goNegotiationRequest: path=%s dev_passwd_id=%d go_intent=%d" % (path, dev_passwd_id, go_intent)) if dev_passwd_id != 1: raise Exception("Unexpected dev_passwd_id=%d" % dev_passwd_id) - args = { 'peer': path, 'wps_method': 'display', 'pin': '12345670', - 'go_intent': 15 } + args = {'peer': path, 'wps_method': 'display', 'pin': '12345670', + 'go_intent': 15} p2p.Connect(args) def goNegotiationSuccess(self, properties): @@ -4910,7 +4911,7 @@ def test_dbus_p2p_wps_failure(dev, apdev): def test_dbus_p2p_two_groups(dev, apdev): """D-Bus P2P with two concurrent groups""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) dev[0].request("SET p2p_no_group_iface 0") @@ -4952,9 +4953,9 @@ def test_dbus_p2p_two_groups(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) - if addr2.replace(':','') in path: + if addr2.replace(':', '') in path: self.peer = path - elif addr1.replace(':','') in path: + elif addr1.replace(':', '') in path: self.go = path if self.go and not self.group1: logger.info("Join the group") @@ -4963,11 +4964,11 @@ def test_dbus_p2p_two_groups(dev, apdev): dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') dev1.group_ifname = dev1_group_ifname dev1.group_request("WPS_PIN any " + pin) - args = { 'peer': self.go, - 'join': True, - 'wps_method': 'pin', - 'pin': pin, - 'frequency': 2412 } + args = {'peer': self.go, + 'join': True, + 'wps_method': 'pin', + 'pin': pin, + 'frequency': 2412} p2p.Connect(args) def groupStarted(self, properties): @@ -4990,7 +4991,7 @@ def test_dbus_p2p_two_groups(dev, apdev): self.group1iface) logger.info("Start autonomous GO") - params = dbus.Dictionary({ 'frequency': 2412 }) + params = dbus.Dictionary({'frequency': 2412}) p2p.GroupAdd(params) elif not self.group2: self.group2 = properties['group_object'] @@ -5001,16 +5002,16 @@ def test_dbus_p2p_two_groups(dev, apdev): if self.group1 and self.group2: logger.info("Authorize peer to join the group") - a2 = binascii.unhexlify(addr2.replace(':','')) - params = { 'Role': 'enrollee', - 'P2PDeviceAddress': dbus.ByteArray(a2), - 'Bssid': dbus.ByteArray(a2), - 'Type': 'pin', - 'Pin': '12345670' } + a2 = binascii.unhexlify(addr2.replace(':', '')) + params = {'Role': 'enrollee', + 'P2PDeviceAddress': dbus.ByteArray(a2), + 'Bssid': dbus.ByteArray(a2), + 'Type': 'pin', + 'Pin': '12345670'} g_wps = dbus.Interface(self.g2_if_obj, WPAS_DBUS_IFACE_WPS) g_wps.Start(params) - bssid = ':'.join([ "%02x" % i for i in struct.unpack('6B', self.g2_bssid) ]) + bssid = ':'.join(["%02x" % i for i in struct.unpack('6B', self.g2_bssid)]) dev2 = WpaSupplicant('wlan2', '/tmp/wpas-wlan2') dev2.scan_for_bss(bssid, freq=2412) dev2.global_request("P2P_CONNECT " + bssid + " 12345670 join freq=2412") @@ -5101,7 +5102,7 @@ def test_dbus_p2p_two_groups(dev, apdev): def test_dbus_p2p_cancel(dev, apdev): """D-Bus P2P Cancel""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) try: p2p.Cancel() @@ -5127,8 +5128,8 @@ def test_dbus_p2p_cancel(dev, apdev): def deviceFound(self, path): logger.debug("deviceFound: path=%s" % path) - args = { 'peer': path, 'wps_method': 'keypad', 'pin': '12345670', - 'go_intent': 0 } + args = {'peer': path, 'wps_method': 'keypad', 'pin': '12345670', + 'go_intent': 0} p2p.Connect(args) p2p.Cancel() self.done = True @@ -5148,13 +5149,13 @@ def test_dbus_p2p_cancel(dev, apdev): def test_dbus_p2p_ip_addr(dev, apdev): """D-Bus P2P and IP address parameters""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) p2p = dbus.Interface(if_obj, WPAS_DBUS_IFACE_P2PDEVICE) - vals = [ ("IpAddrGo", "192.168.43.1"), - ("IpAddrMask", "255.255.255.0"), - ("IpAddrStart", "192.168.43.100"), - ("IpAddrEnd", "192.168.43.199") ] + vals = [("IpAddrGo", "192.168.43.1"), + ("IpAddrMask", "255.255.255.0"), + ("IpAddrStart", "192.168.43.100"), + ("IpAddrEnd", "192.168.43.199")] for field, value in vals: if_obj.Set(WPAS_DBUS_IFACE, field, value, dbus_interface=dbus.PROPERTIES_IFACE) @@ -5220,7 +5221,7 @@ def test_dbus_p2p_ip_addr(dev, apdev): def test_dbus_introspect(dev, apdev): """D-Bus introspection""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) res = if_obj.Introspect(WPAS_DBUS_IFACE, dbus_interface=dbus.INTROSPECTABLE_IFACE) @@ -5266,7 +5267,7 @@ def test_dbus_introspect(dev, apdev): def run_busctl(service, obj): logger.info("busctl introspect %s %s" % (service, obj)) - cmd = subprocess.Popen([ 'busctl', 'introspect', service, obj ], + cmd = subprocess.Popen(['busctl', 'introspect', service, obj], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out = cmd.communicate() @@ -5279,13 +5280,13 @@ def run_busctl(service, obj): def test_dbus_introspect_busctl(dev, apdev): """D-Bus introspection with busctl""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) ifaces = dbus_get(dbus, wpas_obj, "Interfaces") run_busctl(WPAS_DBUS_SERVICE, WPAS_DBUS_PATH) run_busctl(WPAS_DBUS_SERVICE, WPAS_DBUS_PATH + "/Interfaces") run_busctl(WPAS_DBUS_SERVICE, ifaces[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) bssid = apdev[0]['bssid'] dev[0].scan_for_bss(bssid, freq=2412) id = dev[0].add_network() @@ -5297,7 +5298,7 @@ def test_dbus_introspect_busctl(dev, apdev): def test_dbus_ap(dev, apdev): """D-Bus AddNetwork for AP mode""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) ssid = "test-wpa2-psk" @@ -5381,12 +5382,12 @@ def test_dbus_ap(dev, apdev): def run_connect(self, *args): logger.debug("run_connect") - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'WPA-PSK', - 'psk': passphrase, - 'mode': 2, - 'frequency': 2412, - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'WPA-PSK', + 'psk': passphrase, + 'mode': 2, + 'frequency': 2412, + 'scan_freq': 2412}, signature='sv') self.netw = iface.AddNetwork(args) iface.SelectNetwork(self.netw) @@ -5402,7 +5403,7 @@ def test_dbus_ap(dev, apdev): def test_dbus_connect_wpa_eap(dev, apdev): """D-Bus AddNetwork and connection with WPA+WPA2-Enterprise AP""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) ssid = "test-wpa-eap" @@ -5436,14 +5437,14 @@ def test_dbus_connect_wpa_eap(dev, apdev): def run_connect(self, *args): logger.debug("run_connect") - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'WPA-EAP', - 'eap': 'PEAP', - 'identity': 'user', - 'password': 'password', - 'ca_cert': 'auth_serv/ca.pem', - 'phase2': 'auth=MSCHAPV2', - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'WPA-EAP', + 'eap': 'PEAP', + 'identity': 'user', + 'password': 'password', + 'ca_cert': 'auth_serv/ca.pem', + 'phase2': 'auth=MSCHAPV2', + 'scan_freq': 2412}, signature='sv') self.netw = iface.AddNetwork(args) iface.SelectNetwork(self.netw) @@ -5464,7 +5465,7 @@ def test_dbus_ap_scan_2_ap_mode_scan(dev, apdev): dev[0].request("AP_SCAN 1") def _test_dbus_ap_scan_2_ap_mode_scan(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) if "OK" not in dev[0].request("AP_SCAN 2"): @@ -5509,10 +5510,10 @@ def _test_dbus_ap_scan_2_ap_mode_scan(dev, apdev): def test_dbus_expectdisconnect(dev, apdev): """D-Bus ExpectDisconnect""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wpas = dbus.Interface(wpas_obj, WPAS_DBUS_SERVICE) - params = { "ssid": "test-open" } + params = {"ssid": "test-open"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412") @@ -5524,7 +5525,7 @@ def test_dbus_expectdisconnect(dev, apdev): def test_dbus_save_config(dev, apdev): """D-Bus SaveConfig""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) try: iface.SaveConfig() @@ -5541,7 +5542,7 @@ def test_dbus_vendor_elem(dev, apdev): dev[0].request("VENDOR_ELEM_REMOVE 1 *") def _test_dbus_vendor_elem(dev, apdev): - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) dev[0].request("VENDOR_ELEM_REMOVE 1 *") @@ -5646,12 +5647,12 @@ def _test_dbus_vendor_elem(dev, apdev): def test_dbus_assoc_reject(dev, apdev): """D-Bus AssocStatusCode""" - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) ssid = "test-open" - params = { "ssid": ssid, - "max_listen_interval": "1" } + params = {"ssid": ssid, + "max_listen_interval": "1"} hapd = hostapd.add_ap(apdev[0], params) class TestDbusConnect(TestDbus): @@ -5680,9 +5681,9 @@ def test_dbus_assoc_reject(dev, apdev): self.loop.quit() def run_connect(self, *args): - args = dbus.Dictionary({ 'ssid': ssid, - 'key_mgmt': 'NONE', - 'scan_freq': 2412 }, + args = dbus.Dictionary({'ssid': ssid, + 'key_mgmt': 'NONE', + 'scan_freq': 2412}, signature='sv') self.netw = iface.AddNetwork(args) iface.SelectNetwork(self.netw) @@ -5698,7 +5699,7 @@ def test_dbus_assoc_reject(dev, apdev): def test_dbus_mesh(dev, apdev): """D-Bus mesh""" check_mesh_support(dev[0]) - (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) mesh = dbus.Interface(if_obj, WPAS_DBUS_IFACE_MESH) add_open_mesh_network(dev[1]) diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py index a153fae..f14222d 100644 --- a/tests/hwsim/test_dfs.py +++ b/tests/hwsim/test_dfs.py @@ -16,9 +16,9 @@ import hostapd from utils import * def wait_dfs_event(hapd, event, timeout): - dfs_events = [ "DFS-RADAR-DETECTED", "DFS-NEW-CHANNEL", - "DFS-CAC-START", "DFS-CAC-COMPLETED", - "DFS-NOP-FINISHED", "AP-ENABLED", "AP-CSA-FINISHED" ] + dfs_events = ["DFS-RADAR-DETECTED", "DFS-NEW-CHANNEL", + "DFS-CAC-START", "DFS-CAC-COMPLETED", + "DFS-NOP-FINISHED", "AP-ENABLED", "AP-CSA-FINISHED"] ev = hapd.wait_event(dfs_events, timeout=timeout) if not ev: raise Exception("DFS event timed out") @@ -283,7 +283,7 @@ def test_dfs_radar2(dev, apdev): @remote_compatible def test_dfs_radar_on_non_dfs_channel(dev, apdev): """DFS radar detection test code on non-DFS channel""" - params = { "ssid": "radar" } + params = {"ssid": "radar"} hapd = hostapd.add_ap(apdev[0], params) hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1") diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 15c495e..646bc51 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -46,10 +46,10 @@ def test_dpp_qr_code_parsing(dev, apdev): check_dpp_capab(dev[0]) id = [] - tests = [ "DPP:C:81/1,115/36;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkq/24e0rsrfMP9K1Tm8gx+ovP0I=;;", - "DPP:C:81/1,81/2,81/3,81/4,81/5,81/6,81/7,81/8,81/9,81/10,81/11,81/12,81/13,82/14,83/1,83/2,83/3,83/4,83/5,83/6,83/7,83/8,83/9,84/5,84/6,84/7,84/8,84/9,84/10,84/11,84/12,84/13,115/36;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkq/24e0rsrfMP9K1Tm8gx+ovP0I=;;", - "DPP:I:SN=4774LH2b4044;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;", - "DPP:I:;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;" ] + tests = ["DPP:C:81/1,115/36;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkq/24e0rsrfMP9K1Tm8gx+ovP0I=;;", + "DPP:C:81/1,81/2,81/3,81/4,81/5,81/6,81/7,81/8,81/9,81/10,81/11,81/12,81/13,82/14,83/1,83/2,83/3,83/4,83/5,83/6,83/7,83/8,83/9,84/5,84/6,84/7,84/8,84/9,84/10,84/11,84/12,84/13,115/36;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkq/24e0rsrfMP9K1Tm8gx+ovP0I=;;", + "DPP:I:SN=4774LH2b4044;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;", + "DPP:I:;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;"] for uri in tests: id.append(dev[0].dpp_qr_code(uri)) @@ -57,20 +57,20 @@ def test_dpp_qr_code_parsing(dev, apdev): if uri != uri2: raise Exception("Returned URI does not match") - tests = [ "foo", - "DPP:", - "DPP:;;", - "DPP:C:1/2;M:;K;;", - "DPP:I:;M:01020304050;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;", - "DPP:K:" + base64.b64encode(b"hello").decode() + ";;", - "DPP:K:MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;", - "DPP:K:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANNZaZA4T/kRDjnmpI1ACOJhAuTIIEk2KFOpS6XPpGF+EVr/ao3XemkE0/nzXmGaLzLqTUCJknSdxTnVPeWfCVsCAwEAAQ==;;", - "DPP:K:MIIBCjCB0wYHKoZIzj0CATCBxwIBATAkBgcqhkjOPQEBAhkA/////////////////////v//////////MEsEGP////////////////////7//////////AQYZCEFGeWcgOcPp+mrciQwSf643uzBRrmxAxUAMEWub8hCL2TtV5Uo04Eg6uEhltUEMQQYjagOsDCQ9ny/IOtDoYgA9P8K/YL/EBIHGSuV/8jaeGMQEe1rJM3Vc/l3oR55SBECGQD///////////////+Z3vg2FGvJsbTSKDECAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;", - "DPP:I:foo\tbar;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;", - "DPP:C:1;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;", - "DPP:C:81/1a;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;", - "DPP:C:1/2000,81/-1;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;", - "DPP:C:-1/1;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;" ] + tests = ["foo", + "DPP:", + "DPP:;;", + "DPP:C:1/2;M:;K;;", + "DPP:I:;M:01020304050;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;", + "DPP:K:" + base64.b64encode(b"hello").decode() + ";;", + "DPP:K:MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;", + "DPP:K:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANNZaZA4T/kRDjnmpI1ACOJhAuTIIEk2KFOpS6XPpGF+EVr/ao3XemkE0/nzXmGaLzLqTUCJknSdxTnVPeWfCVsCAwEAAQ==;;", + "DPP:K:MIIBCjCB0wYHKoZIzj0CATCBxwIBATAkBgcqhkjOPQEBAhkA/////////////////////v//////////MEsEGP////////////////////7//////////AQYZCEFGeWcgOcPp+mrciQwSf643uzBRrmxAxUAMEWub8hCL2TtV5Uo04Eg6uEhltUEMQQYjagOsDCQ9ny/IOtDoYgA9P8K/YL/EBIHGSuV/8jaeGMQEe1rJM3Vc/l3oR55SBECGQD///////////////+Z3vg2FGvJsbTSKDECAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;", + "DPP:I:foo\tbar;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;", + "DPP:C:1;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;", + "DPP:C:81/1a;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;", + "DPP:C:1/2000,81/-1;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;", + "DPP:C:-1/1;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkqa24e0rsrfMP9K1Tm8gx+ovP0I=;;"] for t in tests: res = dev[0].request("DPP_QR_CODE " + t) if "FAIL" not in res: @@ -117,7 +117,7 @@ def test_dpp_qr_code_parsing_fail(dev, apdev): if "FAIL" not in dev[0].request("DPP_QR_CODE DPP:I:SN=4774LH2b4044;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;"): raise Exception("DPP_QR_CODE failure not reported") -dpp_key_p256 ="30570201010420777fc55dc51e967c10ec051b91d860b5f1e6c934e48d5daffef98d032c64b170a00a06082a8648ce3d030107a124032200020c804188c7f85beb6e91070d2b3e5e39b90ca77b4d3c5251bc1844d6ca29dcad" +dpp_key_p256 = "30570201010420777fc55dc51e967c10ec051b91d860b5f1e6c934e48d5daffef98d032c64b170a00a06082a8648ce3d030107a124032200020c804188c7f85beb6e91070d2b3e5e39b90ca77b4d3c5251bc1844d6ca29dcad" dpp_key_p384 = "307402010104302f56fdd83b5345cacb630eb7c22fa5ad5daba37307c95191e2a75756d137003bd8b32dbcb00eb5650c1eb499ecfcaec0a00706052b81040022a13403320003615ec2141b5b77aebb6523f8a012755f9a34405a8398d2ceeeebca7f5ce868bf55056cba4c4ec62fad3ed26dd29e0f23" dpp_key_p521 = "308198020101044200c8010d5357204c252551aaf4e210343111e503fd1dc615b257058997c49b6b643c975226e93be8181cca3d83a7072defd161dfbdf433c19abe1f2ad51867a05761a00706052b81040023a1460344000301cdf3608b1305fe34a1f976095dcf001182b9973354efe156291a66830292f9babd8f412ad462958663e7a75d1d0610abdfc3dd95d40669f7ab3bc001668cfb3b7c" dpp_key_bp256 = "3058020101042057133a676fb60bf2a3e6797e19833c7b0f89dc192ab99ab5fa377ae23a157765a00b06092b2403030208010107a12403220002945d9bf7ce30c9c1ac0ff21ca62b984d5bb80ff69d2be8c9716ab39a10d2caf0" @@ -127,9 +127,9 @@ dpp_key_bp512 = "30819802010104405803494226eb7e50bf0e90633f37e7e35d33f5fa502165e def test_dpp_qr_code_curves(dev, apdev): """DPP QR Code and supported curves""" check_dpp_capab(dev[0]) - tests = [ ("prime256v1", dpp_key_p256), - ("secp384r1", dpp_key_p384), - ("secp521r1", dpp_key_p521) ] + tests = [("prime256v1", dpp_key_p256), + ("secp384r1", dpp_key_p384), + ("secp521r1", dpp_key_p521)] for curve, hex in tests: id = dev[0].dpp_bootstrap_gen(key=hex) info = dev[0].request("DPP_BOOTSTRAP_INFO %d" % id) @@ -141,9 +141,9 @@ def test_dpp_qr_code_curves(dev, apdev): def test_dpp_qr_code_curves_brainpool(dev, apdev): """DPP QR Code and supported Brainpool curves""" check_dpp_capab(dev[0], brainpool=True) - tests = [ ("brainpoolP256r1", dpp_key_bp256), - ("brainpoolP384r1", dpp_key_bp384), - ("brainpoolP512r1", dpp_key_bp512) ] + tests = [("brainpoolP256r1", dpp_key_bp256), + ("brainpoolP384r1", dpp_key_bp384), + ("brainpoolP512r1", dpp_key_bp512)] for curve, hex in tests: id = dev[0].dpp_bootstrap_gen(key=hex) info = dev[0].request("DPP_BOOTSTRAP_INFO %d" % id) @@ -160,8 +160,8 @@ def test_dpp_qr_code_unsupported_curve(dev, apdev): if "FAIL" not in id: raise Exception("Unsupported curve accepted") - tests = [ "30", - "305f02010104187f723ed9e1b41979ec5cd02eb82696efc76b40e277661049a00a06082a8648ce3d030101a134033200043f292614dea97c43f500f069e79ae9fb48f8b07369180de5eec8fa2bc9eea5af7a46dc335f52f10cb1c0e9464201d41b" ] + tests = ["30", + "305f02010104187f723ed9e1b41979ec5cd02eb82696efc76b40e277661049a00a06082a8648ce3d030101a134033200043f292614dea97c43f500f069e79ae9fb48f8b07369180de5eec8fa2bc9eea5af7a46dc335f52f10cb1c0e9464201d41b"] for hex in tests: id = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode key=" + hex) if "FAIL" not in id: @@ -185,8 +185,8 @@ def test_dpp_qr_code_curve_select(dev, apdev): check_dpp_capab(dev[1], brainpool=True) bi = [] - for key in [ dpp_key_p256, dpp_key_p384, dpp_key_p521, - dpp_key_bp256, dpp_key_bp384, dpp_key_bp512 ]: + for key in [dpp_key_p256, dpp_key_p384, dpp_key_p521, + dpp_key_bp256, dpp_key_bp384, dpp_key_bp512]: id = dev[0].dpp_bootstrap_gen(chan="81/1", mac=True, key=key) info = dev[0].request("DPP_BOOTSTRAP_INFO %d" % id) for i in info.splitlines(): @@ -610,7 +610,7 @@ def test_dpp_qr_code_auth_mutual_curve_mismatch(dev, apdev): def test_dpp_qr_code_auth_hostapd_mutual2(dev, apdev): """DPP QR Code and authentication exchange (hostapd mutual2)""" check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) logger.info("AP displays QR Code") @@ -1226,32 +1226,32 @@ def test_dpp_config_jws_error_prot_hdr_not_an_object(dev, apdev): def test_dpp_config_jws_error_prot_hdr_no_typ(dev, apdev): """DPP Config Object JWS error - protected header - no typ""" - prot_hdr='{"kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU","alg":"ES256"}' + prot_hdr = '{"kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU","alg":"ES256"}' run_dpp_config_error(dev, apdev, build_conf_obj(prot_hdr=prot_hdr)) def test_dpp_config_jws_error_prot_hdr_unsupported_typ(dev, apdev): """DPP Config Object JWS error - protected header - unsupported typ""" - prot_hdr='{"typ":"unsupported","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU","alg":"ES256"}' + prot_hdr = '{"typ":"unsupported","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU","alg":"ES256"}' run_dpp_config_error(dev, apdev, build_conf_obj(prot_hdr=prot_hdr)) def test_dpp_config_jws_error_prot_hdr_no_alg(dev, apdev): """DPP Config Object JWS error - protected header - no alg""" - prot_hdr='{"typ":"dppCon","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU"}' + prot_hdr = '{"typ":"dppCon","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU"}' run_dpp_config_error(dev, apdev, build_conf_obj(prot_hdr=prot_hdr)) def test_dpp_config_jws_error_prot_hdr_unexpected_alg(dev, apdev): """DPP Config Object JWS error - protected header - unexpected alg""" - prot_hdr='{"typ":"dppCon","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU","alg":"unexpected"}' + prot_hdr = '{"typ":"dppCon","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU","alg":"unexpected"}' run_dpp_config_error(dev, apdev, build_conf_obj(prot_hdr=prot_hdr)) def test_dpp_config_jws_error_prot_hdr_no_kid(dev, apdev): """DPP Config Object JWS error - protected header - no kid""" - prot_hdr='{"typ":"dppCon","alg":"ES256"}' + prot_hdr = '{"typ":"dppCon","alg":"ES256"}' run_dpp_config_error(dev, apdev, build_conf_obj(prot_hdr=prot_hdr)) def test_dpp_config_jws_error_prot_hdr_unexpected_kid(dev, apdev): """DPP Config Object JWS error - protected header - unexpected kid""" - prot_hdr='{"typ":"dppCon","kid":"MTIz","alg":"ES256"}' + prot_hdr = '{"typ":"dppCon","kid":"MTIz","alg":"ES256"}' run_dpp_config_error(dev, apdev, build_conf_obj(prot_hdr=prot_hdr)) def test_dpp_config_signed_connector_error_no_dot_1(dev, apdev): @@ -1368,14 +1368,14 @@ def test_dpp_config_error_legacy_too_short_psk(dev, apdev): def ecdsa_sign(pkey, message, alg="sha256"): sign = OpenSSL.crypto.sign(pkey, message, alg) - a,b = struct.unpack('BB', sign[0:2]) + a, b = struct.unpack('BB', sign[0:2]) if a != 0x30: raise Exception("Invalid DER encoding of ECDSA signature") if b != len(sign) - 2: raise Exception("Invalid length of ECDSA signature") sign = sign[2:] - a,b = struct.unpack('BB', sign[0:2]) + a, b = struct.unpack('BB', sign[0:2]) if a != 0x02: raise Exception("Invalid DER encoding of ECDSA signature r") if b > len(sign) - 2: @@ -1390,7 +1390,7 @@ def ecdsa_sign(pkey, message, alg="sha256"): else: raise Exception("Invalid length of ECDSA signature r") - a,b = struct.unpack('BB', sign[0:2]) + a, b = struct.unpack('BB', sign[0:2]) if a != 0x02: raise Exception("Invalid DER encoding of ECDSA signature s") if b > len(sign) - 2: @@ -1608,11 +1608,11 @@ def test_dpp_akm_sha512(dev, apdev): def run_dpp_akm(dev, apdev, pmk_len): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - params = { "ssid": "dpp", - "wpa": "2", - "wpa_key_mgmt": "DPP", - "rsn_pairwise": "CCMP", - "ieee80211w": "2" } + params = {"ssid": "dpp", + "wpa": "2", + "wpa_key_mgmt": "DPP", + "rsn_pairwise": "CCMP", + "ieee80211w": "2"} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1664,14 +1664,14 @@ def test_dpp_network_introduction(dev, apdev): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - params = { "ssid": "dpp", - "wpa": "2", - "wpa_key_mgmt": "DPP", - "ieee80211w": "2", - "rsn_pairwise": "CCMP", - "dpp_connector": params1_ap_connector, - "dpp_csign": params1_csign, - "dpp_netaccesskey": params1_ap_netaccesskey } + params = {"ssid": "dpp", + "wpa": "2", + "wpa_key_mgmt": "DPP", + "ieee80211w": "2", + "rsn_pairwise": "CCMP", + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1693,15 +1693,15 @@ def test_dpp_and_sae_akm(dev, apdev): if "SAE" not in dev[1].get_capability("auth_alg"): raise HwsimSkip("SAE not supported") - params = { "ssid": "dpp+sae", - "wpa": "2", - "wpa_key_mgmt": "DPP SAE", - "ieee80211w": "2", - "rsn_pairwise": "CCMP", - "sae_password": "sae-password", - "dpp_connector": params1_ap_connector, - "dpp_csign": params1_csign, - "dpp_netaccesskey": params1_ap_netaccesskey } + params = {"ssid": "dpp+sae", + "wpa": "2", + "wpa_key_mgmt": "DPP SAE", + "ieee80211w": "2", + "rsn_pairwise": "CCMP", + "sae_password": "sae-password", + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1808,7 +1808,7 @@ def run_dpp_ap_config(dev, apdev, curve=None, conf_curve=None, reconf_configurator=False): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) id_h = hapd.dpp_bootstrap_gen(chan="81/1", mac=True, curve=curve) @@ -1942,7 +1942,7 @@ def test_dpp_auto_connect_2_connect_cmd(dev, apdev): """DPP and auto connect (2) using connect_cmd""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") - dev_new = [ wpas, dev[1] ] + dev_new = [wpas, dev[1]] try: run_dpp_auto_connect(dev_new, apdev, 2) finally: @@ -1957,14 +1957,14 @@ def run_dpp_auto_connect(dev, apdev, processing): ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" - params = { "ssid": "test", - "wpa": "2", - "wpa_key_mgmt": "DPP", - "ieee80211w": "2", - "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign_pub, - "dpp_netaccesskey": ap_netaccesskey } + params = {"ssid": "test", + "wpa": "2", + "wpa_key_mgmt": "DPP", + "ieee80211w": "2", + "rsn_pairwise": "CCMP", + "dpp_connector": ap_connector, + "dpp_csign": csign_pub, + "dpp_netaccesskey": ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -2190,8 +2190,8 @@ def run_dpp_qr_code_auth_responder_configurator(dev, apdev, extra): def test_dpp_qr_code_hostapd_init(dev, apdev): """DPP QR Code and hostapd as initiator""" check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured", - "channel": "6" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", + "channel": "6"}) check_dpp_capab(hapd) cmd = "DPP_CONFIGURATOR_ADD" @@ -2239,8 +2239,8 @@ def test_dpp_qr_code_hostapd_init_offchannel_neg_freq(dev, apdev): def run_dpp_qr_code_hostapd_init_offchannel(dev, apdev, extra): check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured", - "channel": "6" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", + "channel": "6"}) check_dpp_capab(hapd) cmd = "DPP_CONFIGURATOR_ADD" @@ -2948,8 +2948,8 @@ def test_dpp_pkex_after_retry(dev, apdev): def test_dpp_pkex_hostapd_responder(dev, apdev): """DPP PKEX with hostapd as responder""" check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured", - "channel": "6" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", + "channel": "6"}) check_dpp_capab(hapd) id_h = hapd.dpp_bootstrap_gen(type="pkex") @@ -2990,8 +2990,8 @@ def test_dpp_pkex_hostapd_responder(dev, apdev): def test_dpp_pkex_hostapd_initiator(dev, apdev): """DPP PKEX with hostapd as initiator""" check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured", - "channel": "6" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", + "channel": "6"}) check_dpp_capab(hapd) cmd = "DPP_CONFIGURATOR_ADD" @@ -3039,8 +3039,8 @@ def test_dpp_pkex_hostapd_initiator(dev, apdev): def test_dpp_hostapd_configurator(dev, apdev): """DPP with hostapd as configurator/initiator""" check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured", - "channel": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", + "channel": "1"}) check_dpp_capab(hapd) cmd = "DPP_CONFIGURATOR_ADD" @@ -3087,8 +3087,8 @@ def test_dpp_hostapd_configurator(dev, apdev): def test_dpp_hostapd_configurator_responder(dev, apdev): """DPP with hostapd as configurator/responder""" check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured", - "channel": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured", + "channel": "1"}) check_dpp_capab(hapd) cmd = "DPP_CONFIGURATOR_ADD" @@ -3148,7 +3148,7 @@ def test_dpp_own_config_curve_mismatch(dev, apdev): def run_dpp_own_config(dev, apdev, own_curve=None, expect_failure=False, extra=""): check_dpp_capab(dev[0], own_curve and "BP" in own_curve) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) id_h = hapd.dpp_bootstrap_gen(chan="81/1", mac=True) @@ -3224,7 +3224,7 @@ def test_dpp_own_config_ap_reconf(dev, apdev): def run_dpp_own_config_ap(dev, apdev, reconf_configurator=False, extra=""): check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) cmd = "DPP_CONFIGURATOR_ADD" @@ -3299,7 +3299,7 @@ def run_dpp_intro_mismatch(dev, apdev, wpas): check_dpp_capab(dev[2]) logger.info("Start AP in unconfigured state") - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) id_h = hapd.dpp_bootstrap_gen(chan="81/1", mac=True) @@ -4226,20 +4226,20 @@ def test_dpp_proto_network_introduction(dev, apdev): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - params = { "ssid": "dpp", - "wpa": "2", - "wpa_key_mgmt": "DPP", - "ieee80211w": "2", - "rsn_pairwise": "CCMP", - "dpp_connector": params1_ap_connector, - "dpp_csign": params1_csign, - "dpp_netaccesskey": params1_ap_netaccesskey } + params = {"ssid": "dpp", + "wpa": "2", + "wpa_key_mgmt": "DPP", + "ieee80211w": "2", + "rsn_pairwise": "CCMP", + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: raise HwsimSkip("DPP not supported") - for test in [ 60, 61, 80, 82 ]: + for test in [60, 61, 80, 82]: dev[0].set("dpp_test", str(test)) dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", dpp_csign=params1_csign, @@ -4270,7 +4270,7 @@ def test_dpp_proto_network_introduction(dev, apdev): hapd.dump_monitor() dev[0].set("dpp_test", "0") - for test in [ 62, 63, 64, 77, 78, 79 ]: + for test in [62, 63, 64, 77, 78, 79]: hapd.set("dpp_test", str(test)) dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", dpp_csign=params1_csign, @@ -4384,8 +4384,8 @@ def test_dpp_pkex_alloc_fail(dev, apdev): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ (1, "=dpp_keygen_configurator"), - (1, "base64_gen_encode;dpp_keygen_configurator") ] + tests = [(1, "=dpp_keygen_configurator"), + (1, "base64_gen_encode;dpp_keygen_configurator")] for count, func in tests: with alloc_fail(dev[1], count, func): cmd = "DPP_CONFIGURATOR_ADD" @@ -4403,39 +4403,39 @@ def test_dpp_pkex_alloc_fail(dev, apdev): id1 = dev[1].dpp_bootstrap_gen(type="pkex") # Local error cases on the Initiator - tests = [ (1, "dpp_get_pubkey_point"), - (1, "dpp_alloc_msg;dpp_pkex_build_exchange_req"), - (1, "dpp_alloc_msg;dpp_pkex_build_commit_reveal_req"), - (1, "dpp_alloc_msg;dpp_auth_build_req"), - (1, "dpp_alloc_msg;dpp_auth_build_conf"), - (1, "dpp_bootstrap_key_hash"), - (1, "dpp_auth_init"), - (1, "=dpp_auth_resp_rx"), - (2, "=dpp_auth_resp_rx"), - (1, "dpp_build_conf_start"), - (1, "dpp_build_conf_obj_dpp"), - (2, "dpp_build_conf_obj_dpp"), - (3, "dpp_build_conf_obj_dpp"), - (4, "dpp_build_conf_obj_dpp"), - (5, "dpp_build_conf_obj_dpp"), - (6, "dpp_build_conf_obj_dpp"), - (7, "dpp_build_conf_obj_dpp"), - (8, "dpp_build_conf_obj_dpp"), - (1, "dpp_conf_req_rx"), - (2, "dpp_conf_req_rx"), - (3, "dpp_conf_req_rx"), - (4, "dpp_conf_req_rx"), - (5, "dpp_conf_req_rx"), - (6, "dpp_conf_req_rx"), - (7, "dpp_conf_req_rx"), - (1, "dpp_pkex_init"), - (2, "dpp_pkex_init"), - (3, "dpp_pkex_init"), - (1, "dpp_pkex_derive_z"), - (1, "=dpp_pkex_rx_commit_reveal_resp"), - (1, "dpp_get_pubkey_point;dpp_build_jwk"), - (2, "dpp_get_pubkey_point;dpp_build_jwk"), - (1, "dpp_get_pubkey_point;dpp_auth_init") ] + tests = [(1, "dpp_get_pubkey_point"), + (1, "dpp_alloc_msg;dpp_pkex_build_exchange_req"), + (1, "dpp_alloc_msg;dpp_pkex_build_commit_reveal_req"), + (1, "dpp_alloc_msg;dpp_auth_build_req"), + (1, "dpp_alloc_msg;dpp_auth_build_conf"), + (1, "dpp_bootstrap_key_hash"), + (1, "dpp_auth_init"), + (1, "=dpp_auth_resp_rx"), + (2, "=dpp_auth_resp_rx"), + (1, "dpp_build_conf_start"), + (1, "dpp_build_conf_obj_dpp"), + (2, "dpp_build_conf_obj_dpp"), + (3, "dpp_build_conf_obj_dpp"), + (4, "dpp_build_conf_obj_dpp"), + (5, "dpp_build_conf_obj_dpp"), + (6, "dpp_build_conf_obj_dpp"), + (7, "dpp_build_conf_obj_dpp"), + (8, "dpp_build_conf_obj_dpp"), + (1, "dpp_conf_req_rx"), + (2, "dpp_conf_req_rx"), + (3, "dpp_conf_req_rx"), + (4, "dpp_conf_req_rx"), + (5, "dpp_conf_req_rx"), + (6, "dpp_conf_req_rx"), + (7, "dpp_conf_req_rx"), + (1, "dpp_pkex_init"), + (2, "dpp_pkex_init"), + (3, "dpp_pkex_init"), + (1, "dpp_pkex_derive_z"), + (1, "=dpp_pkex_rx_commit_reveal_resp"), + (1, "dpp_get_pubkey_point;dpp_build_jwk"), + (2, "dpp_get_pubkey_point;dpp_build_jwk"), + (1, "dpp_get_pubkey_point;dpp_auth_init")] for count, func in tests: dev[0].request("DPP_STOP_LISTEN") dev[1].request("DPP_STOP_LISTEN") @@ -4460,36 +4460,36 @@ def test_dpp_pkex_alloc_fail(dev, apdev): dev[0].wait_event(["GAS-QUERY-DONE"], timeout=3) # Local error cases on the Responder - tests = [ (1, "dpp_get_pubkey_point"), - (1, "dpp_alloc_msg;dpp_pkex_build_exchange_resp"), - (1, "dpp_alloc_msg;dpp_pkex_build_commit_reveal_resp"), - (1, "dpp_alloc_msg;dpp_auth_build_resp"), - (1, "dpp_get_pubkey_point;dpp_auth_build_resp_ok"), - (1, "=dpp_auth_req_rx"), - (2, "=dpp_auth_req_rx"), - (1, "=dpp_auth_conf_rx"), - (1, "json_parse;dpp_parse_jws_prot_hdr"), - (1, "json_get_member_base64url;dpp_parse_jws_prot_hdr"), - (1, "json_get_member_base64url;dpp_parse_jwk"), - (2, "json_get_member_base64url;dpp_parse_jwk"), - (1, "json_parse;dpp_parse_connector"), - (1, "dpp_parse_jwk;dpp_parse_connector"), - (1, "dpp_parse_jwk;dpp_parse_cred_dpp"), - (1, "dpp_get_pubkey_point;dpp_check_pubkey_match"), - (1, "base64_gen_decode;dpp_process_signed_connector"), - (1, "dpp_parse_jws_prot_hdr;dpp_process_signed_connector"), - (2, "base64_gen_decode;dpp_process_signed_connector"), - (3, "base64_gen_decode;dpp_process_signed_connector"), - (4, "base64_gen_decode;dpp_process_signed_connector"), - (1, "json_parse;dpp_parse_conf_obj"), - (1, "dpp_conf_resp_rx"), - (1, "=dpp_pkex_derive_z"), - (1, "=dpp_pkex_rx_exchange_req"), - (2, "=dpp_pkex_rx_exchange_req"), - (3, "=dpp_pkex_rx_exchange_req"), - (1, "=dpp_pkex_rx_commit_reveal_req"), - (1, "dpp_get_pubkey_point;dpp_pkex_rx_commit_reveal_req"), - (1, "dpp_bootstrap_key_hash") ] + tests = [(1, "dpp_get_pubkey_point"), + (1, "dpp_alloc_msg;dpp_pkex_build_exchange_resp"), + (1, "dpp_alloc_msg;dpp_pkex_build_commit_reveal_resp"), + (1, "dpp_alloc_msg;dpp_auth_build_resp"), + (1, "dpp_get_pubkey_point;dpp_auth_build_resp_ok"), + (1, "=dpp_auth_req_rx"), + (2, "=dpp_auth_req_rx"), + (1, "=dpp_auth_conf_rx"), + (1, "json_parse;dpp_parse_jws_prot_hdr"), + (1, "json_get_member_base64url;dpp_parse_jws_prot_hdr"), + (1, "json_get_member_base64url;dpp_parse_jwk"), + (2, "json_get_member_base64url;dpp_parse_jwk"), + (1, "json_parse;dpp_parse_connector"), + (1, "dpp_parse_jwk;dpp_parse_connector"), + (1, "dpp_parse_jwk;dpp_parse_cred_dpp"), + (1, "dpp_get_pubkey_point;dpp_check_pubkey_match"), + (1, "base64_gen_decode;dpp_process_signed_connector"), + (1, "dpp_parse_jws_prot_hdr;dpp_process_signed_connector"), + (2, "base64_gen_decode;dpp_process_signed_connector"), + (3, "base64_gen_decode;dpp_process_signed_connector"), + (4, "base64_gen_decode;dpp_process_signed_connector"), + (1, "json_parse;dpp_parse_conf_obj"), + (1, "dpp_conf_resp_rx"), + (1, "=dpp_pkex_derive_z"), + (1, "=dpp_pkex_rx_exchange_req"), + (2, "=dpp_pkex_rx_exchange_req"), + (3, "=dpp_pkex_rx_exchange_req"), + (1, "=dpp_pkex_rx_commit_reveal_req"), + (1, "dpp_get_pubkey_point;dpp_pkex_rx_commit_reveal_req"), + (1, "dpp_bootstrap_key_hash")] for count, func in tests: dev[0].request("DPP_STOP_LISTEN") dev[1].request("DPP_STOP_LISTEN") @@ -4518,7 +4518,7 @@ def test_dpp_pkex_test_fail(dev, apdev): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ (1, "dpp_keygen_configurator") ] + tests = [(1, "dpp_keygen_configurator")] for count, func in tests: with fail_test(dev[1], count, func): cmd = "DPP_CONFIGURATOR_ADD" @@ -4526,7 +4526,7 @@ def test_dpp_pkex_test_fail(dev, apdev): if "FAIL" not in res: raise Exception("Unexpected DPP_CONFIGURATOR_ADD success") - tests = [ (1, "dpp_keygen") ] + tests = [(1, "dpp_keygen")] for count, func in tests: with fail_test(dev[1], count, func): cmd = "DPP_BOOTSTRAP_GEN type=pkex" @@ -4544,24 +4544,24 @@ def test_dpp_pkex_test_fail(dev, apdev): id1 = dev[1].dpp_bootstrap_gen(type="pkex") # Local error cases on the Initiator - tests = [ (1, "aes_siv_encrypt;dpp_auth_build_req"), - (1, "os_get_random;dpp_auth_init"), - (1, "dpp_derive_k1;dpp_auth_init"), - (1, "dpp_hkdf_expand;dpp_derive_k1;dpp_auth_init"), - (1, "dpp_gen_i_auth;dpp_auth_build_conf"), - (1, "aes_siv_encrypt;dpp_auth_build_conf"), - (1, "dpp_derive_k2;dpp_auth_resp_rx"), - (1, "dpp_hkdf_expand;dpp_derive_k2;dpp_auth_resp_rx"), - (1, "dpp_derive_ke;dpp_auth_resp_rx"), - (1, "dpp_hkdf_expand;dpp_derive_ke;dpp_auth_resp_rx"), - (1, "dpp_gen_r_auth;dpp_auth_resp_rx"), - (1, "aes_siv_encrypt;dpp_build_conf_resp"), - (1, "dpp_pkex_derive_Qi;dpp_pkex_build_exchange_req"), - (1, "aes_siv_encrypt;dpp_pkex_build_commit_reveal_req"), - (1, "hmac_sha256_vector;dpp_pkex_rx_exchange_resp"), - (1, "aes_siv_decrypt;dpp_pkex_rx_commit_reveal_resp"), - (1, "hmac_sha256_vector;dpp_pkex_rx_commit_reveal_resp"), - (1, "dpp_bootstrap_key_hash") ] + tests = [(1, "aes_siv_encrypt;dpp_auth_build_req"), + (1, "os_get_random;dpp_auth_init"), + (1, "dpp_derive_k1;dpp_auth_init"), + (1, "dpp_hkdf_expand;dpp_derive_k1;dpp_auth_init"), + (1, "dpp_gen_i_auth;dpp_auth_build_conf"), + (1, "aes_siv_encrypt;dpp_auth_build_conf"), + (1, "dpp_derive_k2;dpp_auth_resp_rx"), + (1, "dpp_hkdf_expand;dpp_derive_k2;dpp_auth_resp_rx"), + (1, "dpp_derive_ke;dpp_auth_resp_rx"), + (1, "dpp_hkdf_expand;dpp_derive_ke;dpp_auth_resp_rx"), + (1, "dpp_gen_r_auth;dpp_auth_resp_rx"), + (1, "aes_siv_encrypt;dpp_build_conf_resp"), + (1, "dpp_pkex_derive_Qi;dpp_pkex_build_exchange_req"), + (1, "aes_siv_encrypt;dpp_pkex_build_commit_reveal_req"), + (1, "hmac_sha256_vector;dpp_pkex_rx_exchange_resp"), + (1, "aes_siv_decrypt;dpp_pkex_rx_commit_reveal_resp"), + (1, "hmac_sha256_vector;dpp_pkex_rx_commit_reveal_resp"), + (1, "dpp_bootstrap_key_hash")] for count, func in tests: dev[0].request("DPP_STOP_LISTEN") dev[1].request("DPP_STOP_LISTEN") @@ -4586,28 +4586,28 @@ def test_dpp_pkex_test_fail(dev, apdev): dev[0].wait_event(["GAS-QUERY-DONE"], timeout=3) # Local error cases on the Responder - tests = [ (1, "aes_siv_encrypt;dpp_auth_build_resp"), - (1, "aes_siv_encrypt;dpp_auth_build_resp;dpp_auth_build_resp_ok"), - (1, "os_get_random;dpp_build_conf_req"), - (1, "aes_siv_encrypt;dpp_build_conf_req"), - (1, "os_get_random;dpp_auth_build_resp_ok"), - (1, "dpp_derive_k2;dpp_auth_build_resp_ok"), - (1, "dpp_derive_ke;dpp_auth_build_resp_ok"), - (1, "dpp_gen_r_auth;dpp_auth_build_resp_ok"), - (1, "aes_siv_encrypt;dpp_auth_build_resp_ok"), - (1, "dpp_derive_k1;dpp_auth_req_rx"), - (1, "aes_siv_decrypt;dpp_auth_req_rx"), - (1, "aes_siv_decrypt;dpp_auth_conf_rx"), - (1, "dpp_gen_i_auth;dpp_auth_conf_rx"), - (1, "dpp_check_pubkey_match"), - (1, "aes_siv_decrypt;dpp_conf_resp_rx"), - (1, "hmac_sha256_kdf;dpp_pkex_derive_z"), - (1, "dpp_pkex_derive_Qi;dpp_pkex_rx_exchange_req"), - (1, "dpp_pkex_derive_Qr;dpp_pkex_rx_exchange_req"), - (1, "aes_siv_encrypt;dpp_pkex_build_commit_reveal_resp"), - (1, "aes_siv_decrypt;dpp_pkex_rx_commit_reveal_req"), - (1, "hmac_sha256_vector;dpp_pkex_rx_commit_reveal_req"), - (2, "hmac_sha256_vector;dpp_pkex_rx_commit_reveal_req") ] + tests = [(1, "aes_siv_encrypt;dpp_auth_build_resp"), + (1, "aes_siv_encrypt;dpp_auth_build_resp;dpp_auth_build_resp_ok"), + (1, "os_get_random;dpp_build_conf_req"), + (1, "aes_siv_encrypt;dpp_build_conf_req"), + (1, "os_get_random;dpp_auth_build_resp_ok"), + (1, "dpp_derive_k2;dpp_auth_build_resp_ok"), + (1, "dpp_derive_ke;dpp_auth_build_resp_ok"), + (1, "dpp_gen_r_auth;dpp_auth_build_resp_ok"), + (1, "aes_siv_encrypt;dpp_auth_build_resp_ok"), + (1, "dpp_derive_k1;dpp_auth_req_rx"), + (1, "aes_siv_decrypt;dpp_auth_req_rx"), + (1, "aes_siv_decrypt;dpp_auth_conf_rx"), + (1, "dpp_gen_i_auth;dpp_auth_conf_rx"), + (1, "dpp_check_pubkey_match"), + (1, "aes_siv_decrypt;dpp_conf_resp_rx"), + (1, "hmac_sha256_kdf;dpp_pkex_derive_z"), + (1, "dpp_pkex_derive_Qi;dpp_pkex_rx_exchange_req"), + (1, "dpp_pkex_derive_Qr;dpp_pkex_rx_exchange_req"), + (1, "aes_siv_encrypt;dpp_pkex_build_commit_reveal_resp"), + (1, "aes_siv_decrypt;dpp_pkex_rx_commit_reveal_req"), + (1, "hmac_sha256_vector;dpp_pkex_rx_commit_reveal_req"), + (2, "hmac_sha256_vector;dpp_pkex_rx_commit_reveal_req")] for count, func in tests: dev[0].request("DPP_STOP_LISTEN") dev[1].request("DPP_STOP_LISTEN") @@ -4976,11 +4976,11 @@ def test_dpp_own_config_sign_fail(dev, apdev): if "FAIL" in res: raise Exception("Failed to add configurator") conf_id = int(res) - tests = [ "", - " ", - " conf=sta-dpp", - " configurator=%d" % conf_id, - " conf=sta-dpp configurator=%d curve=unsupported" % conf_id ] + tests = ["", + " ", + " conf=sta-dpp", + " configurator=%d" % conf_id, + " conf=sta-dpp configurator=%d curve=unsupported" % conf_id] for t in tests: if "FAIL" not in dev[0].request("DPP_CONFIGURATOR_SIGN " + t): raise Exception("Invalid command accepted: " + t) @@ -4994,7 +4994,7 @@ def test_dpp_peer_intro_failures(dev, apdev): def run_dpp_peer_intro_failures(dev, apdev): check_dpp_capab(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) res = hapd.request("DPP_CONFIGURATOR_ADD key=" + dpp_key_p256) @@ -5035,9 +5035,9 @@ def run_dpp_peer_intro_failures(dev, apdev): dev[0].wait_disconnected() dev[0].dump_monitor() - tests = [ "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiIwTlNSNTlxRTc0alFfZTFLVGVPV1lYY1pTWnFUaDdNXzU0aHJPcFRpaFJnIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOltdLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiJiVmFMRGlBT09OQmFjcVFVN1pYamFBVEtEMVhhbDVlUExqOUZFZUl3VkN3IiwieSI6Il95c25JR1hTYjBvNEsyMWg0anZmSkZxMHdVNnlPNWp1VUFPd3FuM0dHVHMifX0.WgzZBOJaisWBRxvtXPbVYPXU7OIZxs6sZD-cPOLmJVTIYZKdMkSOMvP5b6si_j61FIrjhm43tmGq1P6cpoxB_g", - "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiIwTlNSNTlxRTc0alFfZTFLVGVPV1lYY1pTWnFUaDdNXzU0aHJPcFRpaFJnIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7fV0sIm5ldEFjY2Vzc0tleSI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwieCI6IkJhY3BWSDNpNDBrZklNS0RHa1FFRzhCODBCaEk4cEFmTWpLbzM5NlFZT2ciLCJ5IjoiMjBDYjhDNjRsSjFzQzV2NXlKMnBFZXRRempxMjI4YVV2cHMxNmQ0M3EwQSJ9fQ.dG2y8VvZQJ5hfob8E5F2FAeR7Nd700qstYkxDgA2QfARaNMZ0_SfKfoG-yKXsIZNM-TvGBfACgfhagG9Oaw_Xw", - "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiIwTlNSNTlxRTc0alFfZTFLVGVPV1lYY1pTWnFUaDdNXzU0aHJPcFRpaFJnIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiJkc2VmcmJWWlhad0RMWHRpLWlObDBBYkFIOXpqeFFKd0R1SUd5NzNuZGU0IiwieSI6IjZFQnExN3cwYW1fZlh1OUQ4UGxWYk9XZ2I3b19DcTUxWHlmSG8wcHJyeDQifX0.caBvdDUtXrhnS61-juVZ_2FQdprepv0yZjC04G4ERvLUpeX7cgu0Hp-A1aFDogP1PEFGpkaEdcAWRQnSSRiIKQ" ] + tests = ["eyJ0eXAiOiJkcHBDb24iLCJraWQiOiIwTlNSNTlxRTc0alFfZTFLVGVPV1lYY1pTWnFUaDdNXzU0aHJPcFRpaFJnIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOltdLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiJiVmFMRGlBT09OQmFjcVFVN1pYamFBVEtEMVhhbDVlUExqOUZFZUl3VkN3IiwieSI6Il95c25JR1hTYjBvNEsyMWg0anZmSkZxMHdVNnlPNWp1VUFPd3FuM0dHVHMifX0.WgzZBOJaisWBRxvtXPbVYPXU7OIZxs6sZD-cPOLmJVTIYZKdMkSOMvP5b6si_j61FIrjhm43tmGq1P6cpoxB_g", + "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiIwTlNSNTlxRTc0alFfZTFLVGVPV1lYY1pTWnFUaDdNXzU0aHJPcFRpaFJnIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7fV0sIm5ldEFjY2Vzc0tleSI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwieCI6IkJhY3BWSDNpNDBrZklNS0RHa1FFRzhCODBCaEk4cEFmTWpLbzM5NlFZT2ciLCJ5IjoiMjBDYjhDNjRsSjFzQzV2NXlKMnBFZXRRempxMjI4YVV2cHMxNmQ0M3EwQSJ9fQ.dG2y8VvZQJ5hfob8E5F2FAeR7Nd700qstYkxDgA2QfARaNMZ0_SfKfoG-yKXsIZNM-TvGBfACgfhagG9Oaw_Xw", + "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiIwTlNSNTlxRTc0alFfZTFLVGVPV1lYY1pTWnFUaDdNXzU0aHJPcFRpaFJnIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiJkc2VmcmJWWlhad0RMWHRpLWlObDBBYkFIOXpqeFFKd0R1SUd5NzNuZGU0IiwieSI6IjZFQnExN3cwYW1fZlh1OUQ4UGxWYk9XZ2I3b19DcTUxWHlmSG8wcHJyeDQifX0.caBvdDUtXrhnS61-juVZ_2FQdprepv0yZjC04G4ERvLUpeX7cgu0Hp-A1aFDogP1PEFGpkaEdcAWRQnSSRiIKQ"] for t in tests: dev[0].set_network_quoted(id, "dpp_connector", t) dev[0].select_network(id, freq=2412) @@ -5052,22 +5052,22 @@ def test_dpp_peer_intro_local_failures(dev, apdev): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - params = { "ssid": "dpp", - "wpa": "2", - "wpa_key_mgmt": "DPP", - "ieee80211w": "2", - "rsn_pairwise": "CCMP", - "dpp_connector": params1_ap_connector, - "dpp_csign": params1_csign, - "dpp_netaccesskey": params1_ap_netaccesskey } + params = {"ssid": "dpp", + "wpa": "2", + "wpa_key_mgmt": "DPP", + "ieee80211w": "2", + "rsn_pairwise": "CCMP", + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: raise HwsimSkip("DPP not supported") - tests = [ "dpp_derive_pmk", - "dpp_hkdf_expand;dpp_derive_pmk", - "dpp_derive_pmkid" ] + tests = ["dpp_derive_pmk", + "dpp_hkdf_expand;dpp_derive_pmk", + "dpp_derive_pmkid"] for func in tests: with fail_test(dev[0], 1, func): dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", @@ -5082,12 +5082,12 @@ def test_dpp_peer_intro_local_failures(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ (1, "base64_gen_decode;dpp_peer_intro"), - (1, "json_parse;dpp_peer_intro"), - (50, "json_parse;dpp_peer_intro"), - (1, "=dpp_peer_intro"), - (1, "dpp_parse_jwk") ] - for count,func in tests: + tests = [(1, "base64_gen_decode;dpp_peer_intro"), + (1, "json_parse;dpp_peer_intro"), + (50, "json_parse;dpp_peer_intro"), + (1, "=dpp_peer_intro"), + (1, "dpp_parse_jwk")] + for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", @@ -5102,7 +5102,7 @@ def test_dpp_peer_intro_local_failures(dev, apdev): dev[0].dump_monitor() parts = params1_ap_connector.split('.') - for ap_connector in [ '.'.join(parts[0:2]), '.'.join(parts[0:1]) ]: + for ap_connector in ['.'.join(parts[0:2]), '.'.join(parts[0:1])]: hapd.set("dpp_connector", ap_connector) dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", @@ -5158,18 +5158,18 @@ def run_dpp_configurator_id_unknown(dev): def test_dpp_configurator_id_unknown(dev, apdev): """DPP and unknown configurator id""" run_dpp_configurator_id_unknown(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) run_dpp_configurator_id_unknown(hapd) def run_dpp_bootstrap_gen_failures(dev, hostapd): check_dpp_capab(dev) - tests = [ "type=unsupported", - "type=qrcode chan=-1", - "type=qrcode mac=a", - "type=qrcode key=qq", - "type=qrcode key=", - "type=qrcode info=abc\tdef" ] + tests = ["type=unsupported", + "type=qrcode chan=-1", + "type=qrcode mac=a", + "type=qrcode key=qq", + "type=qrcode key=", + "type=qrcode info=abc\tdef"] for t in tests: if "FAIL" not in dev.request("DPP_BOOTSTRAP_GEN " + t): raise Exception("Command accepted unexpectedly") @@ -5207,7 +5207,7 @@ def run_dpp_bootstrap_gen_failures(dev, hostapd): def test_dpp_bootstrap_gen_failures(dev, apdev): """DPP_BOOTSTRAP_GEN/REMOVE/GET_URI/INFO error cases""" run_dpp_bootstrap_gen_failures(dev[0], False) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) run_dpp_bootstrap_gen_failures(hapd, True) def test_dpp_listen_continue(dev, apdev): @@ -5251,12 +5251,12 @@ def run_dpp_network_addition_failure(dev, apdev): dev[0].set("dpp_config_processing", "1") cmd = "DPP_CONFIGURATOR_SIGN conf=sta-dpp configurator=%d" % conf_id - tests = [ (1, "=wpas_dpp_add_network"), - (2, "=wpas_dpp_add_network"), - (3, "=wpas_dpp_add_network"), - (4, "=wpas_dpp_add_network"), - (1, "wpa_config_add_network;wpas_dpp_add_network") ] - for count,func in tests: + tests = [(1, "=wpas_dpp_add_network"), + (2, "=wpas_dpp_add_network"), + (3, "=wpas_dpp_add_network"), + (4, "=wpas_dpp_add_network"), + (1, "wpa_config_add_network;wpas_dpp_add_network")] + for count, func in tests: with alloc_fail(dev[0], count, func): res = dev[0].request(cmd) if "OK" in res: @@ -5267,8 +5267,8 @@ def run_dpp_network_addition_failure(dev, apdev): dev[0].dump_monitor() cmd = "DPP_CONFIGURATOR_SIGN conf=sta-psk pass=%s configurator=%d" % (binascii.hexlify(b"passphrase").decode(), conf_id) - tests = [ (1, "wpa_config_set_quoted;wpas_dpp_add_network") ] - for count,func in tests: + tests = [(1, "wpa_config_set_quoted;wpas_dpp_add_network")] + for count, func in tests: with alloc_fail(dev[0], count, func): res = dev[0].request(cmd) if "OK" in res: @@ -5326,7 +5326,7 @@ def test_dpp_conf_file_update(dev, apdev, params): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", config=config) wpas.set("dpp_config_processing", "1") - run_dpp_qr_code_auth_unicast([ wpas, dev[1] ], apdev, None, + run_dpp_qr_code_auth_unicast([wpas, dev[1]], apdev, None, init_extra="conf=sta-dpp", require_conf_success=True, configurator=True) @@ -5334,8 +5334,8 @@ def test_dpp_conf_file_update(dev, apdev, params): with open(config, "r") as f: res = f.read() - for i in [ "network={", "dpp_connector=", "key_mgmt=DPP", "ieee80211w=2", - "dpp_netaccesskey=", "dpp_csign=" ]: + for i in ["network={", "dpp_connector=", "key_mgmt=DPP", "ieee80211w=2", + "dpp_netaccesskey=", "dpp_csign="]: if i not in res: raise Exception("Configuration file missing '%s'" % i) @@ -5425,7 +5425,7 @@ def test_dpp_enrollee_ap_reject_config(dev, apdev): """DPP and Enrollee AP rejecting Config Object""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "unconfigured"}) check_dpp_capab(hapd) hapd.set("dpp_test", "91") diff --git a/tests/hwsim/test_eap_proto.py b/tests/hwsim/test_eap_proto.py index 6074b79..4ee20ea 100644 --- a/tests/hwsim/test_eap_proto.py +++ b/tests/hwsim/test_eap_proto.py @@ -155,7 +155,7 @@ def start_radius_server(eap_handler): t = threading.Thread(target=run_pyrad_server, args=(srv, t_stop, eap_handler)) t.start() - return { 'srv': srv, 'stop': t_stop, 'thread': t } + return {'srv': srv, 'stop': t_stop, 'thread': t} def stop_radius_server(srv): srv['stop'].set() @@ -794,15 +794,15 @@ def test_eap_proto_sake_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ ( 1, "eap_msg_alloc;eap_sake_build_msg;eap_sake_process_challenge" ), - ( 1, "=eap_sake_process_challenge" ), - ( 1, "eap_sake_compute_mic;eap_sake_process_challenge" ), - ( 1, "eap_sake_build_msg;eap_sake_process_confirm" ), - ( 1, "eap_sake_compute_mic;eap_sake_process_confirm" ), - ( 2, "eap_sake_compute_mic;eap_sake_process_confirm" ), - ( 1, "eap_sake_getKey" ), - ( 1, "eap_sake_get_emsk" ), - ( 1, "eap_sake_get_session_id" ) ] + tests = [(1, "eap_msg_alloc;eap_sake_build_msg;eap_sake_process_challenge"), + (1, "=eap_sake_process_challenge"), + (1, "eap_sake_compute_mic;eap_sake_process_challenge"), + (1, "eap_sake_build_msg;eap_sake_process_confirm"), + (1, "eap_sake_compute_mic;eap_sake_process_confirm"), + (2, "eap_sake_compute_mic;eap_sake_process_confirm"), + (1, "eap_sake_getKey"), + (1, "eap_sake_get_emsk"), + (1, "eap_sake_get_session_id")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -2276,7 +2276,7 @@ def test_eap_proto_eke(dev, apdev): timeout=15) if ev is None: raise Exception("Timeout on EAP start") - if i in [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]: + if i in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]: ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10) if ev is None: @@ -2292,8 +2292,8 @@ def eap_eke_test_fail(dev, phase1=None, success=False): dev.connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", eap="EKE", identity="eke user@domain", password="hello", phase1=phase1, erp="1", wait_connect=False) - ev = dev.wait_event([ "CTRL-EVENT-EAP-FAILURE", - "CTRL-EVENT-EAP-SUCCESS" ], timeout=5) + ev = dev.wait_event(["CTRL-EVENT-EAP-FAILURE", + "CTRL-EVENT-EAP-SUCCESS"], timeout=5) if ev is None: raise Exception("Timeout on EAP failure") if not success and "CTRL-EVENT-EAP-FAILURE" not in ev: @@ -2320,55 +2320,55 @@ def test_eap_proto_eke_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_eke_dh_init", None), - (1, "eap_eke_prf_hmac_sha1", "dhgroup=3 encr=1 prf=1 mac=1"), - (1, "eap_eke_prf_hmac_sha256", "dhgroup=5 encr=1 prf=2 mac=2"), - (1, "eap_eke_prf", None), - (1, "os_get_random;eap_eke_dhcomp", None), - (1, "aes_128_cbc_encrypt;eap_eke_dhcomp", None), - (1, "aes_128_cbc_decrypt;eap_eke_shared_secret", None), - (1, "eap_eke_prf;eap_eke_shared_secret", None), - (1, "eap_eke_prfplus;eap_eke_derive_ke_ki", None), - (1, "eap_eke_prfplus;eap_eke_derive_ka", None), - (1, "eap_eke_prfplus;eap_eke_derive_msk", None), - (1, "os_get_random;eap_eke_prot", None), - (1, "aes_128_cbc_decrypt;eap_eke_decrypt_prot", None), - (1, "eap_eke_derive_key;eap_eke_process_commit", None), - (1, "eap_eke_dh_init;eap_eke_process_commit", None), - (1, "eap_eke_shared_secret;eap_eke_process_commit", None), - (1, "eap_eke_derive_ke_ki;eap_eke_process_commit", None), - (1, "eap_eke_dhcomp;eap_eke_process_commit", None), - (1, "os_get_random;eap_eke_process_commit", None), - (1, "os_get_random;=eap_eke_process_commit", None), - (1, "eap_eke_prot;eap_eke_process_commit", None), - (1, "eap_eke_decrypt_prot;eap_eke_process_confirm", None), - (1, "eap_eke_derive_ka;eap_eke_process_confirm", None), - (1, "eap_eke_auth;eap_eke_process_confirm", None), - (2, "eap_eke_auth;eap_eke_process_confirm", None), - (1, "eap_eke_prot;eap_eke_process_confirm", None), - (1, "eap_eke_derive_msk;eap_eke_process_confirm", None) ] + tests = [(1, "eap_eke_dh_init", None), + (1, "eap_eke_prf_hmac_sha1", "dhgroup=3 encr=1 prf=1 mac=1"), + (1, "eap_eke_prf_hmac_sha256", "dhgroup=5 encr=1 prf=2 mac=2"), + (1, "eap_eke_prf", None), + (1, "os_get_random;eap_eke_dhcomp", None), + (1, "aes_128_cbc_encrypt;eap_eke_dhcomp", None), + (1, "aes_128_cbc_decrypt;eap_eke_shared_secret", None), + (1, "eap_eke_prf;eap_eke_shared_secret", None), + (1, "eap_eke_prfplus;eap_eke_derive_ke_ki", None), + (1, "eap_eke_prfplus;eap_eke_derive_ka", None), + (1, "eap_eke_prfplus;eap_eke_derive_msk", None), + (1, "os_get_random;eap_eke_prot", None), + (1, "aes_128_cbc_decrypt;eap_eke_decrypt_prot", None), + (1, "eap_eke_derive_key;eap_eke_process_commit", None), + (1, "eap_eke_dh_init;eap_eke_process_commit", None), + (1, "eap_eke_shared_secret;eap_eke_process_commit", None), + (1, "eap_eke_derive_ke_ki;eap_eke_process_commit", None), + (1, "eap_eke_dhcomp;eap_eke_process_commit", None), + (1, "os_get_random;eap_eke_process_commit", None), + (1, "os_get_random;=eap_eke_process_commit", None), + (1, "eap_eke_prot;eap_eke_process_commit", None), + (1, "eap_eke_decrypt_prot;eap_eke_process_confirm", None), + (1, "eap_eke_derive_ka;eap_eke_process_confirm", None), + (1, "eap_eke_auth;eap_eke_process_confirm", None), + (2, "eap_eke_auth;eap_eke_process_confirm", None), + (1, "eap_eke_prot;eap_eke_process_confirm", None), + (1, "eap_eke_derive_msk;eap_eke_process_confirm", None)] for count, func, phase1 in tests: with fail_test(dev[0], count, func): eap_eke_test_fail(dev[0], phase1) - tests = [ (1, "=eap_eke_derive_ke_ki", None), - (1, "=eap_eke_derive_ka", None), - (1, "=eap_eke_derive_msk", None), - (1, "eap_eke_build_msg;eap_eke_process_id", None), - (1, "wpabuf_alloc;eap_eke_process_id", None), - (1, "=eap_eke_process_id", None), - (1, "wpabuf_alloc;=eap_eke_process_id", None), - (1, "wpabuf_alloc;eap_eke_process_id", None), - (1, "eap_eke_build_msg;eap_eke_process_commit", None), - (1, "wpabuf_resize;eap_eke_process_commit", None), - (1, "eap_eke_build_msg;eap_eke_process_confirm", None) ] + tests = [(1, "=eap_eke_derive_ke_ki", None), + (1, "=eap_eke_derive_ka", None), + (1, "=eap_eke_derive_msk", None), + (1, "eap_eke_build_msg;eap_eke_process_id", None), + (1, "wpabuf_alloc;eap_eke_process_id", None), + (1, "=eap_eke_process_id", None), + (1, "wpabuf_alloc;=eap_eke_process_id", None), + (1, "wpabuf_alloc;eap_eke_process_id", None), + (1, "eap_eke_build_msg;eap_eke_process_commit", None), + (1, "wpabuf_resize;eap_eke_process_commit", None), + (1, "eap_eke_build_msg;eap_eke_process_confirm", None)] for count, func, phase1 in tests: with alloc_fail(dev[0], count, func): eap_eke_test_fail(dev[0], phase1) - tests = [ (1, "eap_eke_getKey", None), - (1, "eap_eke_get_emsk", None), - (1, "eap_eke_get_session_id", None) ] + tests = [(1, "eap_eke_getKey", None), + (1, "eap_eke_get_emsk", None), + (1, "eap_eke_get_session_id", None)] for count, func, phase1 in tests: with alloc_fail(dev[0], count, func): eap_eke_test_fail(dev[0], phase1, success=True) @@ -2733,11 +2733,11 @@ def test_eap_proto_pax_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ "eap_msg_alloc;eap_pax_alloc_resp;eap_pax_process_std_1", - "eap_msg_alloc;eap_pax_alloc_resp;eap_pax_process_std_3", - "eap_pax_getKey", - "eap_pax_get_emsk", - "eap_pax_get_session_id" ] + tests = ["eap_msg_alloc;eap_pax_alloc_resp;eap_pax_process_std_1", + "eap_msg_alloc;eap_pax_alloc_resp;eap_pax_process_std_3", + "eap_pax_getKey", + "eap_pax_get_emsk", + "eap_pax_get_session_id"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -2748,12 +2748,12 @@ def test_eap_proto_pax_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "os_get_random;eap_pax_process_std_1"), - (1, "eap_pax_initial_key_derivation"), - (1, "eap_pax_mac;eap_pax_process_std_3"), - (2, "eap_pax_mac;eap_pax_process_std_3"), - (1, "eap_pax_kdf;eap_pax_getKey"), - (1, "eap_pax_kdf;eap_pax_get_emsk") ] + tests = [(1, "os_get_random;eap_pax_process_std_1"), + (1, "eap_pax_initial_key_derivation"), + (1, "eap_pax_mac;eap_pax_process_std_3"), + (2, "eap_pax_mac;eap_pax_process_std_3"), + (1, "eap_pax_kdf;eap_pax_getKey"), + (1, "eap_pax_kdf;eap_pax_get_emsk")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -2922,15 +2922,15 @@ def test_eap_proto_psk_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "=eap_psk_process_1"), - (2, "=eap_psk_process_1"), - (1, "eap_msg_alloc;eap_psk_process_1"), - (1, "=eap_psk_process_3"), - (2, "=eap_psk_process_3"), - (1, "eap_msg_alloc;eap_psk_process_3"), - (1, "eap_psk_getKey"), - (1, "eap_psk_get_session_id"), - (1, "eap_psk_get_emsk") ] + tests = [(1, "=eap_psk_process_1"), + (2, "=eap_psk_process_1"), + (1, "eap_msg_alloc;eap_psk_process_1"), + (1, "=eap_psk_process_3"), + (2, "=eap_psk_process_3"), + (1, "eap_msg_alloc;eap_psk_process_3"), + (1, "eap_psk_getKey"), + (1, "eap_psk_get_session_id"), + (1, "eap_psk_get_emsk")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -2946,26 +2946,26 @@ def test_eap_proto_psk_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "os_get_random;eap_psk_process_1"), - (1, "omac1_aes_128;eap_psk_process_3"), - (1, "aes_128_eax_decrypt;eap_psk_process_3"), - (2, "aes_128_eax_decrypt;eap_psk_process_3"), - (3, "aes_128_eax_decrypt;eap_psk_process_3"), - (1, "aes_128_eax_encrypt;eap_psk_process_3"), - (2, "aes_128_eax_encrypt;eap_psk_process_3"), - (3, "aes_128_eax_encrypt;eap_psk_process_3"), - (1, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (2, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (3, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (4, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (5, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (6, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (7, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (8, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (9, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (10, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), - (1, "aes_ctr_encrypt;aes_128_eax_decrypt;eap_psk_process_3"), - (1, "aes_ctr_encrypt;aes_128_eax_encrypt;eap_psk_process_3") ] + tests = [(1, "os_get_random;eap_psk_process_1"), + (1, "omac1_aes_128;eap_psk_process_3"), + (1, "aes_128_eax_decrypt;eap_psk_process_3"), + (2, "aes_128_eax_decrypt;eap_psk_process_3"), + (3, "aes_128_eax_decrypt;eap_psk_process_3"), + (1, "aes_128_eax_encrypt;eap_psk_process_3"), + (2, "aes_128_eax_encrypt;eap_psk_process_3"), + (3, "aes_128_eax_encrypt;eap_psk_process_3"), + (1, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (2, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (3, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (4, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (5, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (6, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (7, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (8, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (9, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (10, "aes_128_encrypt_block;eap_psk_derive_keys;eap_psk_process_3"), + (1, "aes_ctr_encrypt;aes_128_eax_decrypt;eap_psk_process_3"), + (1, "aes_ctr_encrypt;aes_128_eax_encrypt;eap_psk_process_3")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -3707,7 +3707,7 @@ def test_eap_proto_aka(dev, apdev): timeout=15) if ev is None: raise Exception("Timeout on EAP start") - if i in [ 0, 15 ]: + if i in [0, 15]: time.sleep(0.1) else: ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], @@ -4134,7 +4134,7 @@ def test_eap_proto_aka_prime(dev, apdev): timeout=15) if ev is None: raise Exception("Timeout on EAP start") - if i in [ 0 ]: + if i in [0]: time.sleep(0.1) else: ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], @@ -4540,7 +4540,7 @@ def test_eap_proto_sim(dev, apdev): timeout=15) if ev is None: raise Exception("Timeout on EAP start") - if i in [ 0 ]: + if i in [0]: time.sleep(0.1) else: ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], @@ -4635,18 +4635,18 @@ def test_eap_proto_sim_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ (1, "eap_sim_verify_mac;eap_sim_process_challenge"), - (1, "eap_sim_parse_encr;eap_sim_process_challenge"), - (1, "eap_sim_msg_init;eap_sim_response_start"), - (1, "wpabuf_alloc;eap_sim_msg_init;eap_sim_response_start"), - (1, "=eap_sim_learn_ids"), - (2, "=eap_sim_learn_ids"), - (2, "eap_sim_learn_ids"), - (3, "eap_sim_learn_ids"), - (1, "eap_sim_process_start"), - (1, "eap_sim_getKey"), - (1, "eap_sim_get_emsk"), - (1, "eap_sim_get_session_id") ] + tests = [(1, "eap_sim_verify_mac;eap_sim_process_challenge"), + (1, "eap_sim_parse_encr;eap_sim_process_challenge"), + (1, "eap_sim_msg_init;eap_sim_response_start"), + (1, "wpabuf_alloc;eap_sim_msg_init;eap_sim_response_start"), + (1, "=eap_sim_learn_ids"), + (2, "=eap_sim_learn_ids"), + (2, "eap_sim_learn_ids"), + (3, "eap_sim_learn_ids"), + (1, "eap_sim_process_start"), + (1, "eap_sim_getKey"), + (1, "eap_sim_get_emsk"), + (1, "eap_sim_get_session_id")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -4657,7 +4657,7 @@ def test_eap_proto_sim_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ (1, "aes_128_cbc_decrypt;eap_sim_parse_encr") ] + tests = [(1, "aes_128_cbc_decrypt;eap_sim_parse_encr")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -4686,8 +4686,8 @@ def test_eap_proto_sim_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ "eap_sim_msg_add_encr_start;eap_sim_response_notification", - "aes_128_cbc_encrypt;eap_sim_response_notification" ] + tests = ["eap_sim_msg_add_encr_start;eap_sim_response_notification", + "aes_128_cbc_encrypt;eap_sim_response_notification"] for func in tests: with fail_test(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -4704,7 +4704,7 @@ def test_eap_proto_sim_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ "eap_sim_parse_encr;eap_sim_process_notification_reauth" ] + tests = ["eap_sim_parse_encr;eap_sim_process_notification_reauth"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -4740,14 +4740,14 @@ def test_eap_proto_aka_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "=eap_aka_learn_ids"), - (2, "=eap_aka_learn_ids"), - (1, "eap_sim_parse_encr;eap_aka_process_challenge"), - (1, "wpabuf_dup;eap_aka_add_id_msg"), - (1, "wpabuf_resize;eap_aka_add_id_msg"), - (1, "eap_aka_getKey"), - (1, "eap_aka_get_emsk"), - (1, "eap_aka_get_session_id") ] + tests = [(1, "=eap_aka_learn_ids"), + (2, "=eap_aka_learn_ids"), + (1, "eap_sim_parse_encr;eap_aka_process_challenge"), + (1, "wpabuf_dup;eap_aka_add_id_msg"), + (1, "wpabuf_resize;eap_aka_add_id_msg"), + (1, "eap_aka_getKey"), + (1, "eap_aka_get_emsk"), + (1, "eap_aka_get_session_id")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -4775,8 +4775,8 @@ def test_eap_proto_aka_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ "eap_sim_msg_add_encr_start;eap_aka_response_notification", - "aes_128_cbc_encrypt;eap_aka_response_notification" ] + tests = ["eap_sim_msg_add_encr_start;eap_aka_response_notification", + "aes_128_cbc_encrypt;eap_aka_response_notification"] for func in tests: with fail_test(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -4793,7 +4793,7 @@ def test_eap_proto_aka_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ "eap_sim_parse_encr;eap_aka_process_notification_reauth" ] + tests = ["eap_sim_parse_encr;eap_aka_process_notification_reauth"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -4855,8 +4855,8 @@ def test_eap_proto_aka_prime_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() - tests = [ (1, "eap_sim_verify_mac_sha256"), - (1, "=eap_aka_process_challenge") ] + tests = [(1, "eap_sim_verify_mac_sha256"), + (1, "=eap_aka_process_challenge")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -5337,7 +5337,7 @@ def test_eap_proto_ikev2(dev, apdev): timeout=15) if ev is None: raise Exception("Timeout on EAP method start") - if i in [ 41, 46 ]: + if i in [41, 46]: ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10) if ev is None: @@ -5399,40 +5399,40 @@ def test_eap_proto_ikev2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "ikev2_encr_encrypt"), - (1, "ikev2_encr_decrypt"), - (1, "ikev2_derive_auth_data"), - (2, "ikev2_derive_auth_data"), - (1, "=ikev2_decrypt_payload"), - (1, "ikev2_encr_decrypt;ikev2_decrypt_payload"), - (1, "ikev2_encr_encrypt;ikev2_build_encrypted"), - (1, "ikev2_derive_sk_keys"), - (2, "ikev2_derive_sk_keys"), - (3, "ikev2_derive_sk_keys"), - (4, "ikev2_derive_sk_keys"), - (5, "ikev2_derive_sk_keys"), - (6, "ikev2_derive_sk_keys"), - (7, "ikev2_derive_sk_keys"), - (8, "ikev2_derive_sk_keys"), - (1, "eap_ikev2_derive_keymat;eap_ikev2_peer_keymat"), - (1, "eap_msg_alloc;eap_ikev2_build_msg"), - (1, "eap_ikev2_getKey"), - (1, "eap_ikev2_get_emsk"), - (1, "eap_ikev2_get_session_id"), - (1, "=ikev2_derive_keys"), - (2, "=ikev2_derive_keys"), - (1, "wpabuf_alloc;ikev2_process_kei"), - (1, "=ikev2_process_idi"), - (1, "ikev2_derive_auth_data;ikev2_build_auth"), - (1, "wpabuf_alloc;ikev2_build_sa_init"), - (2, "wpabuf_alloc;ikev2_build_sa_init"), - (3, "wpabuf_alloc;ikev2_build_sa_init"), - (4, "wpabuf_alloc;ikev2_build_sa_init"), - (5, "wpabuf_alloc;ikev2_build_sa_init"), - (6, "wpabuf_alloc;ikev2_build_sa_init"), - (1, "wpabuf_alloc;ikev2_build_sa_auth"), - (2, "wpabuf_alloc;ikev2_build_sa_auth"), - (1, "ikev2_build_auth;ikev2_build_sa_auth") ] + tests = [(1, "ikev2_encr_encrypt"), + (1, "ikev2_encr_decrypt"), + (1, "ikev2_derive_auth_data"), + (2, "ikev2_derive_auth_data"), + (1, "=ikev2_decrypt_payload"), + (1, "ikev2_encr_decrypt;ikev2_decrypt_payload"), + (1, "ikev2_encr_encrypt;ikev2_build_encrypted"), + (1, "ikev2_derive_sk_keys"), + (2, "ikev2_derive_sk_keys"), + (3, "ikev2_derive_sk_keys"), + (4, "ikev2_derive_sk_keys"), + (5, "ikev2_derive_sk_keys"), + (6, "ikev2_derive_sk_keys"), + (7, "ikev2_derive_sk_keys"), + (8, "ikev2_derive_sk_keys"), + (1, "eap_ikev2_derive_keymat;eap_ikev2_peer_keymat"), + (1, "eap_msg_alloc;eap_ikev2_build_msg"), + (1, "eap_ikev2_getKey"), + (1, "eap_ikev2_get_emsk"), + (1, "eap_ikev2_get_session_id"), + (1, "=ikev2_derive_keys"), + (2, "=ikev2_derive_keys"), + (1, "wpabuf_alloc;ikev2_process_kei"), + (1, "=ikev2_process_idi"), + (1, "ikev2_derive_auth_data;ikev2_build_auth"), + (1, "wpabuf_alloc;ikev2_build_sa_init"), + (2, "wpabuf_alloc;ikev2_build_sa_init"), + (3, "wpabuf_alloc;ikev2_build_sa_init"), + (4, "wpabuf_alloc;ikev2_build_sa_init"), + (5, "wpabuf_alloc;ikev2_build_sa_init"), + (6, "wpabuf_alloc;ikev2_build_sa_init"), + (1, "wpabuf_alloc;ikev2_build_sa_auth"), + (2, "wpabuf_alloc;ikev2_build_sa_auth"), + (1, "ikev2_build_auth;ikev2_build_sa_auth")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -5454,9 +5454,9 @@ def test_eap_proto_ikev2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "wpabuf_alloc;ikev2_build_notify"), - (2, "wpabuf_alloc;ikev2_build_notify"), - (1, "ikev2_build_encrypted;ikev2_build_notify") ] + tests = [(1, "wpabuf_alloc;ikev2_build_notify"), + (2, "wpabuf_alloc;ikev2_build_notify"), + (1, "ikev2_build_encrypted;ikev2_build_notify")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -5479,18 +5479,18 @@ def test_eap_proto_ikev2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "ikev2_integ_hash"), - (1, "ikev2_integ_hash;ikev2_decrypt_payload"), - (1, "os_get_random;ikev2_build_encrypted"), - (1, "ikev2_prf_plus;ikev2_derive_sk_keys"), - (1, "eap_ikev2_derive_keymat;eap_ikev2_peer_keymat"), - (1, "os_get_random;ikev2_build_sa_init"), - (2, "os_get_random;ikev2_build_sa_init"), - (1, "ikev2_integ_hash;eap_ikev2_validate_icv"), - (1, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_keys"), - (1, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_auth_data"), - (2, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_auth_data"), - (3, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_auth_data") ] + tests = [(1, "ikev2_integ_hash"), + (1, "ikev2_integ_hash;ikev2_decrypt_payload"), + (1, "os_get_random;ikev2_build_encrypted"), + (1, "ikev2_prf_plus;ikev2_derive_sk_keys"), + (1, "eap_ikev2_derive_keymat;eap_ikev2_peer_keymat"), + (1, "os_get_random;ikev2_build_sa_init"), + (2, "os_get_random;ikev2_build_sa_init"), + (1, "ikev2_integ_hash;eap_ikev2_validate_icv"), + (1, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_keys"), + (1, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_auth_data"), + (2, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_auth_data"), + (3, "hmac_sha1_vector;?ikev2_prf_hash;ikev2_derive_auth_data")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -5512,15 +5512,15 @@ def test_eap_proto_ikev2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - params = { "ssid": "eap-test2", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", - "fragment_size": "50" } + params = {"ssid": "eap-test2", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", + "fragment_size": "50"} hapd2 = hostapd.add_ap(apdev[1], params) dev[0].scan_for_bss(hapd2.own_addr(), freq=2412) - tests = [ (1, "eap_ikev2_build_frag_ack"), - (1, "wpabuf_alloc;eap_ikev2_process_fragment") ] + tests = [(1, "eap_ikev2_build_frag_ack"), + (1, "wpabuf_alloc;eap_ikev2_process_fragment")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test2", key_mgmt="WPA-EAP", scan_freq="2412", @@ -5851,14 +5851,14 @@ def test_eap_proto_mschapv2(dev, apdev): if ev is None: raise Exception("Timeout on EAP start") - if i in [ 8, 11, 12 ]: + if i in [8, 11, 12]: ev = dev[0].wait_event(["CTRL-REQ-NEW_PASSWORD"], timeout=10) if ev is None: raise Exception("Timeout on new password request") id = ev.split(':')[0].split('-')[-1] dev[0].request("CTRL-RSP-NEW_PASSWORD-" + id + ":new-pw") - if i in [ 11, 12 ]: + if i in [11, 12]: ev = dev[0].wait_event(["CTRL-EVENT-PASSWORD-CHANGED"], timeout=10) if ev is None: @@ -5873,7 +5873,7 @@ def test_eap_proto_mschapv2(dev, apdev): if ev is None: raise Exception("Timeout on EAP failure") - if i in [ 13 ]: + if i in [13]: ev = dev[0].wait_event(["CTRL-REQ-IDENTITY"], timeout=10) if ev is None: @@ -5895,7 +5895,7 @@ def test_eap_proto_mschapv2(dev, apdev): if ev is None: raise Exception("Timeout on EAP failure") - if i in [ 4, 5, 6, 7, 14 ]: + if i in [4, 5, 6, 7, 14]: ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10) if ev is None: @@ -6061,11 +6061,11 @@ def test_eap_proto_mschapv2_errors(dev, apdev): hapd = start_ap(apdev[0]) dev[0].scan_for_bss(hapd.own_addr(), freq=2412) - tests = [ "os_get_random;eap_mschapv2_change_password", - "generate_nt_response;eap_mschapv2_change_password", - "get_master_key;eap_mschapv2_change_password", - "nt_password_hash;eap_mschapv2_change_password", - "old_nt_password_hash_encrypted_with_new_nt_password_hash" ] + tests = ["os_get_random;eap_mschapv2_change_password", + "generate_nt_response;eap_mschapv2_change_password", + "get_master_key;eap_mschapv2_change_password", + "nt_password_hash;eap_mschapv2_change_password", + "old_nt_password_hash_encrypted_with_new_nt_password_hash"] for func in tests: with fail_test(dev[0], 1, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -6081,9 +6081,9 @@ def test_eap_proto_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected(timeout=1) - tests = [ "encrypt_pw_block_with_password_hash;eap_mschapv2_change_password", - "nt_password_hash;eap_mschapv2_change_password", - "nt_password_hash;eap_mschapv2_success" ] + tests = ["encrypt_pw_block_with_password_hash;eap_mschapv2_change_password", + "nt_password_hash;eap_mschapv2_change_password", + "nt_password_hash;eap_mschapv2_success"] for func in tests: with fail_test(dev[0], 1, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -6100,7 +6100,7 @@ def test_eap_proto_mschapv2_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected(timeout=1) - tests = [ "eap_msg_alloc;eap_mschapv2_change_password" ] + tests = ["eap_msg_alloc;eap_mschapv2_change_password"] for func in tests: with alloc_fail(dev[0], 1, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -6404,7 +6404,7 @@ def test_eap_proto_pwd_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - funcs = [ "eap_pwd_getkey", "eap_pwd_get_emsk" ] + funcs = ["eap_pwd_getkey", "eap_pwd_get_emsk"] for func in funcs: with alloc_fail(dev[0], 1, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -6530,10 +6530,10 @@ def test_eap_proto_pwd_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - params = { "ssid": "eap-test2", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", - "rsn_pairwise": "CCMP", "ieee8021x": "1", - "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", - "pwd_group": "19", "fragment_size": "40" } + params = {"ssid": "eap-test2", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", + "rsn_pairwise": "CCMP", "ieee8021x": "1", + "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", + "pwd_group": "19", "fragment_size": "40"} hapd2 = hostapd.add_ap(apdev[1], params) dev[0].scan_for_bss(hapd2.own_addr(), freq=2412) @@ -6736,16 +6736,16 @@ def test_eap_proto_fast_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "wpabuf_alloc;eap_fast_tlv_eap_payload"), - (1, "eap_fast_derive_key;eap_fast_derive_key_auth"), - (1, "eap_msg_alloc;eap_peer_tls_phase2_nak"), - (1, "wpabuf_alloc;eap_fast_tlv_result"), - (1, "wpabuf_alloc;eap_fast_tlv_pac_ack"), - (1, "=eap_peer_tls_derive_session_id;eap_fast_process_crypto_binding"), - (1, "eap_peer_tls_decrypt;eap_fast_decrypt"), - (1, "eap_fast_getKey"), - (1, "eap_fast_get_session_id"), - (1, "eap_fast_get_emsk") ] + tests = [(1, "wpabuf_alloc;eap_fast_tlv_eap_payload"), + (1, "eap_fast_derive_key;eap_fast_derive_key_auth"), + (1, "eap_msg_alloc;eap_peer_tls_phase2_nak"), + (1, "wpabuf_alloc;eap_fast_tlv_result"), + (1, "wpabuf_alloc;eap_fast_tlv_pac_ack"), + (1, "=eap_peer_tls_derive_session_id;eap_fast_process_crypto_binding"), + (1, "eap_peer_tls_decrypt;eap_fast_decrypt"), + (1, "eap_fast_getKey"), + (1, "eap_fast_get_session_id"), + (1, "eap_fast_get_emsk")] for count, func in tests: dev[0].request("SET blob fast_pac_auth_errors ") with alloc_fail(dev[0], count, func): @@ -6765,14 +6765,14 @@ def test_eap_proto_fast_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_fast_derive_key;eap_fast_derive_key_provisioning"), - (1, "eap_mschapv2_getKey;eap_fast_get_phase2_key"), - (1, "=eap_fast_use_pac_opaque"), - (1, "eap_fast_copy_buf"), - (1, "=eap_fast_add_pac"), - (1, "=eap_fast_init_pac_data"), - (1, "=eap_fast_write_pac"), - (2, "=eap_fast_write_pac") ] + tests = [(1, "eap_fast_derive_key;eap_fast_derive_key_provisioning"), + (1, "eap_mschapv2_getKey;eap_fast_get_phase2_key"), + (1, "=eap_fast_use_pac_opaque"), + (1, "eap_fast_copy_buf"), + (1, "=eap_fast_add_pac"), + (1, "=eap_fast_init_pac_data"), + (1, "=eap_fast_write_pac"), + (2, "=eap_fast_write_pac")] for count, func in tests: dev[0].request("SET blob fast_pac_errors ") with alloc_fail(dev[0], count, func): @@ -6792,9 +6792,9 @@ def test_eap_proto_fast_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_fast_get_cmk;eap_fast_process_crypto_binding"), - (1, "eap_fast_derive_eap_msk;eap_fast_process_crypto_binding"), - (1, "eap_fast_derive_eap_emsk;eap_fast_process_crypto_binding") ] + tests = [(1, "eap_fast_get_cmk;eap_fast_process_crypto_binding"), + (1, "eap_fast_derive_eap_msk;eap_fast_process_crypto_binding"), + (1, "eap_fast_derive_eap_emsk;eap_fast_process_crypto_binding")] for count, func in tests: dev[0].request("SET blob fast_pac_auth_errors ") with fail_test(dev[0], count, func): @@ -6851,19 +6851,19 @@ def test_eap_proto_fast_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ "FOOBAR\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nFOOBAR\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nSTART\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Type=12345\nEND\n" - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Key=12\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Key=1\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Key=1q\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Opaque=1\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nA-ID=1\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nI-ID=1\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nA-ID-Info=1\nEND\n" ] + tests = ["FOOBAR\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nFOOBAR\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nSTART\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Type=12345\nEND\n" + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Key=12\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Key=1\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Key=1q\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nPAC-Opaque=1\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nA-ID=1\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nI-ID=1\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nA-ID-Info=1\nEND\n"] for pac in tests: blob = binascii.hexlify(pac.encode()).decode() dev[0].request("SET blob fast_pac_errors " + blob) @@ -6881,8 +6881,8 @@ def test_eap_proto_fast_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nEND\n", - "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nEND\nSTART\nEND\nSTART\nEND\n" ] + tests = ["wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nEND\n", + "wpa_supplicant EAP-FAST PAC file - version 1\nSTART\nEND\nSTART\nEND\nSTART\nEND\n"] for pac in tests: blob = binascii.hexlify(pac.encode()).decode() dev[0].request("SET blob fast_pac_errors " + blob) @@ -6919,17 +6919,17 @@ def test_eap_proto_peap_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_mschapv2_getKey;eap_peap_get_isk;eap_peap_derive_cmk"), - (1, "eap_msg_alloc;eap_tlv_build_result"), - (1, "eap_mschapv2_init;eap_peap_phase2_request"), - (1, "eap_peer_tls_decrypt;eap_peap_decrypt"), - (1, "wpabuf_alloc;=eap_peap_decrypt"), - (1, "eap_peer_tls_encrypt;eap_peap_decrypt"), - (1, "eap_peer_tls_process_helper;eap_peap_process"), - (1, "eap_peer_tls_derive_key;eap_peap_process"), - (1, "eap_peer_tls_derive_session_id;eap_peap_process"), - (1, "eap_peap_getKey"), - (1, "eap_peap_get_session_id") ] + tests = [(1, "eap_mschapv2_getKey;eap_peap_get_isk;eap_peap_derive_cmk"), + (1, "eap_msg_alloc;eap_tlv_build_result"), + (1, "eap_mschapv2_init;eap_peap_phase2_request"), + (1, "eap_peer_tls_decrypt;eap_peap_decrypt"), + (1, "wpabuf_alloc;=eap_peap_decrypt"), + (1, "eap_peer_tls_encrypt;eap_peap_decrypt"), + (1, "eap_peer_tls_process_helper;eap_peap_process"), + (1, "eap_peer_tls_derive_key;eap_peap_process"), + (1, "eap_peer_tls_derive_session_id;eap_peap_process"), + (1, "eap_peap_getKey"), + (1, "eap_peap_get_session_id")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -6946,9 +6946,9 @@ def test_eap_proto_peap_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "peap_prfplus;eap_peap_derive_cmk"), - (1, "eap_tlv_add_cryptobinding;eap_tlv_build_result"), - (1, "peap_prfplus;eap_peap_getKey") ] + tests = [(1, "peap_prfplus;eap_peap_derive_cmk"), + (1, "eap_tlv_add_cryptobinding;eap_tlv_build_result"), + (1, "peap_prfplus;eap_peap_getKey")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -6999,56 +6999,56 @@ def test_eap_proto_ttls_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "eap_peer_tls_derive_key;eap_ttls_v0_derive_key", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_peer_tls_derive_session_id;eap_ttls_v0_derive_key", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "wpabuf_alloc;eap_ttls_phase2_request_mschapv2", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_peer_tls_derive_key;eap_ttls_phase2_request_mschapv2", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_peer_tls_encrypt;eap_ttls_encrypt_response;eap_ttls_implicit_identity_request", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_peer_tls_decrypt;eap_ttls_decrypt", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_ttls_getKey", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_ttls_get_session_id", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_ttls_get_emsk", - "mschapv2 user@domain", "auth=MSCHAPV2"), - (1, "wpabuf_alloc;eap_ttls_phase2_request_mschap", - "mschap user", "auth=MSCHAP"), - (1, "eap_peer_tls_derive_key;eap_ttls_phase2_request_mschap", - "mschap user", "auth=MSCHAP"), - (1, "wpabuf_alloc;eap_ttls_phase2_request_chap", - "chap user", "auth=CHAP"), - (1, "eap_peer_tls_derive_key;eap_ttls_phase2_request_chap", - "chap user", "auth=CHAP"), - (1, "wpabuf_alloc;eap_ttls_phase2_request_pap", - "pap user", "auth=PAP"), - (1, "wpabuf_alloc;eap_ttls_avp_encapsulate", - "user", "autheap=MSCHAPV2"), - (1, "eap_mschapv2_init;eap_ttls_phase2_request_eap_method", - "user", "autheap=MSCHAPV2"), - (1, "eap_sm_buildIdentity;eap_ttls_phase2_request_eap", - "user", "autheap=MSCHAPV2"), - (1, "eap_ttls_avp_encapsulate;eap_ttls_phase2_request_eap", - "user", "autheap=MSCHAPV2"), - (1, "eap_ttls_parse_attr_eap", - "user", "autheap=MSCHAPV2"), - (1, "eap_peer_tls_encrypt;eap_ttls_encrypt_response;eap_ttls_process_decrypted", - "user", "autheap=MSCHAPV2"), - (1, "eap_ttls_fake_identity_request", - "user", "autheap=MSCHAPV2"), - (1, "eap_msg_alloc;eap_tls_process_output", - "user", "autheap=MSCHAPV2"), - (1, "eap_msg_alloc;eap_peer_tls_build_ack", - "user", "autheap=MSCHAPV2"), - (1, "tls_connection_decrypt;eap_peer_tls_decrypt", - "user", "autheap=MSCHAPV2"), - (1, "eap_peer_tls_phase2_nak;eap_ttls_phase2_request_eap_method", - "cert user", "autheap=MSCHAPV2") ] + tests = [(1, "eap_peer_tls_derive_key;eap_ttls_v0_derive_key", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_peer_tls_derive_session_id;eap_ttls_v0_derive_key", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "wpabuf_alloc;eap_ttls_phase2_request_mschapv2", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_peer_tls_derive_key;eap_ttls_phase2_request_mschapv2", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_peer_tls_encrypt;eap_ttls_encrypt_response;eap_ttls_implicit_identity_request", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_peer_tls_decrypt;eap_ttls_decrypt", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_ttls_getKey", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_ttls_get_session_id", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_ttls_get_emsk", + "mschapv2 user@domain", "auth=MSCHAPV2"), + (1, "wpabuf_alloc;eap_ttls_phase2_request_mschap", + "mschap user", "auth=MSCHAP"), + (1, "eap_peer_tls_derive_key;eap_ttls_phase2_request_mschap", + "mschap user", "auth=MSCHAP"), + (1, "wpabuf_alloc;eap_ttls_phase2_request_chap", + "chap user", "auth=CHAP"), + (1, "eap_peer_tls_derive_key;eap_ttls_phase2_request_chap", + "chap user", "auth=CHAP"), + (1, "wpabuf_alloc;eap_ttls_phase2_request_pap", + "pap user", "auth=PAP"), + (1, "wpabuf_alloc;eap_ttls_avp_encapsulate", + "user", "autheap=MSCHAPV2"), + (1, "eap_mschapv2_init;eap_ttls_phase2_request_eap_method", + "user", "autheap=MSCHAPV2"), + (1, "eap_sm_buildIdentity;eap_ttls_phase2_request_eap", + "user", "autheap=MSCHAPV2"), + (1, "eap_ttls_avp_encapsulate;eap_ttls_phase2_request_eap", + "user", "autheap=MSCHAPV2"), + (1, "eap_ttls_parse_attr_eap", + "user", "autheap=MSCHAPV2"), + (1, "eap_peer_tls_encrypt;eap_ttls_encrypt_response;eap_ttls_process_decrypted", + "user", "autheap=MSCHAPV2"), + (1, "eap_ttls_fake_identity_request", + "user", "autheap=MSCHAPV2"), + (1, "eap_msg_alloc;eap_tls_process_output", + "user", "autheap=MSCHAPV2"), + (1, "eap_msg_alloc;eap_peer_tls_build_ack", + "user", "autheap=MSCHAPV2"), + (1, "tls_connection_decrypt;eap_peer_tls_decrypt", + "user", "autheap=MSCHAPV2"), + (1, "eap_peer_tls_phase2_nak;eap_ttls_phase2_request_eap_method", + "cert user", "autheap=MSCHAPV2")] for count, func, identity, phase2 in tests: with alloc_fail(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -7065,8 +7065,8 @@ def test_eap_proto_ttls_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "os_get_random;eap_ttls_phase2_request_mschapv2"), - (1, "mschapv2_derive_response;eap_ttls_phase2_request_mschapv2") ] + tests = [(1, "os_get_random;eap_ttls_phase2_request_mschapv2"), + (1, "mschapv2_derive_response;eap_ttls_phase2_request_mschapv2")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -7083,7 +7083,7 @@ def test_eap_proto_ttls_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - tests = [ (1, "nt_challenge_response;eap_ttls_phase2_request_mschap") ] + tests = [(1, "nt_challenge_response;eap_ttls_phase2_request_mschap")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", @@ -7187,14 +7187,14 @@ def test_eap_proto_expanded(dev, apdev): ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5) if ev is None: raise Exception("Timeout on EAP start") - if i in [ 1 ]: + if i in [1]: ev = dev[0].wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=5) if ev is None: raise Exception("Timeout on EAP method start") ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=5) if ev is None: raise Exception("Timeout on EAP failure") - elif i in [ 2, 3 ]: + elif i in [2, 3]: ev = dev[0].wait_event(["CTRL-EVENT-EAP-PROPOSED-METHOD"], timeout=5) if ev is None: @@ -8322,136 +8322,136 @@ def test_eap_fast_proto_phase2(dev, apdev): hapd = start_ap(apdev[0]) dev[0].scan_for_bss(hapd.own_addr(), freq=2412) - tests = [ ("Too short Phase 2 TLV frame (len=3)", - "ABC", - False), - ("EAP-FAST: TLV overflow", - struct.pack(">HHB", 0, 2, 0xff), - False), - ("EAP-FAST: Unknown TLV (optional and mandatory)", - struct.pack(">HHB", 0, 1, 0xff) + - struct.pack(">HHB", EAP_TLV_TYPE_MANDATORY, 1, 0xff), - True), - ("EAP-FAST: More than one EAP-Payload TLV in the message", - struct.pack(">HHBHHB", - EAP_TLV_EAP_PAYLOAD_TLV, 1, 0xff, - EAP_TLV_EAP_PAYLOAD_TLV, 1, 0xff), - True), - ("EAP-FAST: Unknown Result 255 and More than one Result TLV in the message", - struct.pack(">HHHHHH", - EAP_TLV_RESULT_TLV, 2, 0xff, - EAP_TLV_RESULT_TLV, 2, 0xff), - True), - ("EAP-FAST: Too short Result TLV", - struct.pack(">HHB", EAP_TLV_RESULT_TLV, 1, 0xff), - True), - ("EAP-FAST: Unknown Intermediate Result 255 and More than one Intermediate-Result TLV in the message", - struct.pack(">HHHHHH", - EAP_TLV_INTERMEDIATE_RESULT_TLV, 2, 0xff, - EAP_TLV_INTERMEDIATE_RESULT_TLV, 2, 0xff), - True), - ("EAP-FAST: Too short Intermediate-Result TLV", - struct.pack(">HHB", EAP_TLV_INTERMEDIATE_RESULT_TLV, 1, 0xff), - True), - ("EAP-FAST: More than one Crypto-Binding TLV in the message", - struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A' + - struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A', - True), - ("EAP-FAST: Too short Crypto-Binding TLV", - struct.pack(">HHB", EAP_TLV_CRYPTO_BINDING_TLV, 1, 0xff), - True), - ("EAP-FAST: More than one Request-Action TLV in the message", - struct.pack(">HHBBHHBB", - EAP_TLV_REQUEST_ACTION_TLV, 2, 0xff, 0xff, - EAP_TLV_REQUEST_ACTION_TLV, 2, 0xff, 0xff), - True), - ("EAP-FAST: Too short Request-Action TLV", - struct.pack(">HHB", EAP_TLV_REQUEST_ACTION_TLV, 1, 0xff), - True), - ("EAP-FAST: More than one PAC TLV in the message", - struct.pack(">HHBHHB", - EAP_TLV_PAC_TLV, 1, 0xff, - EAP_TLV_PAC_TLV, 1, 0xff), - True), - ("EAP-FAST: Too short EAP Payload TLV (Len=3)", - struct.pack(">HH3B", - EAP_TLV_EAP_PAYLOAD_TLV, 3, 0, 0, 0), - False), - ("EAP-FAST: Too short Phase 2 request (Len=0)", - struct.pack(">HHBBH", - EAP_TLV_EAP_PAYLOAD_TLV, 4, - EAP_CODE_REQUEST, 0, 0), - False), - ("EAP-FAST: EAP packet overflow in EAP Payload TLV", - struct.pack(">HHBBH", - EAP_TLV_EAP_PAYLOAD_TLV, 4, - EAP_CODE_REQUEST, 0, 4 + 1), - False), - ("EAP-FAST: Unexpected code=0 in Phase 2 EAP header", - struct.pack(">HHBBH", - EAP_TLV_EAP_PAYLOAD_TLV, 4, - 0, 0, 0), - False), - ("EAP-FAST: PAC TLV without Result TLV acknowledging success", - struct.pack(">HHB", EAP_TLV_PAC_TLV, 1, 0xff), - True), - ("EAP-FAST: PAC TLV does not include all the required fields", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHB", EAP_TLV_PAC_TLV, 1, 0xff), - True), - ("EAP-FAST: Invalid PAC-Key length 0, Ignored unknown PAC type 0, and PAC TLV overrun (type=0 len=2 left=1)", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHHHHHHHB", EAP_TLV_PAC_TLV, 4 + 4 + 5, - PAC_TYPE_PAC_KEY, 0, 0, 0, 0, 2, 0), - True), - ("EAP-FAST: PAC-Info does not include all the required fields", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 4 + 32, - PAC_TYPE_PAC_OPAQUE, 0, - PAC_TYPE_PAC_INFO, 0, - PAC_TYPE_PAC_KEY, 32) + 32*b'A', - True), - ("EAP-FAST: Invalid CRED_LIFETIME length, Ignored unknown PAC-Info type 0, and Invalid PAC-Type length 1", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHHHHHHHHHHHBHH", EAP_TLV_PAC_TLV, 4 + 4 + 13 + 4 + 32, - PAC_TYPE_PAC_OPAQUE, 0, - PAC_TYPE_PAC_INFO, 13, PAC_TYPE_CRED_LIFETIME, 0, - 0, 0, PAC_TYPE_PAC_TYPE, 1, 0, - PAC_TYPE_PAC_KEY, 32) + 32*b'A', - True), - ("EAP-FAST: Unsupported PAC-Type 0", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHHHHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 6 + 4 + 32, - PAC_TYPE_PAC_OPAQUE, 0, - PAC_TYPE_PAC_INFO, 6, PAC_TYPE_PAC_TYPE, 2, 0, - PAC_TYPE_PAC_KEY, 32) + 32*b'A', - True), - ("EAP-FAST: PAC-Info overrun (type=0 len=2 left=1)", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHHHHHHHBHH", EAP_TLV_PAC_TLV, 4 + 4 + 5 + 4 + 32, - PAC_TYPE_PAC_OPAQUE, 0, - PAC_TYPE_PAC_INFO, 5, 0, 2, 1, - PAC_TYPE_PAC_KEY, 32) + 32*b'A', - True), - ("EAP-FAST: Valid PAC", - struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, - EAP_TLV_RESULT_SUCCESS) + - struct.pack(">HHHHHHHHBHHBHH", EAP_TLV_PAC_TLV, - 4 + 4 + 10 + 4 + 32, - PAC_TYPE_PAC_OPAQUE, 0, - PAC_TYPE_PAC_INFO, 10, PAC_TYPE_A_ID, 1, 0x41, - PAC_TYPE_A_ID_INFO, 1, 0x42, - PAC_TYPE_PAC_KEY, 32) + 32*b'A', - True), - ("EAP-FAST: Invalid version/subtype in Crypto-Binding TLV", - struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A', - True) ] + tests = [("Too short Phase 2 TLV frame (len=3)", + "ABC", + False), + ("EAP-FAST: TLV overflow", + struct.pack(">HHB", 0, 2, 0xff), + False), + ("EAP-FAST: Unknown TLV (optional and mandatory)", + struct.pack(">HHB", 0, 1, 0xff) + + struct.pack(">HHB", EAP_TLV_TYPE_MANDATORY, 1, 0xff), + True), + ("EAP-FAST: More than one EAP-Payload TLV in the message", + struct.pack(">HHBHHB", + EAP_TLV_EAP_PAYLOAD_TLV, 1, 0xff, + EAP_TLV_EAP_PAYLOAD_TLV, 1, 0xff), + True), + ("EAP-FAST: Unknown Result 255 and More than one Result TLV in the message", + struct.pack(">HHHHHH", + EAP_TLV_RESULT_TLV, 2, 0xff, + EAP_TLV_RESULT_TLV, 2, 0xff), + True), + ("EAP-FAST: Too short Result TLV", + struct.pack(">HHB", EAP_TLV_RESULT_TLV, 1, 0xff), + True), + ("EAP-FAST: Unknown Intermediate Result 255 and More than one Intermediate-Result TLV in the message", + struct.pack(">HHHHHH", + EAP_TLV_INTERMEDIATE_RESULT_TLV, 2, 0xff, + EAP_TLV_INTERMEDIATE_RESULT_TLV, 2, 0xff), + True), + ("EAP-FAST: Too short Intermediate-Result TLV", + struct.pack(">HHB", EAP_TLV_INTERMEDIATE_RESULT_TLV, 1, 0xff), + True), + ("EAP-FAST: More than one Crypto-Binding TLV in the message", + struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A' + + struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A', + True), + ("EAP-FAST: Too short Crypto-Binding TLV", + struct.pack(">HHB", EAP_TLV_CRYPTO_BINDING_TLV, 1, 0xff), + True), + ("EAP-FAST: More than one Request-Action TLV in the message", + struct.pack(">HHBBHHBB", + EAP_TLV_REQUEST_ACTION_TLV, 2, 0xff, 0xff, + EAP_TLV_REQUEST_ACTION_TLV, 2, 0xff, 0xff), + True), + ("EAP-FAST: Too short Request-Action TLV", + struct.pack(">HHB", EAP_TLV_REQUEST_ACTION_TLV, 1, 0xff), + True), + ("EAP-FAST: More than one PAC TLV in the message", + struct.pack(">HHBHHB", + EAP_TLV_PAC_TLV, 1, 0xff, + EAP_TLV_PAC_TLV, 1, 0xff), + True), + ("EAP-FAST: Too short EAP Payload TLV (Len=3)", + struct.pack(">HH3B", + EAP_TLV_EAP_PAYLOAD_TLV, 3, 0, 0, 0), + False), + ("EAP-FAST: Too short Phase 2 request (Len=0)", + struct.pack(">HHBBH", + EAP_TLV_EAP_PAYLOAD_TLV, 4, + EAP_CODE_REQUEST, 0, 0), + False), + ("EAP-FAST: EAP packet overflow in EAP Payload TLV", + struct.pack(">HHBBH", + EAP_TLV_EAP_PAYLOAD_TLV, 4, + EAP_CODE_REQUEST, 0, 4 + 1), + False), + ("EAP-FAST: Unexpected code=0 in Phase 2 EAP header", + struct.pack(">HHBBH", + EAP_TLV_EAP_PAYLOAD_TLV, 4, + 0, 0, 0), + False), + ("EAP-FAST: PAC TLV without Result TLV acknowledging success", + struct.pack(">HHB", EAP_TLV_PAC_TLV, 1, 0xff), + True), + ("EAP-FAST: PAC TLV does not include all the required fields", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHB", EAP_TLV_PAC_TLV, 1, 0xff), + True), + ("EAP-FAST: Invalid PAC-Key length 0, Ignored unknown PAC type 0, and PAC TLV overrun (type=0 len=2 left=1)", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHHHHHHHB", EAP_TLV_PAC_TLV, 4 + 4 + 5, + PAC_TYPE_PAC_KEY, 0, 0, 0, 0, 2, 0), + True), + ("EAP-FAST: PAC-Info does not include all the required fields", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 4 + 32, + PAC_TYPE_PAC_OPAQUE, 0, + PAC_TYPE_PAC_INFO, 0, + PAC_TYPE_PAC_KEY, 32) + 32*b'A', + True), + ("EAP-FAST: Invalid CRED_LIFETIME length, Ignored unknown PAC-Info type 0, and Invalid PAC-Type length 1", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHHHHHHHHHHHBHH", EAP_TLV_PAC_TLV, 4 + 4 + 13 + 4 + 32, + PAC_TYPE_PAC_OPAQUE, 0, + PAC_TYPE_PAC_INFO, 13, PAC_TYPE_CRED_LIFETIME, 0, + 0, 0, PAC_TYPE_PAC_TYPE, 1, 0, + PAC_TYPE_PAC_KEY, 32) + 32*b'A', + True), + ("EAP-FAST: Unsupported PAC-Type 0", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHHHHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 6 + 4 + 32, + PAC_TYPE_PAC_OPAQUE, 0, + PAC_TYPE_PAC_INFO, 6, PAC_TYPE_PAC_TYPE, 2, 0, + PAC_TYPE_PAC_KEY, 32) + 32*b'A', + True), + ("EAP-FAST: PAC-Info overrun (type=0 len=2 left=1)", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHHHHHHHBHH", EAP_TLV_PAC_TLV, 4 + 4 + 5 + 4 + 32, + PAC_TYPE_PAC_OPAQUE, 0, + PAC_TYPE_PAC_INFO, 5, 0, 2, 1, + PAC_TYPE_PAC_KEY, 32) + 32*b'A', + True), + ("EAP-FAST: Valid PAC", + struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2, + EAP_TLV_RESULT_SUCCESS) + + struct.pack(">HHHHHHHHBHHBHH", EAP_TLV_PAC_TLV, + 4 + 4 + 10 + 4 + 32, + PAC_TYPE_PAC_OPAQUE, 0, + PAC_TYPE_PAC_INFO, 10, PAC_TYPE_A_ID, 1, 0x41, + PAC_TYPE_A_ID_INFO, 1, 0x42, + PAC_TYPE_PAC_KEY, 32) + 32*b'A', + True), + ("EAP-FAST: Invalid version/subtype in Crypto-Binding TLV", + struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A', + True)] for title, payload, failure in tests: logger.info("Phase 2 test: " + title) run_eap_fast_phase2(dev, payload, failure) diff --git a/tests/hwsim/test_erp.py b/tests/hwsim/test_erp.py index 7623198..3bb47f1 100644 --- a/tests/hwsim/test_erp.py +++ b/tests/hwsim/test_erp.py @@ -108,21 +108,21 @@ def test_erp_server_no_match(dev, apdev): dev[0].wait_connected(timeout=15, error="Reconnection timed out") def start_erp_as(apdev, erp_domain="example.com", msk_dump=None, tls13=False): - params = { "ssid": "as", "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18128', - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ca.pem", - "server_cert": "auth_serv/server.pem", - "private_key": "auth_serv/server.key", - "eap_sim_db": "unix:/tmp/hlr_auc_gw.sock", - "dh_file": "auth_serv/dh.conf", - "pac_opaque_encr_key": "000102030405060708090a0b0c0d0e0f", - "eap_fast_a_id": "101112131415161718191a1b1c1d1e1f", - "eap_fast_a_id_info": "test server", - "eap_server_erp": "1", - "erp_domain": erp_domain } + params = {"ssid": "as", "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18128', + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ca.pem", + "server_cert": "auth_serv/server.pem", + "private_key": "auth_serv/server.key", + "eap_sim_db": "unix:/tmp/hlr_auc_gw.sock", + "dh_file": "auth_serv/dh.conf", + "pac_opaque_encr_key": "000102030405060708090a0b0c0d0e0f", + "eap_fast_a_id": "101112131415161718191a1b1c1d1e1f", + "eap_fast_a_id_info": "test server", + "eap_server_erp": "1", + "erp_domain": erp_domain} if msk_dump: params["dump_msk_file"] = msk_dump if tls13: @@ -176,7 +176,7 @@ def erp_test(dev, hapd, **kwargs): if "EAP re-authentication completed successfully" not in ev: raise Exception("Did not use ERP") dev.wait_connected(timeout=15, error="Reconnection timed out") - ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") dev.request("DISCONNECT") diff --git a/tests/hwsim/test_ext_password.py b/tests/hwsim/test_ext_password.py index e89e51d..dfaf3ea 100644 --- a/tests/hwsim/test_ext_password.py +++ b/tests/hwsim/test_ext_password.py @@ -74,8 +74,8 @@ def test_ext_password_interworking(dev, apdev): dev[0].hs20_enable() dev[0].request("SET ext_password_backend test:pw1=password") - id = dev[0].add_cred_values({ 'realm': "example.com", - 'username': "hs20-test" }) + id = dev[0].add_cred_values({'realm': "example.com", + 'username': "hs20-test"}) dev[0].set_cred(id, "password", "ext:pw1") interworking_select(dev[0], bssid, freq="2412") interworking_connect(dev[0], bssid, "TTLS") diff --git a/tests/hwsim/test_fils.py b/tests/hwsim/test_fils.py index 5d4d486..a35c408 100644 --- a/tests/hwsim/test_fils.py +++ b/tests/hwsim/test_fils.py @@ -567,13 +567,13 @@ def test_fils_sk_multiple_realms(dev, apdev, params): params['wpa_key_mgmt'] = "FILS-SHA256" params['auth_server_port'] = "18128" params['erp_domain'] = 'example.com' - fils_realms = [ 'r1.example.org', 'r2.EXAMPLE.org', 'r3.example.org', - 'r4.example.org', 'r5.example.org', 'r6.example.org', - 'r7.example.org', 'r8.example.org', - 'example.com', - 'r9.example.org', 'r10.example.org', 'r11.example.org', - 'r12.example.org', 'r13.example.org', 'r14.example.org', - 'r15.example.org', 'r16.example.org' ] + fils_realms = ['r1.example.org', 'r2.EXAMPLE.org', 'r3.example.org', + 'r4.example.org', 'r5.example.org', 'r6.example.org', + 'r7.example.org', 'r8.example.org', + 'example.com', + 'r9.example.org', 'r10.example.org', 'r11.example.org', + 'r12.example.org', 'r13.example.org', 'r14.example.org', + 'r15.example.org', 'r16.example.org'] params['fils_realm'] = fils_realms params['fils_cache_id'] = "1234" params['hessid'] = bssid @@ -644,22 +644,22 @@ def test_fils_sk_multiple_realms(dev, apdev, params): hwsim_utils.test_connectivity(dev[0], hapd) # DHCP message op codes -BOOTREQUEST=1 -BOOTREPLY=2 - -OPT_PAD=0 -OPT_DHCP_MESSAGE_TYPE=53 -OPT_RAPID_COMMIT=80 -OPT_END=255 - -DHCPDISCOVER=1 -DHCPOFFER=2 -DHCPREQUEST=3 -DHCPDECLINE=4 -DHCPACK=5 -DHCPNAK=6 -DHCPRELEASE=7 -DHCPINFORM=8 +BOOTREQUEST = 1 +BOOTREPLY = 2 + +OPT_PAD = 0 +OPT_DHCP_MESSAGE_TYPE = 53 +OPT_RAPID_COMMIT = 80 +OPT_END = 255 + +DHCPDISCOVER = 1 +DHCPOFFER = 2 +DHCPREQUEST = 3 +DHCPDECLINE = 4 +DHCPACK = 5 +DHCPNAK = 6 +DHCPRELEASE = 7 +DHCPINFORM = 8 def build_dhcp(req, dhcp_msg, chaddr, giaddr="0.0.0.0", ip_src="0.0.0.0", ip_dst="255.255.255.255", @@ -673,7 +673,7 @@ def build_dhcp(req, dhcp_msg, chaddr, giaddr="0.0.0.0", _yiaddr = b'\x00\x00\x00\x00' _siaddr = b'\x00\x00\x00\x00' _giaddr = socket.inet_pton(socket.AF_INET, giaddr) - _chaddr = binascii.unhexlify(chaddr.replace(':','')) + 10 * b'\x00' + _chaddr = binascii.unhexlify(chaddr.replace(':', '')) + 10 * b'\x00' htype = 1 # Hardware address type; 1 = Ethernet hlen = 6 # Hardware address length hops = 0 @@ -764,19 +764,19 @@ def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params): dev[0].request("ERP_FLUSH") if "OK" not in dev[0].request("FILS_HLP_REQ_FLUSH"): raise Exception("Failed to flush pending FILS HLP requests") - tests = [ "", - "q", - "ff:ff:ff:ff:ff:ff", - "ff:ff:ff:ff:ff:ff q" ] + tests = ["", + "q", + "ff:ff:ff:ff:ff:ff", + "ff:ff:ff:ff:ff:ff q"] for t in tests: if "FAIL" not in dev[0].request("FILS_HLP_REQ_ADD " + t): raise Exception("Invalid FILS_HLP_REQ_ADD accepted: " + t) dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER, chaddr=dev[0].own_addr()) - tests = [ "ff:ff:ff:ff:ff:ff aabb", - "ff:ff:ff:ff:ff:ff " + 255*'cc', - hapd.own_addr() + " ddee010203040506070809", - "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode() ] + tests = ["ff:ff:ff:ff:ff:ff aabb", + "ff:ff:ff:ff:ff:ff " + 255*'cc', + hapd.own_addr() + " ddee010203040506070809", + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()] for t in tests: if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + t): raise Exception("FILS_HLP_REQ_ADD failed: " + t) @@ -791,7 +791,7 @@ def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params): dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) if rapid_commit_server: # TODO: Proper rapid commit response @@ -802,7 +802,7 @@ def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params): dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3") sock.sendto(dhcpdisc[2+20+8:], addr) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3") @@ -827,7 +827,7 @@ def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params): raise Exception("Unexpected UDP port in HLP response") dhcp = frame[0:28] frame = frame[28:] - op,htype,hlen,hops,xid,secs,flags,ciaddr,yiaddr,siaddr,giaddr = struct.unpack('>4BL2H4L', dhcp) + op, htype, hlen, hops, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr = struct.unpack('>4BL2H4L', dhcp) chaddr = frame[0:16] frame = frame[16:] sname = frame[0:64] @@ -881,7 +881,7 @@ def test_fils_sk_hlp_timeout(dev, apdev, params): dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) # Wait for HLP wait timeout to hit # FILS: HLP response timeout - continue with association response @@ -946,7 +946,7 @@ def test_fils_sk_hlp_oom(dev, apdev, params): dev[0].dump_monitor() with alloc_fail(hapd, 1, "wpabuf_alloc;fils_dhcp_handler"): dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK, chaddr=dev[0].own_addr(), giaddr="127.0.0.3") @@ -958,7 +958,7 @@ def test_fils_sk_hlp_oom(dev, apdev, params): dev[0].dump_monitor() with alloc_fail(hapd, 1, "wpabuf_resize;fils_dhcp_handler"): dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK, chaddr=dev[0].own_addr(), giaddr="127.0.0.3") @@ -969,7 +969,7 @@ def test_fils_sk_hlp_oom(dev, apdev, params): dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3") @@ -1068,19 +1068,19 @@ def test_fils_sk_hlp_req_parsing(dev, apdev, params): dhcp_valid = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER, chaddr=dev[0].own_addr()) - tests = [ "ff", - "0800", - "0800" + 20*"00", - "0800" + binascii.hexlify(ipv4_overflow).decode(), - "0800" + binascii.hexlify(ipv4_unknown_proto).decode(), - "0800" + binascii.hexlify(ipv4_missing_udp_hdr).decode(), - "0800" + binascii.hexlify(udp_overflow).decode(), - "0800" + binascii.hexlify(udp_underflow).decode(), - "0800" + binascii.hexlify(udp_unknown_port).decode(), - "0800" + binascii.hexlify(dhcp_missing_data).decode(), - binascii.hexlify(dhcp_not_req).decode(), - binascii.hexlify(dhcp_no_magic).decode(), - binascii.hexlify(dhcp_unknown_magic).decode() ] + tests = ["ff", + "0800", + "0800" + 20*"00", + "0800" + binascii.hexlify(ipv4_overflow).decode(), + "0800" + binascii.hexlify(ipv4_unknown_proto).decode(), + "0800" + binascii.hexlify(ipv4_missing_udp_hdr).decode(), + "0800" + binascii.hexlify(udp_overflow).decode(), + "0800" + binascii.hexlify(udp_underflow).decode(), + "0800" + binascii.hexlify(udp_unknown_port).decode(), + "0800" + binascii.hexlify(dhcp_missing_data).decode(), + binascii.hexlify(dhcp_not_req).decode(), + binascii.hexlify(dhcp_no_magic).decode(), + binascii.hexlify(dhcp_unknown_magic).decode()] for t in tests: if "OK" not in dev[0].request("FILS_HLP_REQ_ADD ff:ff:ff:ff:ff:ff " + t): raise Exception("FILS_HLP_REQ_ADD failed: " + t) @@ -1099,8 +1099,8 @@ def test_fils_sk_hlp_req_parsing(dev, apdev, params): dev[0].wait_disconnected() dev[0].request("FILS_HLP_REQ_FLUSH") - tests = [ binascii.hexlify(dhcp_opts).decode(), - binascii.hexlify(dhcp_opts2).decode() ] + tests = [binascii.hexlify(dhcp_opts).decode(), + binascii.hexlify(dhcp_opts2).decode()] for t in tests: if "OK" not in dev[0].request("FILS_HLP_REQ_ADD ff:ff:ff:ff:ff:ff " + t): raise Exception("FILS_HLP_REQ_ADD failed: " + t) @@ -1192,21 +1192,21 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK, chaddr=dev[0].own_addr(), giaddr="127.0.0.3") #sock.sendto(dhcpdisc[2+20+8:], addr) - chaddr = binascii.unhexlify(dev[0].own_addr().replace(':','')) + 10*b'\x00' - tests = [ b"\x00", - b"\x02" + 500 * b"\x00", - b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 500*b"\x00", - b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63", - b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x00\x11", - b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x11\x01", - b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x00\xff", - b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x01\x00\xff", - 1501 * b"\x00" ] + chaddr = binascii.unhexlify(dev[0].own_addr().replace(':', '')) + 10*b'\x00' + tests = [b"\x00", + b"\x02" + 500 * b"\x00", + b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 500*b"\x00", + b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63", + b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x00\x11", + b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x11\x01", + b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x00\xff", + b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x01\x00\xff", + 1501 * b"\x00"] for t in tests: sock.sendto(t, addr) dev[0].wait_connected() @@ -1216,7 +1216,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): # FILS: DHCP sendto failed: Invalid argument for second DHCP TX in proxy dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) hapd.set("dhcp_server_port", "0") dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, @@ -1230,13 +1230,13 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): # Options in DHCPOFFER dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3", extra_op=b"\x00\x11", opt_end=False) sock.sendto(dhcpoffer[2+20+8:], addr) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dev[0].wait_connected() dev[0].request("DISCONNECT") @@ -1245,13 +1245,13 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): # Options in DHCPOFFER (2) dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3", extra_op=b"\x11\x01", opt_end=False) sock.sendto(dhcpoffer[2+20+8:], addr) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dev[0].wait_connected() dev[0].request("DISCONNECT") @@ -1260,13 +1260,13 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): # Server ID in DHCPOFFER dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3", extra_op=b"\x36\x01\x30") sock.sendto(dhcpoffer[2+20+8:], addr) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dev[0].wait_connected() dev[0].request("DISCONNECT") @@ -1281,7 +1281,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): raise Exception("FILS_HLP_REQ_ADD failed") dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3", @@ -1300,7 +1300,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params): raise Exception("FILS_HLP_REQ_ADD failed") dev[0].dump_monitor() dev[0].select_network(id, freq=2412) - (msg,addr) = sock.recvfrom(1000) + (msg, addr) = sock.recvfrom(1000) logger.debug("Received DHCP message from %s" % str(addr)) dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False, chaddr=dev[0].own_addr(), giaddr="127.0.0.3", @@ -1356,7 +1356,7 @@ def test_fils_sk_erp_sim(dev, apdev, params): check_fils_capa(dev[0]) check_erp_capa(dev[0]) - realm='wlan.mnc001.mcc232.3gppnetwork.org' + realm = 'wlan.mnc001.mcc232.3gppnetwork.org' start_erp_as(apdev[1], erp_domain=realm, msk_dump=os.path.join(params['logdir'], "msk.lst")) @@ -1431,10 +1431,10 @@ def run_fils_sk_pfs(dev, apdev, group, params): check_erp_capa(dev[0]) tls = dev[0].request("GET tls_library") - if int(group) in [ 25 ]: + if int(group) in [25]: if not (tls.startswith("OpenSSL") and ("build=OpenSSL 1.0.2" in tls or "build=OpenSSL 1.1" in tls) and ("run=OpenSSL 1.0.2" in tls or "run=OpenSSL 1.1" in tls)): raise HwsimSkip("EC group not supported") - if int(group) in [ 27, 28, 29, 30 ]: + if int(group) in [27, 28, 29, 30]: if not (tls.startswith("OpenSSL") and ("build=OpenSSL 1.0.2" in tls or "build=OpenSSL 1.1" in tls) and ("run=OpenSSL 1.0.2" in tls or "run=OpenSSL 1.1" in tls)): raise HwsimSkip("Brainpool EC group not supported") @@ -1744,7 +1744,7 @@ def test_fils_and_ft(dev, apdev, params): params["reassociation_deadline"] = "1000" params['nas_identifier'] = "nas1.w1.fi" params['r1_key_holder'] = "000102030405" - params['r0kh'] = [ "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f" params['ieee80211w'] = "1" hapd = hostapd.add_ap(apdev[0]['ifname'], params) @@ -1781,7 +1781,7 @@ def test_fils_and_ft(dev, apdev, params): params['wpa_key_mgmt'] = "FT-EAP" params['nas_identifier'] = "nas2.w1.fi" params['r1_key_holder'] = "000102030406" - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f" hapd2 = hostapd.add_ap(apdev[1]['ifname'], params) @@ -1893,8 +1893,8 @@ def run_fils_and_ft_setup(dev, apdev, params, key_mgmt): params["reassociation_deadline"] = "1000" params['nas_identifier'] = "nas1.w1.fi" params['r1_key_holder'] = "000102030405" - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f100102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f" params['ieee80211w'] = "2" hapd = hostapd.add_ap(apdev[0]['ifname'], params) @@ -1924,8 +1924,8 @@ def run_fils_and_ft_setup(dev, apdev, params, key_mgmt): params['wpa_key_mgmt'] = key_mgmt params['nas_identifier'] = "nas2.w1.fi" params['r1_key_holder'] = "000102030406" - params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f", - "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f" ] + params['r0kh'] = ["02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f", + "02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"] params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f" hapd2 = hostapd.add_ap(apdev[1]['ifname'], params) @@ -2009,7 +2009,7 @@ def test_fils_assoc_replay(dev, apdev, params): filt = "wlan.fc.type == 2 && " + \ "wlan.da == " + sta + " && " + \ "wlan.sa == " + ap + " && wlan.ccmp.extiv" - fields = [ "wlan.ccmp.extiv" ] + fields = ["wlan.ccmp.extiv"] res = run_tshark(capfile, filt, fields) vals = res.splitlines() logger.info("CCMP PN: " + str(vals)) diff --git a/tests/hwsim/test_fst_config.py b/tests/hwsim/test_fst_config.py index d497819..9813401 100644 --- a/tests/hwsim/test_fst_config.py +++ b/tests/hwsim/test_fst_config.py @@ -162,8 +162,8 @@ class FstLauncher: 'alt-hostapd/hostapd/hostapd') if not os.path.exists(prg): prg = '../../hostapd/hostapd' - cmd = [ prg, '-B', '-dddt', - '-P', pidfile, '-f', mylogfile, '-g', self.hapd_fst_global] + cmd = [prg, '-B', '-dddt', + '-P', pidfile, '-f', mylogfile, '-g', self.hapd_fst_global] for i in range(0, len(self.cfgs_to_run)): cfg = self.cfgs_to_run[i] if cfg.is_ap() == True: @@ -189,8 +189,8 @@ class FstLauncher: 'alt-wpa_supplicant/wpa_supplicant/wpa_supplicant') if not os.path.exists(prg): prg = '../../wpa_supplicant/wpa_supplicant' - cmd = [ prg, '-B', '-dddt', - '-P' + pidfile, '-f', mylogfile, '-g', self.wsup_fst_global ] + cmd = [prg, '-B', '-dddt', + '-P' + pidfile, '-f', mylogfile, '-g', self.wsup_fst_global] sta_no = 0 for i in range(0, len(self.cfgs_to_run)): cfg = self.cfgs_to_run[i] @@ -295,9 +295,9 @@ def scan_and_get_bss(dev, frq): # AP configuration tests def run_test_ap_configuration(apdev, test_params, - fst_group = fst_test_common.fst_test_def_group, - fst_pri = fst_test_common.fst_test_def_prio_high, - fst_llt = fst_test_common.fst_test_def_llt): + fst_group=fst_test_common.fst_test_def_group, + fst_pri=fst_test_common.fst_test_def_prio_high, + fst_llt=fst_test_common.fst_test_def_llt): """Runs FST hostapd where the 1st AP configuration is fixed, the 2nd fst configuration is provided by the parameters. Returns the result of the run: 0 - no errors discovered, an error otherwise. The function is used for @@ -318,9 +318,9 @@ def run_test_ap_configuration(apdev, test_params, return res def run_test_sta_configuration(test_params, - fst_group = fst_test_common.fst_test_def_group, - fst_pri = fst_test_common.fst_test_def_prio_high, - fst_llt = fst_test_common.fst_test_def_llt): + fst_group=fst_test_common.fst_test_def_group, + fst_pri=fst_test_common.fst_test_def_prio_high, + fst_llt=fst_test_common.fst_test_def_llt): """Runs FST wpa_supplicant where the 1st STA configuration is fixed, the 2nd fst configuration is provided by the parameters. Returns the result of the run: 0 - no errors discovered, an error otherwise. The function is used @@ -339,57 +339,57 @@ def run_test_sta_configuration(test_params, def test_fst_ap_config_llt_neg(dev, apdev, test_params): """FST AP configuration negative LLT""" - res = run_test_ap_configuration(apdev, test_params, fst_llt = '-1') + res = run_test_ap_configuration(apdev, test_params, fst_llt='-1') if res == 0: raise Exception("hostapd started with a negative llt") def test_fst_ap_config_llt_zero(dev, apdev, test_params): """FST AP configuration zero LLT""" - res = run_test_ap_configuration(apdev, test_params, fst_llt = '0') + res = run_test_ap_configuration(apdev, test_params, fst_llt='0') if res == 0: raise Exception("hostapd started with a zero llt") def test_fst_ap_config_llt_too_big(dev, apdev, test_params): """FST AP configuration LLT is too big""" res = run_test_ap_configuration(apdev, test_params, - fst_llt = '4294967296') #0x100000000 + fst_llt='4294967296') #0x100000000 if res == 0: raise Exception("hostapd started with llt that is too big") def test_fst_ap_config_llt_nan(dev, apdev, test_params): """FST AP configuration LLT is not a number""" - res = run_test_ap_configuration(apdev, test_params, fst_llt = 'nan') + res = run_test_ap_configuration(apdev, test_params, fst_llt='nan') if res == 0: raise Exception("hostapd started with llt not a number") def test_fst_ap_config_pri_neg(dev, apdev, test_params): """FST AP configuration Priority negative""" - res = run_test_ap_configuration(apdev, test_params, fst_pri = '-1') + res = run_test_ap_configuration(apdev, test_params, fst_pri='-1') if res == 0: raise Exception("hostapd started with a negative fst priority") def test_fst_ap_config_pri_zero(dev, apdev, test_params): """FST AP configuration Priority zero""" - res = run_test_ap_configuration(apdev, test_params, fst_pri = '0') + res = run_test_ap_configuration(apdev, test_params, fst_pri='0') if res == 0: raise Exception("hostapd started with a zero fst priority") def test_fst_ap_config_pri_large(dev, apdev, test_params): """FST AP configuration Priority too large""" - res = run_test_ap_configuration(apdev, test_params, fst_pri = '256') + res = run_test_ap_configuration(apdev, test_params, fst_pri='256') if res == 0: raise Exception("hostapd started with too large fst priority") def test_fst_ap_config_pri_nan(dev, apdev, test_params): """FST AP configuration Priority not a number""" - res = run_test_ap_configuration(apdev, test_params, fst_pri = 'nan') + res = run_test_ap_configuration(apdev, test_params, fst_pri='nan') if res == 0: raise Exception("hostapd started with fst priority not a number") def test_fst_ap_config_group_len(dev, apdev, test_params): """FST AP configuration Group max length""" res = run_test_ap_configuration(apdev, test_params, - fst_group = 'fstg5678abcd34567') + fst_group='fstg5678abcd34567') if res == 0: raise Exception("hostapd started with fst_group length too big") @@ -401,7 +401,7 @@ def test_fst_ap_config_good(dev, apdev, test_params): def test_fst_ap_config_default(dev, apdev, test_params): """FST AP configuration default parameters""" - res = run_test_ap_configuration(apdev, test_params, fst_llt = None) + res = run_test_ap_configuration(apdev, test_params, fst_llt=None) if res != 0: raise Exception("hostapd didn't start with valid config parameters") @@ -410,57 +410,57 @@ def test_fst_ap_config_default(dev, apdev, test_params): def test_fst_sta_config_llt_neg(dev, apdev, test_params): """FST STA configuration negative LLT""" - res = run_test_sta_configuration(test_params, fst_llt = '-1') + res = run_test_sta_configuration(test_params, fst_llt='-1') if res == 0: raise Exception("wpa_supplicant started with a negative llt") def test_fst_sta_config_llt_zero(dev, apdev, test_params): """FST STA configuration zero LLT""" - res = run_test_sta_configuration(test_params, fst_llt = '0') + res = run_test_sta_configuration(test_params, fst_llt='0') if res == 0: raise Exception("wpa_supplicant started with a zero llt") def test_fst_sta_config_llt_large(dev, apdev, test_params): """FST STA configuration LLT is too large""" res = run_test_sta_configuration(test_params, - fst_llt = '4294967296') #0x100000000 + fst_llt='4294967296') #0x100000000 if res == 0: raise Exception("wpa_supplicant started with llt that is too large") def test_fst_sta_config_llt_nan(dev, apdev, test_params): """FST STA configuration LLT is not a number""" - res = run_test_sta_configuration(test_params, fst_llt = 'nan') + res = run_test_sta_configuration(test_params, fst_llt='nan') if res == 0: raise Exception("wpa_supplicant started with llt not a number") def test_fst_sta_config_pri_neg(dev, apdev, test_params): """FST STA configuration Priority negative""" - res = run_test_sta_configuration(test_params, fst_pri = '-1') + res = run_test_sta_configuration(test_params, fst_pri='-1') if res == 0: raise Exception("wpa_supplicant started with a negative fst priority") def test_fst_sta_config_pri_zero(dev, apdev, test_params): """FST STA configuration Priority zero""" - res = run_test_sta_configuration(test_params, fst_pri = '0') + res = run_test_sta_configuration(test_params, fst_pri='0') if res == 0: raise Exception("wpa_supplicant started with a zero fst priority") def test_fst_sta_config_pri_big(dev, apdev, test_params): """FST STA configuration Priority too large""" - res = run_test_sta_configuration(test_params, fst_pri = '256') + res = run_test_sta_configuration(test_params, fst_pri='256') if res == 0: raise Exception("wpa_supplicant started with too large fst priority") def test_fst_sta_config_pri_nan(dev, apdev, test_params): """FST STA configuration Priority not a number""" - res = run_test_sta_configuration(test_params, fst_pri = 'nan') + res = run_test_sta_configuration(test_params, fst_pri='nan') if res == 0: raise Exception("wpa_supplicant started with fst priority not a number") def test_fst_sta_config_group_len(dev, apdev, test_params): """FST STA configuration Group max length""" res = run_test_sta_configuration(test_params, - fst_group = 'fstg5678abcd34567') + fst_group='fstg5678abcd34567') if res == 0: raise Exception("wpa_supplicant started with fst_group length too big") @@ -472,7 +472,7 @@ def test_fst_sta_config_good(dev, apdev, test_params): def test_fst_sta_config_default(dev, apdev, test_params): """FST STA configuration default parameters""" - res = run_test_sta_configuration(test_params, fst_llt = None) + res = run_test_sta_configuration(test_params, fst_llt=None) if res != 0: raise Exception("wpa_supplicant didn't start with valid config parameters") @@ -496,9 +496,9 @@ def test_fst_scan_mb(dev, apdev, test_params): if res != 0: raise Exception("hostapd didn't start properly") try: - mbie1=[] + mbie1 = [] flags1 = '' - mbie2=[] + mbie2 = [] flags2 = '' # Scan 1st AP vals1 = scan_and_get_bss(dev[0], fst_test_common.fst_test_def_freq_a) @@ -511,7 +511,7 @@ def test_fst_scan_mb(dev, apdev, test_params): vals2 = scan_and_get_bss(dev[2], fst_test_common.fst_test_def_freq_g) if vals2 != None: if 'ie' in vals2: - mbie2 = parse_ies(vals2['ie'],0x9e) + mbie2 = parse_ies(vals2['ie'], 0x9e) if 'flags' in vals2: flags2 = vals2['flags'] finally: @@ -538,7 +538,7 @@ def test_fst_scan_nomb(dev, apdev, test_params): raise Exception("Hostapd didn't start properly") try: time.sleep(2) - mbie1=[] + mbie1 = [] flags1 = '' vals1 = scan_and_get_bss(dev[0], fst_test_common.fst_test_def_freq_a) if vals1 != None: diff --git a/tests/hwsim/test_fst_module.py b/tests/hwsim/test_fst_module.py index ffa216f..bb3b44c 100644 --- a/tests/hwsim/test_fst_module.py +++ b/tests/hwsim/test_fst_module.py @@ -84,7 +84,7 @@ bad_param_names = ("None", "Bad fsts_id") def fst_start_session(apdev, test_params, bad_param_type, start_on_ap, - peer_addr = None): + peer_addr=None): """This function makes the necessary preparations and the adds and sets a session using either correct or incorrect parameters depending on the value of bad_param_type. If the call ends as expected (with session being @@ -354,7 +354,7 @@ def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap, responder = ap1 new_iface = sta2.ifname() new_peer_addr = sta2.get_actual_peer_addr() - initiator.add_peer(responder, new_peer_addr = new_peer_addr) + initiator.add_peer(responder, new_peer_addr=new_peer_addr) sid = initiator.add_session() initiator.configure_session(sid, new_iface) if bad_param_type != bad_param_session_transfer_setup_skipped: @@ -413,7 +413,7 @@ def fst_tear_down_session(apdev, test_params, bad_param_type, init_on_ap): responder = ap1 new_iface = sta2.ifname() new_peer_addr = sta2.get_actual_peer_addr() - initiator.add_peer(responder, new_peer_addr = new_peer_addr) + initiator.add_peer(responder, new_peer_addr=new_peer_addr) sid = initiator.add_session() initiator.configure_session(sid, new_iface) if bad_param_type != bad_param_session_teardown_setup_skipped: @@ -492,7 +492,7 @@ def fst_remove_session(apdev, test_params, remove_session_scenario, init_on_ap): responder = ap1 new_iface = sta2.ifname() new_peer_addr = sta2.get_actual_peer_addr() - initiator.add_peer(responder, new_peer_addr = new_peer_addr) + initiator.add_peer(responder, new_peer_addr=new_peer_addr) sid = initiator.add_session() initiator.configure_session(sid, new_iface) if remove_session_scenario != remove_scenario_no_params: @@ -544,7 +544,7 @@ frame_type_names = ("Session request", "Ack response", "Tear down") -def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, additional_param = ''): +def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, additional_param=''): """This function creates two pairs of APs and stations, makes them connect and then causes one side to send an unexpected FST frame of the specified type to the other. The other side should then identify and ignore the @@ -568,8 +568,8 @@ def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, addi receiver = ap1 new_iface = sta2.ifname() new_peer_addr = sta2.get_actual_peer_addr() - sender.add_peer(receiver, new_peer_addr = new_peer_addr) - sid=sender.add_session() + sender.add_peer(receiver, new_peer_addr=new_peer_addr) + sid = sender.add_session() sender.configure_session(sid, new_iface) if frame_type == frame_type_session_request: sender.send_session_setup_request(sid) @@ -663,7 +663,7 @@ def fst_bad_transfer(apdev, test_params, bad_scenario_type, init_on_ap): responder = ap1 new_iface = sta2.ifname() new_peer_addr = sta2.get_actual_peer_addr() - initiator.add_peer(responder, new_peer_addr = new_peer_addr) + initiator.add_peer(responder, new_peer_addr=new_peer_addr) sid = initiator.add_session() initiator.configure_session(sid, new_iface) if (bad_scenario_type != bad_scenario_ack_req_session_not_set_up and @@ -672,7 +672,7 @@ def fst_bad_transfer(apdev, test_params, bad_scenario_type, init_on_ap): bad_scenario_type != bad_scenario_ack_resp_session_not_established_init_side and bad_scenario_type != bad_scenario_ack_req_session_not_established_resp_side and bad_scenario_type != bad_scenario_ack_resp_session_not_established_resp_side): - response = "accept" + response = "accept" else: response = '' initiator.initiate_session(sid, response) @@ -739,7 +739,7 @@ def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params): """FST STA connecting to non-FST AP""" ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" }) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: orig_sta1_mbies = sta1.get_local_mbies() orig_sta2_mbies = sta2.get_local_mbies() @@ -822,7 +822,7 @@ def test_fst_second_sta_connect_to_non_fst_ap(dev, apdev, test_params): """FST STA 2nd connecting to non-FST AP""" fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" }) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a) sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a) @@ -852,7 +852,7 @@ def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params): """FST STA 2nd connecting to FST AP""" fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" }) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq='2412') @@ -882,7 +882,7 @@ def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params): """FST disconnect 1 of 2 STAs from non-FST AP""" fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" }) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a) sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a) @@ -913,7 +913,7 @@ def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params): """FST disconnect 1 of 2 STAs from FST AP""" fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" }) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a) sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a) @@ -944,7 +944,7 @@ def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params): """FST disconnect 2 of 2 STAs from non-FST AP""" fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" }) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a) sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a) @@ -977,7 +977,7 @@ def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params): """FST disconnect 2 of 2 STAs from FST AP""" fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) with HWSimRadio() as (radio, iface): - non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g"}) + non_fst_ap = hostapd.add_ap(iface, {"ssid": "non_fst_11g"}) try: vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a) sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a) @@ -1444,51 +1444,51 @@ def test_fst_ap_ctrl_iface(dev, apdev, test_params): if len(res) != 1 + start_num_groups: raise Exception("Unexpected number of groups") - tests = [ "LIST_IFACES unknown", - "LIST_IFACES unknown2", - "SESSION_GET 12345678", - "SESSION_SET " + sid + " unknown=foo", - "SESSION_RESPOND 12345678 foo", - "SESSION_RESPOND " + sid, - "SESSION_RESPOND " + sid + " foo", - "TEST_REQUEST foo", - "TEST_REQUEST SEND_SETUP_REQUEST", - "TEST_REQUEST SEND_SETUP_REQUEST foo", - "TEST_REQUEST SEND_SETUP_RESPONSE", - "TEST_REQUEST SEND_SETUP_RESPONSE foo", - "TEST_REQUEST SEND_ACK_REQUEST", - "TEST_REQUEST SEND_ACK_REQUEST foo", - "TEST_REQUEST SEND_ACK_RESPONSE", - "TEST_REQUEST SEND_ACK_RESPONSE foo", - "TEST_REQUEST SEND_TEAR_DOWN", - "TEST_REQUEST SEND_TEAR_DOWN foo", - "TEST_REQUEST GET_FSTS_ID", - "TEST_REQUEST GET_FSTS_ID foo", - "TEST_REQUEST GET_LOCAL_MBIES", - "TEST_REQUEST GET_LOCAL_MBIES foo", - "GET_PEER_MBIES", - "GET_PEER_MBIES ", - "GET_PEER_MBIES unknown", - "GET_PEER_MBIES unknown unknown", - "GET_PEER_MBIES unknown " + initiator.get_new_peer_addr(), - "GET_PEER_MBIES " + initiator.ifname() + " 01:ff:ff:ff:ff:ff", - "GET_PEER_MBIES " + initiator.ifname() + " 00:ff:ff:ff:ff:ff", - "GET_PEER_MBIES " + initiator.ifname() + " 00:00:00:00:00:00", - "IFACE_PEERS", - "IFACE_PEERS ", - "IFACE_PEERS unknown", - "IFACE_PEERS unknown unknown", - "IFACE_PEERS " + initiator.fst_group, - "IFACE_PEERS " + initiator.fst_group + " unknown" ] + tests = ["LIST_IFACES unknown", + "LIST_IFACES unknown2", + "SESSION_GET 12345678", + "SESSION_SET " + sid + " unknown=foo", + "SESSION_RESPOND 12345678 foo", + "SESSION_RESPOND " + sid, + "SESSION_RESPOND " + sid + " foo", + "TEST_REQUEST foo", + "TEST_REQUEST SEND_SETUP_REQUEST", + "TEST_REQUEST SEND_SETUP_REQUEST foo", + "TEST_REQUEST SEND_SETUP_RESPONSE", + "TEST_REQUEST SEND_SETUP_RESPONSE foo", + "TEST_REQUEST SEND_ACK_REQUEST", + "TEST_REQUEST SEND_ACK_REQUEST foo", + "TEST_REQUEST SEND_ACK_RESPONSE", + "TEST_REQUEST SEND_ACK_RESPONSE foo", + "TEST_REQUEST SEND_TEAR_DOWN", + "TEST_REQUEST SEND_TEAR_DOWN foo", + "TEST_REQUEST GET_FSTS_ID", + "TEST_REQUEST GET_FSTS_ID foo", + "TEST_REQUEST GET_LOCAL_MBIES", + "TEST_REQUEST GET_LOCAL_MBIES foo", + "GET_PEER_MBIES", + "GET_PEER_MBIES ", + "GET_PEER_MBIES unknown", + "GET_PEER_MBIES unknown unknown", + "GET_PEER_MBIES unknown " + initiator.get_new_peer_addr(), + "GET_PEER_MBIES " + initiator.ifname() + " 01:ff:ff:ff:ff:ff", + "GET_PEER_MBIES " + initiator.ifname() + " 00:ff:ff:ff:ff:ff", + "GET_PEER_MBIES " + initiator.ifname() + " 00:00:00:00:00:00", + "IFACE_PEERS", + "IFACE_PEERS ", + "IFACE_PEERS unknown", + "IFACE_PEERS unknown unknown", + "IFACE_PEERS " + initiator.fst_group, + "IFACE_PEERS " + initiator.fst_group + " unknown"] for t in tests: if "FAIL" not in initiator.grequest("FST-MANAGER " + t): raise Exception("Unexpected response for invalid FST-MANAGER command " + t) if "UNKNOWN FST COMMAND" not in initiator.grequest("FST-MANAGER unknown"): raise Exception("Unexpected response for unknown FST-MANAGER command") - tests = [ "FST-DETACH", "FST-DETACH ", "FST-DETACH unknown", - "FST-ATTACH", "FST-ATTACH ", "FST-ATTACH unknown", - "FST-ATTACH unknown unknown" ] + tests = ["FST-DETACH", "FST-DETACH ", "FST-DETACH unknown", + "FST-ATTACH", "FST-ATTACH ", "FST-ATTACH unknown", + "FST-ATTACH unknown unknown"] for t in tests: if "FAIL" not in initiator.grequest(t): raise Exception("Unexpected response for invalid command " + t) @@ -1823,7 +1823,7 @@ FST_ACTION_ON_CHANNEL_TUNNEL = 5 def hostapd_tx_and_status(hapd, msg): hapd.set("ext_mgmt_frame_handling", "1") hapd.mgmt_tx(msg) - ev = hapd.wait_event([ "MGMT-TX-STATUS" ], timeout=1) + ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=1) if ev is None or "ok=1" not in ev: raise Exception("No ACK") hapd.set("ext_mgmt_frame_handling", "0") @@ -2067,7 +2067,7 @@ def test_fst_ack_response_proto(dev, apdev, test_params): s = sta1.grequest("FST-MANAGER SESSION_INITIATE "+ sid) if not s.startswith('OK'): raise Exception("Cannot initiate fst session: %s" % s) - ev = sta1.peer_obj.wait_gevent([ "FST-EVENT-SESSION" ], timeout=5) + ev = sta1.peer_obj.wait_gevent(["FST-EVENT-SESSION"], timeout=5) if ev is None: raise Exception("No FST-EVENT-SESSION received") event = fst_module_aux.parse_fst_session_event(ev) @@ -2103,7 +2103,7 @@ def test_fst_ack_response_proto(dev, apdev, test_params): msg['payload'] = struct.pack("