diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index 58aabc5e3..03a0bd73e 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 8fbd71fc5..4b6bab07d 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 7578159f1..2ca1e3dac 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 bc1be8542..bc8aabdd4 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 cf49b13b1..dccdefc71 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 eba6102a4..7e6327a7b 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 08fae834a..55642c022 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 58dc9d6fa..4a43da447 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 aa83c1d94..50f46c310 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 dbc02923b..2627c57a5 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 ec126e666..0046000d6 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 8e5b2d68b..59fb651ad 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 cede63cf7..412a821c7 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" }) + 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") ] + 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 76c5d786a..07ae4a8e8 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 9b6ba11a6..225f3ab05 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 64cb26711..32bafdcb5 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 71ef74f5c..556ea46bb 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 937d6fa53..5a1120762 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 1df9a9de4..9c6f1e447 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 cca0cb77a..4cdb33a53 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 72e05b936..8a183c436 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 bcb95ac26..e35914c28 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 1cc202e8f..e4e940f08 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 575239f3b..6708f3f7e 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 6f6f65a5c..fb74065eb 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 4444e398f..25201e5b0 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 df4be9b5b..e17b39780 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 513273e19..04bec3c23 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 f0f852b24..df408f134 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 ef117280a..bdd47bf98 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 25db66212..544cd0099 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 06eb1266b..f418f56da 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 0890984fc..a461fe0ce 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 630ea224f..87122aa32 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 16fcf3cd5..55d74bbf5 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 a153fae1a..f14222daa 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 15c495e0b..646bc518a 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 6074b796f..4ee20ea12 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 762319899..3bb47f1eb 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 e89e51d31..dfaf3ea6e 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 5d4d48621..a35c40810 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 +BOOTREQUEST = 1 +BOOTREPLY = 2 -OPT_PAD=0 -OPT_DHCP_MESSAGE_TYPE=53 -OPT_RAPID_COMMIT=80 -OPT_END=255 +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 +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 d497819bd..981340141 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 ffa216f5c..bb3b44ca3 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("Q', self.msg['rsn_replay_counter'])[0] + 1 @@ -803,10 +803,10 @@ class STAConnection: @remote_compatible def test_wpa2_ocv_mismatch_client(dev, apdev): """OCV client mismatch""" - params = { "channel": "1", - "ieee80211w": "1", - "ocv": "1", - "freq": "2412" } + params = {"channel": "1", + "ieee80211w": "1", + "ocv": "1", + "freq": "2412"} conn = STAConnection(apdev[0], dev[0], params) conn.test_bad_oci("element missing", None, 0, 0, "did not receive mandatory OCI") @@ -831,20 +831,20 @@ def test_wpa2_ocv_vht160_mismatch_client(dev, apdev): dev[0].flush_scan_cache() def run_wpa2_ocv_vht160_mismatch_client(dev, apdev): - params = { "hw_mode": "a", - "channel": "100", - "country_code": "ZA", - "ht_capab": "[HT40+]", - "ieee80211w": "1", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "ocv": "1", - "vht_oper_centr_freq_seg0_idx": "114", - "freq": "5500", - "ieee80211d": "1", - "ieee80211h": "1" } - sta_params = { "disable_vht": "1" } + params = {"hw_mode": "a", + "channel": "100", + "country_code": "ZA", + "ht_capab": "[HT40+]", + "ieee80211w": "1", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "ocv": "1", + "vht_oper_centr_freq_seg0_idx": "114", + "freq": "5500", + "ieee80211d": "1", + "ieee80211h": "1"} + sta_params = {"disable_vht": "1"} conn = STAConnection(apdev[0], dev[0], params, sta_params) conn.test_bad_oci("smaller bandwidth (20 Mhz) than negotiated", 121, 100, 0, "channel bandwidth mismatch") @@ -863,11 +863,11 @@ def run_wpa2_ocv_vht160_mismatch_client(dev, apdev): def test_wpa2_ocv_sta_group_hs(dev, apdev): """OCV group handshake (STA)""" - params = { "channel": "1", - "ieee80211w": "1", - "ocv": "1", - "freq": "2412", - "wpa_strict_rekey": "1" } + params = {"channel": "1", + "ieee80211w": "1", + "ocv": "1", + "freq": "2412", + "wpa_strict_rekey": "1"} conn = STAConnection(apdev[0], dev[0], params.copy()) conn.confirm_valid_oci(81, 1, 0) diff --git a/tests/hwsim/test_owe.py b/tests/hwsim/test_owe.py index ba15fc764..ee42495d4 100644 --- a/tests/hwsim/test_owe.py +++ b/tests/hwsim/test_owe.py @@ -19,11 +19,11 @@ def test_owe(dev, apdev): """Opportunistic Wireless Encryption""" if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP" } + params = {"ssid": "owe", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -43,15 +43,15 @@ def test_owe_groups(dev, apdev): """Opportunistic Wireless Encryption - DH groups""" if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP" } + params = {"ssid": "owe", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() dev[0].scan_for_bss(bssid, freq="2412") - for group in [ 19, 20, 21 ]: + for group in [19, 20, 21]: dev[0].connect("owe", key_mgmt="OWE", owe_group=str(group)) hwsim_utils.test_connectivity(dev[0], hapd) dev[0].request("REMOVE_NETWORK all") @@ -66,15 +66,15 @@ def test_owe_pmksa_caching_connect_cmd(dev, apdev): """Opportunistic Wireless Encryption and PMKSA caching using cfg80211 connect command""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") - run_owe_pmksa_caching([ wpas ], apdev) + run_owe_pmksa_caching([wpas], apdev) def run_owe_pmksa_caching(dev, apdev): if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP" } + params = {"ssid": "owe", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -116,11 +116,11 @@ def test_owe_and_psk(dev, apdev): """Opportunistic Wireless Encryption and WPA2-PSK enabled""" if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe+psk", - "wpa": "2", - "wpa_key_mgmt": "OWE WPA-PSK", - "rsn_pairwise": "CCMP", - "wpa_passphrase": "12345678" } + params = {"ssid": "owe+psk", + "wpa": "2", + "wpa_key_mgmt": "OWE WPA-PSK", + "rsn_pairwise": "CCMP", + "wpa_passphrase": "12345678"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -140,26 +140,26 @@ def test_owe_transition_mode_connect_cmd(dev, apdev): """Opportunistic Wireless Encryption transition mode using cfg80211 connect command""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") - run_owe_transition_mode([ wpas ], apdev) + run_owe_transition_mode([wpas], apdev) def run_owe_transition_mode(dev, apdev): if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") dev[0].flush_scan_cache() - params = { "ssid": "owe-random", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP", - "ieee80211w": "2", - "owe_transition_bssid": apdev[1]['bssid'], - "owe_transition_ssid": '"owe-test"', - "ignore_broadcast_ssid": "1" } + params = {"ssid": "owe-random", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP", + "ieee80211w": "2", + "owe_transition_bssid": apdev[1]['bssid'], + "owe_transition_ssid": '"owe-test"', + "ignore_broadcast_ssid": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() - params = { "ssid": "owe-test", - "owe_transition_bssid": apdev[0]['bssid'], - "owe_transition_ssid": '"owe-random"' } + params = {"ssid": "owe-test", + "owe_transition_bssid": apdev[0]['bssid'], + "owe_transition_ssid": '"owe-random"'} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = hapd2.own_addr() @@ -207,7 +207,7 @@ def test_owe_transition_mode_open_only_ap(dev, apdev): if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") dev[0].flush_scan_cache() - params = { "ssid": "owe-test-open" } + params = {"ssid": "owe-test-open"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -227,9 +227,9 @@ def test_owe_transition_mode_open_multiple_scans(dev, apdev): if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") dev[0].flush_scan_cache() - params = { "ssid": "owe-test", - "owe_transition_bssid": apdev[0]['bssid'], - "owe_transition_ssid": '"owe-random"' } + params = {"ssid": "owe-test", + "owe_transition_bssid": apdev[0]['bssid'], + "owe_transition_ssid": '"owe-random"'} hapd2 = hostapd.add_ap(apdev[1], params) bssid2 = hapd2.own_addr() @@ -240,14 +240,14 @@ def test_owe_transition_mode_open_multiple_scans(dev, apdev): scan_freq="2412", wait_connect=False) ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=1) - params = { "ssid": "owe-random", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP", - "ieee80211w": "2", - "owe_transition_bssid": apdev[1]['bssid'], - "owe_transition_ssid": '"owe-test"', - "ignore_broadcast_ssid": "1" } + params = {"ssid": "owe-random", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP", + "ieee80211w": "2", + "owe_transition_bssid": apdev[1]['bssid'], + "owe_transition_ssid": '"owe-test"', + "ignore_broadcast_ssid": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -306,7 +306,7 @@ def test_owe_unsupported_group_connect_cmd(dev, apdev): wpas = None wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") - run_owe_unsupported_group([ wpas ], apdev) + run_owe_unsupported_group([wpas], apdev) finally: if wpas: wpas.request("VENDOR_ELEM_REMOVE 13 *") @@ -319,10 +319,10 @@ def run_owe_unsupported_group(dev, apdev): # status code 77. dev[0].request("VENDOR_ELEM_ADD 13 ff23200000783590fb7440e03d5b3b33911f86affdcc6b4411b707846ac4ff08ddc8831ccd") - params = { "ssid": "owe", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP" } + params = {"ssid": "owe", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -339,11 +339,11 @@ def test_owe_limited_group_set(dev, apdev): """Opportunistic Wireless Encryption and limited group set""" if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP", - "owe_groups": "20 21" } + params = {"ssid": "owe", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP", + "owe_groups": "20 21"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -357,7 +357,7 @@ def test_owe_limited_group_set(dev, apdev): raise Exception("Unexpected rejection reason: " + ev) dev[0].dump_monitor() - for group in [ 20, 21 ]: + for group in [20, 21]: dev[0].connect("owe", key_mgmt="OWE", owe_group=str(group)) dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() @@ -369,12 +369,12 @@ def test_owe_limited_group_set_pmf(dev, apdev, params): raise HwsimSkip("OWE not supported") pcapng = os.path.join(params['logdir'], "hwsim0.pcapng") - params = { "ssid": "owe", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP", - "owe_groups": "21" } + params = {"ssid": "owe", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP", + "owe_groups": "21"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -428,11 +428,11 @@ def test_owe_group_negotiation_connect_cmd(dev, apdev): def run_owe_group_negotiation(dev, apdev): if "OWE" not in dev.get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP", - "owe_groups": "21" } + params = {"ssid": "owe", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP", + "owe_groups": "21"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -443,13 +443,13 @@ def test_owe_assoc_reject(dev, apdev): """Opportunistic Wireless Encryption association rejection handling""" if "OWE" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("OWE not supported") - params = { "ssid": "owe", - "require_ht": "1", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "OWE", - "rsn_pairwise": "CCMP", - "owe_groups": "19" } + params = {"ssid": "owe", + "require_ht": "1", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "OWE", + "rsn_pairwise": "CCMP", + "owe_groups": "19"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -457,7 +457,7 @@ def test_owe_assoc_reject(dev, apdev): dev[0].scan_for_bss(bssid, freq="2412") dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", disable_ht="1", scan_freq="2412", wait_connect=False) - for i in range(0,2): + for i in range(0, 2): ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout=10) if ev is None: raise Exception("Association rejection not reported") @@ -465,7 +465,7 @@ def test_owe_assoc_reject(dev, apdev): # Then, verify that STA tries OWE with the default group (19) on the next # attempt instead of having moved to testing another group. hapd.set("require_ht", "0") - for i in range(0,2): + for i in range(0, 2): ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT", "CTRL-EVENT-CONNECTED"], timeout=10) if ev is None: diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py index 2a7969a1f..e896323f1 100644 --- a/tests/hwsim/test_p2p_autogo.py +++ b/tests/hwsim/test_p2p_autogo.py @@ -746,7 +746,7 @@ def _test_autogo_many_clients(dev): raise Exception("Could not find peer (3)") dev[1].p2p_stop_find() - for i in [ name0, name2, name3 ]: + for i in [name0, name2, name3]: if i not in ev1 and i not in ev2 and i not in ev3: raise Exception('name "%s" not found' % i) diff --git a/tests/hwsim/test_p2p_channel.py b/tests/hwsim/test_p2p_channel.py index 3683735d1..5729566b6 100644 --- a/tests/hwsim/test_p2p_channel.py +++ b/tests/hwsim/test_p2p_channel.py @@ -75,7 +75,7 @@ def test_p2p_channel_random_social(dev): test_data=False) check_grpform_results(i_res, r_res) freq = int(i_res['freq']) - if freq not in [ 2412, 2437, 2462 ]: + if freq not in [2412, 2437, 2462]: raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq) remove_group(dev[0], dev[1]) finally: @@ -94,7 +94,7 @@ def test_p2p_channel_random(dev): test_data=False) check_grpform_results(i_res, r_res) freq = int(i_res['freq']) - if freq > 2500 or freq in [ 2412, 2437, 2462 ]: + if freq > 2500 or freq in [2412, 2437, 2462]: raise Exception("Unexpected channel %d MHz" % freq) remove_group(dev[0], dev[1]) finally: @@ -125,7 +125,7 @@ def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params): test_data=False) check_grpform_results(i_res, r_res) freq = int(i_res['freq']) - if freq not in [ 2412, 2437, 2462 ]: + if freq not in [2412, 2437, 2462]: raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq) remove_group(dev[0], dev[1]) @@ -162,7 +162,7 @@ def test_p2p_channel_avoid(dev): test_data=False) check_grpform_results(i_res, r_res) freq = int(i_res['freq']) - if freq > 2500 or freq in [ 2412, 2437, 2462 ]: + if freq > 2500 or freq in [2412, 2437, 2462]: raise Exception("Unexpected channel %d MHz" % freq) if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES"): @@ -260,10 +260,10 @@ def test_autogo_following_bss(dev, apdev): dev[0].global_request("SET p2p_no_group_iface 0") - channels = { 3 : "2422", 5 : "2432", 9 : "2452" } + channels = {3: "2422", 5: "2432", 9: "2452"} for key in channels: - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test', - "channel" : str(key) }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test', + "channel": str(key)}) dev[0].connect("ap-test", key_mgmt="NONE", scan_freq=str(channels[key])) res_go = autogo(dev[0]) @@ -281,7 +281,7 @@ def test_go_neg_with_bss_connected(dev, apdev): dev[0].global_request("SET p2p_no_group_iface 0") hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-2.4ghz', "channel": '5' }) + {"ssid": 'bss-2.4ghz', "channel": '5'}) dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2432") #dev[0] as GO [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1], @@ -328,8 +328,8 @@ def test_autogo_with_bss_on_disallowed_chan(dev, apdev): raise Exception("New radio does not support MCC") try: - hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz', - "channel": '1' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'bss-2.4ghz', + "channel": '1'}) wpas.global_request("P2P_SET disallow_freq 2412") wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") res = autogo(wpas) @@ -353,7 +353,7 @@ def test_go_neg_with_bss_on_disallowed_chan(dev, apdev): try: hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-2.4ghz', "channel": '1' }) + {"ssid": 'bss-2.4ghz', "channel": '1'}) # make sure PBC overlap from old test cases is not maintained dev[1].flush_scan_cache() wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") @@ -406,10 +406,10 @@ def test_autogo_force_diff_channel(dev, apdev): wpas.global_request("SET p2p_no_group_iface 0") hapd = hostapd.add_ap(apdev[0], - {"ssid" : 'ap-test', "channel" : '1'}) - wpas.connect("ap-test", key_mgmt = "NONE", scan_freq = "2412") + {"ssid": 'ap-test', "channel": '1'}) + wpas.connect("ap-test", key_mgmt="NONE", scan_freq="2412") wpas.dump_monitor() - channels = { 2 : 2417, 5 : 2432, 9 : 2452 } + channels = {2: 2417, 5: 2432, 9: 2452} for key in channels: res_go = autogo(wpas, channels[key]) wpas.dump_monitor() @@ -434,9 +434,9 @@ def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev): wpas.global_request("SET p2p_no_group_iface 0") hapd = hostapd.add_ap(apdev[0], - { "country_code": 'US', - "ssid": 'bss-5ghz', "hw_mode": 'a', - "channel": '40' }) + {"country_code": 'US', + "ssid": 'bss-5ghz', "hw_mode": 'a', + "channel": '40'}) wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200") # GO and peer force the same freq, different than BSS freq, @@ -478,8 +478,8 @@ def test_go_pref_chan_bss_on_diff_chan(dev, apdev): dev[0].global_request("SET p2p_no_group_iface 0") try: - hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz', - "channel": '1' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'bss-2.4ghz', + "channel": '1'}) dev[0].global_request("SET p2p_pref_chan 81:2") dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") res = autogo(dev[0]) @@ -501,8 +501,8 @@ def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev): wpas.global_request("SET p2p_no_group_iface 0") try: - hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz', - "channel": '1' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'bss-2.4ghz', + "channel": '1'}) wpas.global_request("P2P_SET disallow_freq 2412") wpas.global_request("SET p2p_pref_chan 81:2") wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") @@ -580,7 +580,7 @@ def test_p2p_autogo_pref_chan_disallowed(dev, apdev): dev[0].global_request("P2P_SET disallow_freq 2412,2422,2437,2452,2462") for i in range(0, 5): res = autogo(dev[0]) - if res['freq'] in [ "2412", "2422", "2437", "2452", "2462" ]: + if res['freq'] in ["2412", "2422", "2437", "2452", "2462"]: raise Exception("GO channel is disallowed") dev[0].remove_group(res['ifname']) finally: @@ -668,7 +668,7 @@ def test_p2p_listen_chan_optimize(dev, apdev): channel = "1" if lfreq != '2412' else "6" freq = "2412" if lfreq != '2412' else "2437" - params = { "ssid": "test-open", "channel": channel } + params = {"ssid": "test-open", "channel": channel} hapd = hostapd.add_ap(apdev[0], params) id = wpas.connect("test-open", key_mgmt="NONE", scan_freq=freq) @@ -811,15 +811,15 @@ def test_p2p_go_move_active(dev, apdev): if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") - ndev = [ wpas, dev[1] ] + ndev = [wpas, dev[1]] _test_p2p_go_move_active(ndev, apdev) def _test_p2p_go_move_active(dev, apdev): dev[0].global_request("SET p2p_no_group_iface 0") try: dev[0].global_request("P2P_SET disallow_freq 2430-6000") - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test', - "channel" : '11' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test', + "channel": '11'}) dev[0].connect("ap-test", key_mgmt="NONE", scan_freq="2462") @@ -858,15 +858,15 @@ def test_p2p_go_move_scm(dev, apdev): if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") - ndev = [ wpas, dev[1] ] + ndev = [wpas, dev[1]] _test_p2p_go_move_scm(ndev, apdev) def _test_p2p_go_move_scm(dev, apdev): dev[0].global_request("SET p2p_no_group_iface 0") try: dev[0].global_request("P2P_SET disallow_freq 2430-6000") - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test', - "channel" : '11' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test', + "channel": '11'}) dev[0].connect("ap-test", key_mgmt="NONE", scan_freq="2462") @@ -912,7 +912,7 @@ def test_p2p_go_move_scm_peer_supports(dev, apdev): if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") - ndev = [ wpas, dev[1] ] + ndev = [wpas, dev[1]] _test_p2p_go_move_scm_peer_supports(ndev, apdev) def _test_p2p_go_move_scm_peer_supports(dev, apdev): @@ -929,8 +929,8 @@ def _test_p2p_go_move_scm_peer_supports(dev, apdev): if freq < 5000: raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq) - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test', - "channel" : '11' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test', + "channel": '11'}) logger.info('Connecting client to to an AP on channel 11') dev[0].connect("ap-test", key_mgmt="NONE", scan_freq="2462") @@ -960,7 +960,7 @@ def test_p2p_go_move_scm_peer_does_not_support(dev, apdev): if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") - ndev = [ wpas, dev[1] ] + ndev = [wpas, dev[1]] _test_p2p_go_move_scm_peer_does_not_support(ndev, apdev) def _test_p2p_go_move_scm_peer_does_not_support(dev, apdev): @@ -979,8 +979,8 @@ def _test_p2p_go_move_scm_peer_does_not_support(dev, apdev): if freq < 5000: raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq) - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test', - "channel" : '11' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test', + "channel": '11'}) logger.info('Connecting client to to an AP on channel 11') dev[0].connect("ap-test", key_mgmt="NONE", scan_freq="2462") @@ -1006,15 +1006,15 @@ def test_p2p_go_move_scm_multi(dev, apdev): if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") - ndev = [ wpas, dev[1] ] + ndev = [wpas, dev[1]] _test_p2p_go_move_scm_multi(ndev, apdev) def _test_p2p_go_move_scm_multi(dev, apdev): dev[0].request("SET p2p_no_group_iface 0") try: dev[0].global_request("P2P_SET disallow_freq 2430-6000") - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test-1', - "channel" : '11' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test-1', + "channel": '11'}) dev[0].connect("ap-test-1", key_mgmt="NONE", scan_freq="2462") @@ -1046,8 +1046,8 @@ def _test_p2p_go_move_scm_multi(dev, apdev): if freq != '2462': raise Exception("Unexpected freq after group reform=" + freq) - hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test-2', - "channel" : '6' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'ap-test-2', + "channel": '6'}) dev[0].connect("ap-test-2", key_mgmt="NONE", scan_freq="2437") @@ -1087,8 +1087,8 @@ def test_p2p_delay_go_csa(dev, apdev, params): raise Exception("Peer " + addr1 + " not found") wpas.p2p_stop_find() - hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz', - "channel": '1' }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'bss-2.4ghz', + "channel": '1'}) wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412") diff --git a/tests/hwsim/test_p2p_concurrency.py b/tests/hwsim/test_p2p_concurrency.py index 81545cc32..8adf32798 100644 --- a/tests/hwsim/test_p2p_concurrency.py +++ b/tests/hwsim/test_p2p_concurrency.py @@ -21,7 +21,7 @@ def test_concurrent_autogo(dev, apdev): """Concurrent P2P autonomous GO""" logger.info("Connect to an infrastructure AP") dev[0].request("P2P_SET cross_connect 0") - 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") hwsim_utils.test_connectivity(dev[0], hapd) @@ -45,17 +45,17 @@ def test_concurrent_autogo_5ghz_ht40(dev, apdev): try: hapd = None hapd2 = None - params = { "ssid": "ht40", - "hw_mode": "a", - "channel": "153", - "country_code": "US", - "ht_capab": "[HT40-]" } + params = {"ssid": "ht40", + "hw_mode": "a", + "channel": "153", + "country_code": "US", + "ht_capab": "[HT40-]"} hapd2 = hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-open-5", - "hw_mode": "a", - "channel": "149", - "country_code": "US" } + params = {"ssid": "test-open-5", + "hw_mode": "a", + "channel": "149", + "country_code": "US"} hapd = hostapd.add_ap(apdev[0], params) dev[0].request("P2P_SET cross_connect 0") @@ -98,7 +98,7 @@ def test_concurrent_autogo_5ghz_ht40(dev, apdev): def test_concurrent_autogo_crossconnect(dev, apdev): """Concurrent P2P autonomous GO""" dev[0].global_request("P2P_SET cross_connect 1") - 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[0].global_request("SET p2p_no_group_iface 0") @@ -136,7 +136,7 @@ def test_concurrent_autogo_crossconnect(dev, apdev): def test_concurrent_p2pcli(dev, apdev): """Concurrent P2P client join""" logger.info("Connect to an infrastructure AP") - 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") hwsim_utils.test_connectivity(dev[0], hapd) @@ -158,7 +158,7 @@ def test_concurrent_p2pcli(dev, apdev): def test_concurrent_grpform_go(dev, apdev): """Concurrent P2P group formation to become GO""" logger.info("Connect to an infrastructure AP") - 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") hwsim_utils.test_connectivity(dev[0], hapd) @@ -177,7 +177,7 @@ def test_concurrent_grpform_go(dev, apdev): def test_concurrent_grpform_cli(dev, apdev): """Concurrent P2P group formation to become P2P Client""" logger.info("Connect to an infrastructure AP") - 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") hwsim_utils.test_connectivity(dev[0], hapd) @@ -196,7 +196,7 @@ def test_concurrent_grpform_cli(dev, apdev): def test_concurrent_grpform_while_connecting(dev, apdev): """Concurrent P2P group formation while connecting to an AP""" 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"}) dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False) logger.info("Form a P2P group while connecting to an AP") @@ -214,7 +214,7 @@ def test_concurrent_grpform_while_connecting(dev, apdev): def test_concurrent_grpform_while_connecting2(dev, apdev): """Concurrent P2P group formation while connecting to an AP (2)""" 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"}) dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False) dev[1].flush_scan_cache() @@ -234,7 +234,7 @@ def test_concurrent_grpform_while_connecting2(dev, apdev): def test_concurrent_grpform_while_connecting3(dev, apdev): """Concurrent P2P group formation while connecting to an AP (3)""" 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"}) dev[0].connect("test-open", key_mgmt="NONE", wait_connect=False) logger.info("Form a P2P group while connecting to an AP") @@ -253,7 +253,7 @@ def test_concurrent_grpform_while_connecting3(dev, apdev): def test_concurrent_persistent_group(dev, apdev): """Concurrent P2P persistent group""" logger.info("Connect to an infrastructure AP") - hostapd.add_ap(apdev[0], { "ssid": "test-open", "channel": "2" }) + hostapd.add_ap(apdev[0], {"ssid": "test-open", "channel": "2"}) dev[0].global_request("SET p2p_no_group_iface 0") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417") @@ -276,7 +276,7 @@ def test_concurrent_invitation_channel_mismatch(dev, apdev): dev[1].dump_monitor() logger.info("Connect to an infrastructure AP") - hostapd.add_ap(apdev[0], { "ssid": "test-open", "channel": "2" }) + hostapd.add_ap(apdev[0], {"ssid": "test-open", "channel": "2"}) dev[0].global_request("SET p2p_no_group_iface 0") dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2417") invite(dev[1], dev[0], extra="freq=2412") diff --git a/tests/hwsim/test_p2p_device.py b/tests/hwsim/test_p2p_device.py index bd2a7633c..ed781d5c5 100644 --- a/tests/hwsim/test_p2p_device.py +++ b/tests/hwsim/test_p2p_device.py @@ -35,7 +35,7 @@ def test_p2p_device_grpform(dev, apdev): found = False for l in lines: try: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) if name == "wdev_id": found = True break @@ -169,7 +169,7 @@ def run_p2p_device_nfc_invite(dev, apdev, no_group_iface): def test_p2p_device_misuses(dev, apdev): """cfg80211 P2P Device misuses""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) @@ -214,7 +214,7 @@ def test_p2p_device_misuses(dev, apdev): time.sleep(1) hwsim_utils.test_connectivity(wpas, hapd) - ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=0.1) + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=0.1) if ev is not None: raise Exception("Unexpected disconnection event received from hostapd") ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.1) diff --git a/tests/hwsim/test_p2p_discovery.py b/tests/hwsim/test_p2p_discovery.py index b94dc69a8..5ef4f8f3d 100644 --- a/tests/hwsim/test_p2p_discovery.py +++ b/tests/hwsim/test_p2p_discovery.py @@ -492,11 +492,11 @@ def test_p2p_peer_command(dev): res0 = dev[0].request("P2P_PEER FIRST") peer = res0.splitlines()[0] - if peer not in [ addr1, addr2 ]: + if peer not in [addr1, addr2]: raise Exception("Unexpected P2P_PEER FIRST address") res1 = dev[0].request("P2P_PEER NEXT-" + peer) peer2 = res1.splitlines()[0] - if peer2 not in [ addr1, addr2 ] or peer == peer2: + if peer2 not in [addr1, addr2] or peer == peer2: raise Exception("Unexpected P2P_PEER NEXT address") if "FAIL" not in dev[0].request("P2P_PEER NEXT-foo"): @@ -679,7 +679,7 @@ def run_discovery_while_go(wpas, dev, params): terminate_group(wpas, dev[1]) out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), - "wifi_p2p.public_action.subtype == 8", [ "wlan.da" ]) + "wifi_p2p.public_action.subtype == 8", ["wlan.da"]) da = out.splitlines() logger.info("PD Response DAs: " + str(da)) if len(da) != 3: @@ -714,7 +714,7 @@ def run_discovery_while_cli(wpas, dev, params): terminate_group(dev[1], wpas) out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), - "wifi_p2p.public_action.subtype == 8", [ "wlan.da" ]) + "wifi_p2p.public_action.subtype == 8", ["wlan.da"]) da = out.splitlines() logger.info("PD Response DAs: " + str(da)) if len(da) != 3: diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index df13b19c3..41104d515 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -648,7 +648,7 @@ def clear_pbc_overlap(dev, ap): @remote_compatible def test_grpform_pbc_overlap(dev, apdev): """P2P group formation during PBC overlap""" - 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) hapd.request("WPS_PBC") time.sleep(0.1) @@ -688,8 +688,8 @@ def test_grpform_pbc_overlap_group_iface(dev, apdev): """P2P group formation during PBC overlap using group interfaces""" # Note: Need to include P2P IE from the AP to get the P2P interface BSS # update use this information. - params = { "ssid": "wps", "eap_server": "1", "wps_state": "1", - "beacon_int": "15", 'manage_p2p': '1' } + params = {"ssid": "wps", "eap_server": "1", "wps_state": "1", + "beacon_int": "15", 'manage_p2p': '1'} hapd = hostapd.add_ap(apdev[0], params) hapd.request("WPS_PBC") @@ -877,14 +877,14 @@ def test_grpform_wait_peer(dev): def test_invalid_p2p_connect_command(dev): """P2P_CONNECT error cases""" id = dev[0].add_network() - for cmd in [ "foo", - "00:11:22:33:44:55", - "00:11:22:33:44:55 pbc persistent=123", - "00:11:22:33:44:55 pbc persistent=%d" % id, - "00:11:22:33:44:55 pbc go_intent=-1", - "00:11:22:33:44:55 pbc go_intent=16", - "00:11:22:33:44:55 pin", - "00:11:22:33:44:55 pbc freq=0" ]: + for cmd in ["foo", + "00:11:22:33:44:55", + "00:11:22:33:44:55 pbc persistent=123", + "00:11:22:33:44:55 pbc persistent=%d" % id, + "00:11:22:33:44:55 pbc go_intent=-1", + "00:11:22:33:44:55 pbc go_intent=16", + "00:11:22:33:44:55 pin", + "00:11:22:33:44:55 pbc freq=0"]: if "FAIL" not in dev[0].request("P2P_CONNECT " + cmd): raise Exception("Invalid P2P_CONNECT command accepted: " + cmd) diff --git a/tests/hwsim/test_p2p_invitation.py b/tests/hwsim/test_p2p_invitation.py index e3e9c020b..1e84af29d 100644 --- a/tests/hwsim/test_p2p_invitation.py +++ b/tests/hwsim/test_p2p_invitation.py @@ -184,12 +184,12 @@ def test_p2p_cli_invite(dev): def test_p2p_invite_invalid(dev): """Invalid parameters to P2P_INVITE""" id = dev[0].add_network() - for cmd in [ "foo=bar", - "persistent=123 peer=foo", - "persistent=123", - "persistent=%d" % id, - "group=foo", - "group=foo peer=foo", - "group=foo peer=00:11:22:33:44:55 go_dev_addr=foo" ]: + for cmd in ["foo=bar", + "persistent=123 peer=foo", + "persistent=123", + "persistent=%d" % id, + "group=foo", + "group=foo peer=foo", + "group=foo peer=00:11:22:33:44:55 go_dev_addr=foo"]: if "FAIL" not in dev[0].request("P2P_INVITE " + cmd): raise Exception("Invalid P2P_INVITE accepted: " + cmd) diff --git a/tests/hwsim/test_p2p_messages.py b/tests/hwsim/test_p2p_messages.py index 943fdd514..a4cac698b 100644 --- a/tests/hwsim/test_p2p_messages.py +++ b/tests/hwsim/test_p2p_messages.py @@ -43,7 +43,7 @@ def p2p_attr_capability(dev_capab=0, group_capab=0): return struct.pack("H", config_methods) + struct.pack("8BB", *t2) + struct.pack('>HH', 0x1011, len(name)) + name.encode() def p2p_attr_group_id(addr, ssid): - val = struct.unpack('6B', binascii.unhexlify(addr.replace(':',''))) + val = struct.unpack('6B', binascii.unhexlify(addr.replace(':', ''))) t = (P2P_ATTR_GROUP_ID, 6 + len(ssid)) + val return struct.pack(' 2: - (id,elen) = struct.unpack('BB', pos[0:2]) + (id, elen) = struct.unpack('BB', pos[0:2]) pos = pos[2:] if elen > len(pos): raise Exception("Truncated IE in P2P Public Action frame (elen=%d left=%d)" % (elen, len(pos))) if id == WLAN_EID_VENDOR_SPECIFIC: if elen < 4: raise Exception("Too short vendor specific IE in P2P Public Action frame (elen=%d)" % elen) - (oui1,oui2,oui3,subtype) = struct.unpack('BBBB', pos[0:4]) + (oui1, oui2, oui3, subtype) = struct.unpack('BBBB', pos[0:4]) if oui1 == 0x50 and oui2 == 0x6f and oui3 == 0x9a and subtype == 9: if 'p2p' in p2p: p2p['p2p'] += pos[4:elen] @@ -196,7 +196,7 @@ def parse_p2p_public_action(payload): p2p['p2p_attrs'] = {} pos = p2p['p2p'] while len(pos) >= 3: - (id,alen) = struct.unpack(' len(pos): logger.info("P2P payload: " + binascii.hexlify(p2p['p2p'])) @@ -210,7 +210,7 @@ def parse_p2p_public_action(payload): p2p['wsc_attrs'] = {} pos = p2p['wsc'] while len(pos) >= 4: - (id,alen) = struct.unpack('>HH', pos[0:4]) + (id, alen) = struct.unpack('>HH', pos[0:4]) pos = pos[4:] if alen > len(pos): logger.info("WSC payload: " + binascii.hexlify(p2p['wsc'])) @@ -1955,13 +1955,13 @@ def test_p2p_msg_group_info(dev): dev[0].request("VENDOR_ELEM_REMOVE 2 *") def _test_p2p_msg_group_info(dev): - tests = [ "dd08506f9a090e010001", - "dd08506f9a090e010000", - "dd20506f9a090e190018" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "ff", - "dd20506f9a090e190018" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00", - "dd24506f9a090e1d001c" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00" + "00000000", - "dd24506f9a090e1d001c" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00" + "10110001", - "dd24506f9a090e1d001c" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00" + "1011ffff" ] + tests = ["dd08506f9a090e010001", + "dd08506f9a090e010000", + "dd20506f9a090e190018" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "ff", + "dd20506f9a090e190018" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00", + "dd24506f9a090e1d001c" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00" + "00000000", + "dd24506f9a090e1d001c" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00" + "10110001", + "dd24506f9a090e1d001c" + "112233445566" + "aabbccddeeff" + "00" + "0000" + "0000000000000000" + "00" + "1011ffff"] for t in tests: dev[0].request("VENDOR_ELEM_REMOVE 2 *") if "OK" not in dev[0].request("VENDOR_ELEM_ADD 2 " + t): diff --git a/tests/hwsim/test_p2p_persistent.py b/tests/hwsim/test_p2p_persistent.py index 673fda3dd..fa3648ab3 100644 --- a/tests/hwsim/test_p2p_persistent.py +++ b/tests/hwsim/test_p2p_persistent.py @@ -89,7 +89,7 @@ def test_persistent_group_per_sta_psk(dev): logger.info("Join another client to the group") pin = dev[2].wps_read_pin() dev[0].p2p_go_authorize_client(pin) - social = int(i_res['freq']) in [ 2412, 2437, 2462 ] + social = int(i_res['freq']) in [2412, 2437, 2462] c_res = dev[2].p2p_connect_group(addr0, pin, timeout=60, social=social, freq=i_res['freq']) if not c_res['persistent']: @@ -152,7 +152,8 @@ def test_persistent_group_per_sta_psk(dev): dev[2].dump_monitor() peer = dev[2].get_peer(addr0) dev[2].global_request("P2P_GROUP_ADD persistent=" + peer['persistent'] + " freq=2412") - ev = dev[2].wait_global_event(["P2P-GROUP-STARTED","WPA: 4-Way Handshake failed"], timeout=30) + ev = dev[2].wait_global_event(["P2P-GROUP-STARTED", + "WPA: 4-Way Handshake failed"], timeout=30) if ev is None: raise Exception("Timeout on group restart (on client)") if "P2P-GROUP-STARTED" not in ev: @@ -168,7 +169,8 @@ def test_persistent_group_per_sta_psk(dev): dev[2].dump_monitor() peer = dev[2].get_peer(addr0) dev[2].global_request("P2P_GROUP_ADD persistent=" + peer['persistent'] + " freq=2412") - ev = dev[2].wait_global_event(["P2P-GROUP-STARTED","WPA: 4-Way Handshake failed"], timeout=30) + ev = dev[2].wait_global_event(["P2P-GROUP-STARTED", + "WPA: 4-Way Handshake failed"], timeout=30) if ev is None: raise Exception("Timeout on group restart (on client)") if "P2P-GROUP-STARTED" in ev: @@ -192,7 +194,8 @@ def test_persistent_group_per_sta_psk(dev): dev[1].global_request("P2P_INVITE persistent=" + peer['persistent'] + " peer=" + addr0) ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=30) dev[0].group_form_result(ev) - ev = dev[1].wait_global_event(["P2P-GROUP-STARTED","WPA: 4-Way Handshake failed"], timeout=30) + ev = dev[1].wait_global_event(["P2P-GROUP-STARTED", + "WPA: 4-Way Handshake failed"], timeout=30) if ev is None: raise Exception("Timeout on group restart (on client)") if "P2P-GROUP-STARTED" in ev: @@ -228,12 +231,12 @@ def test_persistent_group_invite_removed_client(dev): raise Exception("Timeout on invitation") if "sa=" + addr0 + " persistent=" not in ev: raise Exception("Unexpected invitation event") - [event,addr,persistent] = ev.split(' ', 2) + [event, addr, persistent] = ev.split(' ', 2) dev[1].global_request("P2P_GROUP_ADD " + persistent) ev = dev[1].wait_global_event(["P2P-PERSISTENT-PSK-FAIL"], timeout=30) if ev is None: raise Exception("Did not receive PSK failure report") - [tmp,id] = ev.split('=', 1) + [tmp, id] = ev.split('=', 1) ev = dev[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout=10) if ev is None: raise Exception("Group removal event timed out") @@ -533,8 +536,8 @@ def test_persistent_group_missed_inv_resp(dev): dev[1].p2p_stop_find() # Verify that group re-invocation goes through - ev = dev[1].wait_global_event([ "P2P-GROUP-STARTED", - "P2P-GROUP-FORMATION-FAILURE" ], + ev = dev[1].wait_global_event(["P2P-GROUP-STARTED", + "P2P-GROUP-FORMATION-FAILURE"], timeout=20) if ev is None: raise Exception("Group start event timed out") @@ -542,7 +545,7 @@ def test_persistent_group_missed_inv_resp(dev): raise Exception("Group re-invocation failed") dev[0].group_form_result(ev) - ev = dev[0].wait_global_event([ "P2P-GROUP-STARTED" ], timeout=5) + ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5) if ev is None: raise Exception("Group start event timed out on GO") dev[0].group_form_result(ev) @@ -552,7 +555,7 @@ def test_persistent_group_missed_inv_resp(dev): @remote_compatible def test_persistent_group_profile_add(dev): """Create a P2P persistent group with ADD_NETWORK""" - passphrase="passphrase here" + passphrase = "passphrase here" id = dev[0].p2pdev_add_network() dev[0].p2pdev_set_network_quoted(id, "ssid", "DIRECT-ab") dev[0].p2pdev_set_network_quoted(id, "psk", passphrase) diff --git a/tests/hwsim/test_p2p_service.py b/tests/hwsim/test_p2p_service.py index 178e74e64..a3891c323 100644 --- a/tests/hwsim/test_p2p_service.py +++ b/tests/hwsim/test_p2p_service.py @@ -93,26 +93,26 @@ def run_sd(dev, dst, query, exp_query=None, fragment=False, query2=None): def test_p2p_service_discovery(dev): """P2P service discovery""" addr0 = dev[0].p2p_dev_addr() - for dst in [ "00:00:00:00:00:00", addr0 ]: + for dst in ["00:00:00:00:00:00", addr0]: ev = run_sd(dev, dst, "02000001") if "0b5f6166706f766572746370c00c000c01" not in ev: raise Exception("Unexpected service discovery response contents (Bonjour)") if "496e7465726e6574" not in ev: raise Exception("Unexpected service discovery response contents (UPnP)") - for req in [ "foo 02000001", - addr0, - addr0 + " upnp qq urn:schemas-upnp-org:device:InternetGatewayDevice:1", - addr0 + " upnp 10", - addr0 + " 123", - addr0 + " qq" ]: + for req in ["foo 02000001", + addr0, + addr0 + " upnp qq urn:schemas-upnp-org:device:InternetGatewayDevice:1", + addr0 + " upnp 10", + addr0 + " 123", + addr0 + " qq"]: if "FAIL" not in dev[1].global_request("P2P_SERV_DISC_REQ " + req): raise Exception("Invalid P2P_SERV_DISC_REQ accepted: " + req) def test_p2p_service_discovery2(dev): """P2P service discovery with one peer having no services""" dev[2].p2p_listen() - for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: + for dst in ["00:00:00:00:00:00", dev[0].p2p_dev_addr()]: ev = run_sd(dev, dst, "02000001") if "0b5f6166706f766572746370c00c000c01" not in ev: raise Exception("Unexpected service discovery response contents (Bonjour)") @@ -122,7 +122,7 @@ def test_p2p_service_discovery2(dev): def test_p2p_service_discovery3(dev): """P2P service discovery for Bonjour with one peer having no services""" dev[2].p2p_listen() - for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: + for dst in ["00:00:00:00:00:00", dev[0].p2p_dev_addr()]: ev = run_sd(dev, dst, "02000101") if "0b5f6166706f766572746370c00c000c01" not in ev: raise Exception("Unexpected service discovery response contents (Bonjour)") @@ -130,7 +130,7 @@ def test_p2p_service_discovery3(dev): def test_p2p_service_discovery4(dev): """P2P service discovery for UPnP with one peer having no services""" dev[2].p2p_listen() - for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: + for dst in ["00:00:00:00:00:00", dev[0].p2p_dev_addr()]: ev = run_sd(dev, dst, "02000201") if "496e7465726e6574" not in ev: raise Exception("Unexpected service discovery response contents (UPnP)") @@ -138,7 +138,7 @@ def test_p2p_service_discovery4(dev): @remote_compatible def test_p2p_service_discovery_multiple_queries(dev): """P2P service discovery with multiple queries""" - for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: + for dst in ["00:00:00:00:00:00", dev[0].p2p_dev_addr()]: ev = run_sd(dev, dst, "02000201", query2="02000101") if "0b5f6166706f766572746370c00c000c01" not in ev[0] + ev[1]: raise Exception("Unexpected service discovery response contents (Bonjour)") @@ -148,7 +148,7 @@ def test_p2p_service_discovery_multiple_queries(dev): def test_p2p_service_discovery_multiple_queries2(dev): """P2P service discovery with multiple queries with one peer having no services""" dev[2].p2p_listen() - for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: + for dst in ["00:00:00:00:00:00", dev[0].p2p_dev_addr()]: ev = run_sd(dev, dst, "02000201", query2="02000101") if "0b5f6166706f766572746370c00c000c01" not in ev[0] + ev[1]: raise Exception("Unexpected service discovery response contents (Bonjour)") @@ -157,7 +157,7 @@ def test_p2p_service_discovery_multiple_queries2(dev): def test_p2p_service_discovery_fragmentation(dev): """P2P service discovery with fragmentation""" - for dst in [ "00:00:00:00:00:00", dev[0].p2p_dev_addr() ]: + for dst in ["00:00:00:00:00:00", dev[0].p2p_dev_addr()]: ev = run_sd(dev, dst, "02000001", fragment=True) if "long response" not in ev: if "0b5f6166706f766572746370c00c000c01" not in ev: @@ -391,13 +391,13 @@ def _test_p2p_service_discovery_external(dev): if ver == ver2: raise Exception("Service list version did not change") - for cmd in [ "%s%s%s%s" % (arg[2], arg[3], arg[4], resp), - "%s %s %s %s" % ("0", arg[3], arg[4], resp), - "%s %s %s %s" % (arg[2], "foo", arg[4], resp), - "%s %s%s%s" % (arg[2], arg[3], arg[4], resp), - "%s %s %s%s" % (arg[2], arg[3], arg[4], resp), - "%s %s %s %s" % (arg[2], arg[3], arg[4], "12345"), - "%s %s %s %s" % (arg[2], arg[3], arg[4], "qq") ]: + for cmd in ["%s%s%s%s" % (arg[2], arg[3], arg[4], resp), + "%s %s %s %s" % ("0", arg[3], arg[4], resp), + "%s %s %s %s" % (arg[2], "foo", arg[4], resp), + "%s %s%s%s" % (arg[2], arg[3], arg[4], resp), + "%s %s %s%s" % (arg[2], arg[3], arg[4], resp), + "%s %s %s %s" % (arg[2], arg[3], arg[4], "12345"), + "%s %s %s %s" % (arg[2], arg[3], arg[4], "qq")]: if "FAIL" not in dev[0].global_request("P2P_SERV_DISC_RESP " + cmd): raise Exception("Invalid P2P_SERV_DISC_RESP accepted: " + cmd) @@ -412,25 +412,25 @@ def test_p2p_service_discovery_external(dev): @remote_compatible def test_p2p_service_discovery_invalid_commands(dev): """P2P service discovery invalid commands""" - for cmd in [ "bonjour", - "bonjour 12", - "bonjour 123 12", - "bonjour qq 12", - "bonjour 12 123", - "bonjour 12 qq", - "upnp 10", - "upnp qq uuid:", - "foo bar" ]: + for cmd in ["bonjour", + "bonjour 12", + "bonjour 123 12", + "bonjour qq 12", + "bonjour 12 123", + "bonjour 12 qq", + "upnp 10", + "upnp qq uuid:", + "foo bar"]: if "FAIL" not in dev[0].global_request("P2P_SERVICE_ADD " + cmd): raise Exception("Invalid P2P_SERVICE_ADD accepted: " + cmd) - for cmd in [ "bonjour", - "bonjour 123", - "bonjour qq", - "upnp 10", - "upnp ", - "upnp qq uuid:", - "foo bar" ]: + for cmd in ["bonjour", + "bonjour 123", + "bonjour qq", + "upnp 10", + "upnp ", + "upnp qq uuid:", + "foo bar"]: if "FAIL" not in dev[0].global_request("P2P_SERVICE_DEL " + cmd): raise Exception("Invalid P2P_SERVICE_DEL accepted: " + cmd) diff --git a/tests/hwsim/test_p2p_set.py b/tests/hwsim/test_p2p_set.py index 0bdc859b1..58577994e 100644 --- a/tests/hwsim/test_p2p_set.py +++ b/tests/hwsim/test_p2p_set.py @@ -8,31 +8,31 @@ from remotehost import remote_compatible def test_p2p_set(dev): """P2P_SET commands""" - for cmd in [ "", - "foo bar", - "noa 1", - "noa 1,2", - "noa 1,2,3", - "noa -1,0,0", - "noa 256,0,0", - "noa 0,-1,0", - "noa 0,0,-1", - "noa 0,0,1", - "noa 255,10,20", - "ps 2", - "oppps 1", - "ctwindow 1", - "conc_pref foo", - "peer_filter foo", - "client_apsd 0", - "client_apsd 0,0", - "client_apsd 0,0,0", - "disc_int 1", - "disc_int 1 2", - "disc_int 2 1 10", - "disc_int -1 0 10", - "disc_int 0 -1 10", - "ssid_postfix 123456789012345678901234" ]: + for cmd in ["", + "foo bar", + "noa 1", + "noa 1,2", + "noa 1,2,3", + "noa -1,0,0", + "noa 256,0,0", + "noa 0,-1,0", + "noa 0,0,-1", + "noa 0,0,1", + "noa 255,10,20", + "ps 2", + "oppps 1", + "ctwindow 1", + "conc_pref foo", + "peer_filter foo", + "client_apsd 0", + "client_apsd 0,0", + "client_apsd 0,0,0", + "disc_int 1", + "disc_int 1 2", + "disc_int 2 1 10", + "disc_int -1 0 10", + "disc_int 0 -1 10", + "ssid_postfix 123456789012345678901234"]: if "FAIL" not in dev[0].request("P2P_SET " + cmd): raise Exception("Invalid P2P_SET accepted: " + cmd) dev[0].request("P2P_SET ps 1") diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py index e9ab57fe6..1430db1b0 100644 --- a/tests/hwsim/test_p2ps.py +++ b/tests/hwsim/test_p2ps.py @@ -114,7 +114,7 @@ def p2ps_nonexact_seek(i_dev, r_dev, svc_name, srv_info=None, adv_num=None): if r_dev.p2p_dev_addr() not in ev1: raise Exception("Unexpected peer") ev_list = [] - for i in range (0, adv_num): + for i in range(0, adv_num): ev1 = i_dev.wait_global_event(["P2P-SERV-ASP-RESP"], timeout=10) if ev1 is None: raise Exception("Failed to receive Service Discovery Response") @@ -683,14 +683,14 @@ def test_p2ps_service_discovery_multiple_queries(dev): break dev[1].p2p_stop_find() - for test in [ ("seek=org.wi-fi.wfds.display.TX", - "asp_svc=org.wi-fi.wfds.display.tx"), - ("seek=foo seek=org.wi-fi.wfds.display.tx seek=bar", - "asp_svc=org.wi-fi.wfds.display.tx"), - ("seek=1 seek=2 seek=3 seek=org.wi-fi.wfds.display.tx seek=4 seek=5 seek=6", - "asp_svc=org.wi-fi.wfds.display.tx"), - ("seek=not-found", None), - ("seek=org.wi-fi.wfds", "asp_svc=org.wi-fi.wfds")]: + for test in [("seek=org.wi-fi.wfds.display.TX", + "asp_svc=org.wi-fi.wfds.display.tx"), + ("seek=foo seek=org.wi-fi.wfds.display.tx seek=bar", + "asp_svc=org.wi-fi.wfds.display.tx"), + ("seek=1 seek=2 seek=3 seek=org.wi-fi.wfds.display.tx seek=4 seek=5 seek=6", + "asp_svc=org.wi-fi.wfds.display.tx"), + ("seek=not-found", None), + ("seek=org.wi-fi.wfds", "asp_svc=org.wi-fi.wfds")]: dev[2].global_request("P2P_FIND 10 type=social " + test[0]) if test[1] is None: ev = dev[2].wait_global_event(["P2P-DEVICE-FOUND"], timeout=1) @@ -1118,7 +1118,7 @@ def test_p2ps_many_services_in_probe(dev): long3 = 'org.example.0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.c' long4 = 'org.example.0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.d' long5 = 'org.example.0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.e' - for name in [ long1, long2, long3, long4, long5 ]: + for name in [long1, long2, long3, long4, long5]: p2ps_advertise(r_dev=dev[0], r_role='1', svc_name=name, srv_info='I can do stuff') @@ -1136,7 +1136,7 @@ def test_p2ps_many_services_in_probe(dev): events = events + ev dev[1].p2p_stop_find() dev[1].dump_monitor() - for name in [ long2, long3, long4, long5 ]: + for name in [long2, long3, long4, long5]: if name not in events: raise Exception("Service missing from peer events") @@ -1222,7 +1222,7 @@ def test_p2ps_channel_one_connected(dev, apdev): try: hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-2.4ghz', "channel": '7' }) + {"ssid": 'bss-2.4ghz', "channel": '7'}) dev[1].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2442") (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(dev, keep_group=True, join_extra=" freq=2442") @@ -1251,12 +1251,12 @@ def test_p2ps_channel_both_connected_same(dev, apdev): try: hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-2.4ghz', "channel": '6' }) + {"ssid": 'bss-2.4ghz', "channel": '6'}) dev[2].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2437") dev[1].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2437") - tmpdev = [ dev[2], dev[1] ] + tmpdev = [dev[2], dev[1]] (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(tmpdev, keep_group=True, join_extra=" freq=2437", flush=False) freq = dev[2].get_group_status_field('freq') @@ -1282,10 +1282,10 @@ def test_p2ps_channel_both_connected_different(dev, apdev): try: hapd1 = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-3', "channel": '3' }) + {"ssid": 'bss-channel-3', "channel": '3'}) hapd2 = hostapd.add_ap(apdev[1], - { "ssid": 'bss-channel-10', "channel": '10' }) + {"ssid": 'bss-channel-10', "channel": '10'}) dev[0].connect("bss-channel-3", key_mgmt="NONE", scan_freq="2422") dev[1].connect("bss-channel-10", key_mgmt="NONE", scan_freq="2457") @@ -1318,15 +1318,15 @@ def test_p2ps_channel_both_connected_different_mcc(dev, apdev): try: hapd1 = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-3', "channel": '3' }) + {"ssid": 'bss-channel-3', "channel": '3'}) hapd2 = hostapd.add_ap(apdev[1], - { "ssid": 'bss-channel-10', "channel": '10' }) + {"ssid": 'bss-channel-10', "channel": '10'}) wpas.connect("bss-channel-3", key_mgmt="NONE", scan_freq="2422") dev[1].connect("bss-channel-10", key_mgmt="NONE", scan_freq="2457") - (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method([ wpas, dev[1] ], keep_group=True) + (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method([wpas, dev[1]], keep_group=True) freq = wpas.get_group_status_field('freq') if freq != '2422' and freq != '2457': @@ -1380,7 +1380,7 @@ def test_p2ps_channel_sta_connected_disallow_freq(dev, apdev): try: dev[0].global_request("P2P_SET disallow_freq 2437") hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-6', "channel": '6' }) + {"ssid": 'bss-channel-6', "channel": '6'}) dev[1].connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437") @@ -1418,11 +1418,11 @@ def test_p2ps_channel_sta_connected_disallow_freq_mcc(dev, apdev): try: dev[0].global_request("P2P_SET disallow_freq 2437") hapd1 = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-6', "channel": '6' }) + {"ssid": 'bss-channel-6', "channel": '6'}) wpas.connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437") - tmpdev = [ dev[0], wpas ] + tmpdev = [dev[0], wpas] (grp_ifname0, grp_ifname1, ifnames) = p2ps_connect_p2ps_method(tmpdev, keep_group=True) freq = dev[0].get_group_status_field('freq') @@ -1503,7 +1503,7 @@ def test_p2ps_channel_active_go_and_station_same(dev, apdev): dev[1].global_request("P2P_SET listen_channel 11") try: hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-11', "channel": '11' }) + {"ssid": 'bss-channel-11', "channel": '11'}) dev[2].connect("bss-channel-11", key_mgmt="NONE", scan_freq="2462") @@ -1540,7 +1540,7 @@ def test_p2ps_channel_active_go_and_station_different(dev, apdev): try: hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-2', "channel": '2' }) + {"ssid": 'bss-channel-2', "channel": '2'}) dev[0].connect("bss-channel-2", key_mgmt="NONE", scan_freq="2417") @@ -1585,7 +1585,7 @@ def test_p2ps_channel_active_go_and_station_different_mcc(dev, apdev): try: hapd = hostapd.add_ap(apdev[0], - { "ssid": 'bss-channel-6', "channel": '6' }) + {"ssid": 'bss-channel-6', "channel": '6'}) wpas.global_request("P2P_SET listen_channel 1") wpas.connect("bss-channel-6", key_mgmt="NONE", scan_freq="2437") diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py index 5e46c1176..83fec2ce9 100644 --- a/tests/hwsim/test_pmksa_cache.py +++ b/tests/hwsim/test_pmksa_cache.py @@ -353,7 +353,7 @@ def test_pmksa_cache_and_cui(dev, apdev): pmksa = dev[0].get_pmksa(bssid) if pmksa is None: raise Exception("No PMKSA cache entry created") - 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") @@ -616,7 +616,7 @@ def test_pmksa_cache_ap_expiration(dev, apdev): eap="GPSK", identity="gpsk-user-session-timeout", password="abcdefghijklmnop0123456789abcdef", 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") dev[0].request("DISCONNECT") @@ -666,7 +666,7 @@ def test_pmksa_cache_multiple_sta(dev, apdev): bssid2 = apdev[1]['bssid'] logger.info("Roam to AP2") - for sta in [ dev[1], dev[0], dev[2], wpas ]: + for sta in [dev[1], dev[0], dev[2], wpas]: sta.dump_monitor() sta.scan_for_bss(bssid2, freq="2412") if "OK" not in sta.request("ROAM " + bssid2): @@ -678,7 +678,7 @@ def test_pmksa_cache_multiple_sta(dev, apdev): sta.dump_monitor() logger.info("Roam back to AP1") - for sta in [ dev[1], wpas, dev[0], dev[2] ]: + for sta in [dev[1], wpas, dev[0], dev[2]]: sta.dump_monitor() sta.scan(freq="2412") sta.dump_monitor() @@ -689,7 +689,7 @@ def test_pmksa_cache_multiple_sta(dev, apdev): time.sleep(4) logger.info("Roam back to AP2") - for sta in [ dev[1], wpas, dev[0], dev[2] ]: + for sta in [dev[1], wpas, dev[0], dev[2]]: sta.dump_monitor() sta.scan(freq="2412") sta.dump_monitor() @@ -708,7 +708,7 @@ def test_pmksa_cache_opportunistic_multiple_sta(dev, apdev): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.flush_scan_cache() - for sta in [ dev[0], dev[1], dev[2], wpas ]: + for sta in [dev[0], dev[1], dev[2], wpas]: sta.connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk user", password="abcdefghijklmnop0123456789abcdef", okc=True, @@ -718,7 +718,7 @@ def test_pmksa_cache_opportunistic_multiple_sta(dev, apdev): bssid2 = apdev[1]['bssid'] logger.info("Roam to AP2") - for sta in [ dev[2], dev[0], wpas, dev[1] ]: + for sta in [dev[2], dev[0], wpas, dev[1]]: sta.dump_monitor() sta.scan_for_bss(bssid2, freq="2412") if "OK" not in sta.request("ROAM " + bssid2): @@ -735,7 +735,7 @@ def test_pmksa_cache_opportunistic_multiple_sta(dev, apdev): sta.dump_monitor() logger.info("Roam back to AP1") - for sta in [ dev[0], dev[1], dev[2], wpas ]: + for sta in [dev[0], dev[1], dev[2], wpas]: sta.dump_monitor() sta.scan_for_bss(bssid, freq="2412") sta.request("ROAM " + bssid) @@ -772,10 +772,10 @@ def _test_pmksa_cache_preauth_oom(dev, apdev): hapd = hostapd.add_ap(apdev[1], params) bssid1 = apdev[1]['bssid'] - tests = [ (1, "rsn_preauth_receive"), - (2, "rsn_preauth_receive"), - (1, "rsn_preauth_send"), - (1, "wpa_auth_pmksa_add_preauth;rsn_preauth_finished") ] + tests = [(1, "rsn_preauth_receive"), + (2, "rsn_preauth_receive"), + (1, "rsn_preauth_send"), + (1, "wpa_auth_pmksa_add_preauth;rsn_preauth_finished")] for test in tests: hapd.request("DEAUTHENTICATE ff:ff:ff:ff:ff:ff") with alloc_fail(hapd, test[0], test[1]): @@ -1042,25 +1042,25 @@ def test_rsn_preauth_processing(dev, apdev): proto = b"\x88\xc7" tests = [] # RSN: too short pre-auth packet (len=14) - tests += [ _bssid + foreign + proto ] + tests += [_bssid + foreign + proto] # Not EAPOL-Start - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 0, 0, 0) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 0, 0, 0)] # RSN: pre-auth for foreign address 02:03:04:05:06:07 - tests += [ foreign + foreign + proto + struct.pack('>BBH', 0, 0, 0) ] + tests += [foreign + foreign + proto + struct.pack('>BBH', 0, 0, 0)] # RSN: pre-auth for already association STA 02:00:00:00:00:00 - tests += [ _bssid + _addr + proto + struct.pack('>BBH', 0, 0, 0) ] + tests += [_bssid + _addr + proto + struct.pack('>BBH', 0, 0, 0)] # New STA - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 0, 1, 1) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 0, 1, 1)] # IEEE 802.1X: received EAPOL-Start from STA - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 0, 1, 0) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 0, 1, 0)] # frame too short for this IEEE 802.1X packet - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 0, 1, 1) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 0, 1, 1)] # EAPOL-Key - Dropped key data from unauthorized Supplicant - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 2, 3, 0) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 2, 3, 0)] # EAPOL-Encapsulated-ASF-Alert - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 2, 4, 0) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 2, 4, 0)] # unknown IEEE 802.1X packet type - tests += [ _bssid + foreign + proto + struct.pack('>BBH', 2, 255, 0) ] + tests += [_bssid + foreign + proto + struct.pack('>BBH', 2, 255, 0)] for t in tests: sock.send(t) @@ -1096,12 +1096,12 @@ def test_rsn_preauth_local_errors(dev, apdev): sock.send(_bssid + foreign2 + proto + struct.pack('>BBH', 2, 1, 0)) hapd.request("DISABLE") - tests = [ (1, "=rsn_preauth_iface_add"), - (2, "=rsn_preauth_iface_add"), - (1, "l2_packet_init;rsn_preauth_iface_add"), - (1, "rsn_preauth_iface_init"), - (1, "rsn_preauth_iface_init") ] - for count,func in tests: + tests = [(1, "=rsn_preauth_iface_add"), + (2, "=rsn_preauth_iface_add"), + (1, "l2_packet_init;rsn_preauth_iface_add"), + (1, "rsn_preauth_iface_init"), + (1, "rsn_preauth_iface_init")] + for count, func in tests: with alloc_fail(hapd, count, func): if "FAIL" not in hapd.request("ENABLE"): raise Exception("ENABLE succeeded unexpectedly") diff --git a/tests/hwsim/test_radio_work.py b/tests/hwsim/test_radio_work.py index 70fbc2dab..536afba74 100644 --- a/tests/hwsim/test_radio_work.py +++ b/tests/hwsim/test_radio_work.py @@ -104,7 +104,7 @@ def test_radio_work_cancel(dev, apdev): def test_ext_radio_work_disconnect_connect(dev, apdev): """External radio work and DISCONNECT clearing connection attempt""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) dev[0].scan_for_bss(hapd.own_addr(), freq=2412) # Start a radio work to block connection attempt diff --git a/tests/hwsim/test_radius.py b/tests/hwsim/test_radius.py index 1ab343f5a..fba96bdb3 100644 --- a/tests/hwsim/test_radius.py +++ b/tests/hwsim/test_radius.py @@ -166,10 +166,10 @@ def test_radius_acct(dev, apdev): params['acct_server_addr'] = "127.0.0.1" params['acct_server_port'] = "1813" params['acct_server_shared_secret'] = "radius" - params['radius_auth_req_attr'] = [ "126:s:Operator", "77:s:testing", - "62:d:1" ] - params['radius_acct_req_attr'] = [ "126:s:Operator", "62:d:1", - "77:s:testing" ] + params['radius_auth_req_attr'] = ["126:s:Operator", "77:s:testing", + "62:d:1"] + params['radius_acct_req_attr'] = ["126:s:Operator", "62:d:1", + "77:s:testing"] hapd = hostapd.add_ap(apdev[0], params) connect(dev[0], "radius-acct") dev[1].connect("radius-acct", key_mgmt="WPA-EAP", scan_freq="2412", @@ -231,7 +231,7 @@ def test_radius_acct_pmksa_caching(dev, apdev): dev[1].connect("radius-acct", key_mgmt="WPA-EAP", scan_freq="2412", eap="PAX", identity="test-class", password_hex="0123456789abcdef0123456789abcdef") - for d in [ dev[0], dev[1] ]: + for d in [dev[0], dev[1]]: d.request("REASSOCIATE") d.wait_connected(timeout=15, error="Reassociation timed out") @@ -328,13 +328,13 @@ def test_radius_acct_ipaddr(dev, apdev): stderr=open('/dev/null', 'w')) def _test_radius_acct_ipaddr(dev, apdev): - params = { "ssid": "radius-acct-open", - 'acct_server_addr': "127.0.0.1", - 'acct_server_port': "1813", - 'acct_server_shared_secret': "radius", - 'proxy_arp': '1', - 'ap_isolate': '1', - 'bridge': 'ap-br0' } + params = {"ssid": "radius-acct-open", + 'acct_server_addr': "127.0.0.1", + 'acct_server_port': "1813", + 'acct_server_shared_secret': "radius", + 'proxy_arp': '1', + 'ap_isolate': '1', + 'bridge': 'ap-br0'} hapd = hostapd.add_ap(apdev[0], params, no_enable=True) try: hapd.enable() @@ -731,7 +731,7 @@ def add_message_auth_req(req): # request attributes req.AddAttribute("Message-Authenticator", 16*b"\x00") attrs = b'' - for code,datalst in sorted(req.items()): + for code, datalst in sorted(req.items()): for data in datalst: attrs += req._PktEncodeAttribute(code, data) @@ -1508,14 +1508,14 @@ def test_ap_vlan_wpa2_psk_radius_required(dev, apdev): def test_radius_mppe_failure(dev, apdev): """RADIUS failure when adding MPPE keys""" - params = { "ssid": "as", "beacon_int": "2000", - "radius_server_clients": "auth_serv/radius_clients.conf", - "radius_server_auth_port": '18127', - "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" } + params = {"ssid": "as", "beacon_int": "2000", + "radius_server_clients": "auth_serv/radius_clients.conf", + "radius_server_auth_port": '18127', + "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"} authsrv = hostapd.add_ap(apdev[1], params) params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") @@ -1535,26 +1535,26 @@ def test_radius_acct_failure(dev, apdev): """RADIUS Accounting and failure to add attributes""" # Connection goes through, but Accounting-Request cannot be sent out due to # NAS-Identifier being too long to fit into a RADIUS attribute. - params = { "ssid": "radius-acct-open", - 'acct_server_addr': "127.0.0.1", - 'acct_server_port': "1813", - 'acct_server_shared_secret': "radius", - 'nas_identifier': 255*'A' } + params = {"ssid": "radius-acct-open", + 'acct_server_addr': "127.0.0.1", + 'acct_server_port': "1813", + 'acct_server_shared_secret': "radius", + 'nas_identifier': 255*'A'} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("radius-acct-open", key_mgmt="NONE", scan_freq="2412") def test_radius_acct_failure_oom(dev, apdev): """RADIUS Accounting and failure to add attributes due to OOM""" - params = { "ssid": "radius-acct-open", - 'acct_server_addr': "127.0.0.1", - 'acct_server_port': "1813", - 'acct_server_shared_secret': "radius", - 'radius_acct_interim_interval': "1", - 'nas_identifier': 250*'A', - 'radius_acct_req_attr': [ "126:s:" + 250*'B', - "77:s:" + 250*'C', - "127:s:" + 250*'D', - "181:s:" + 250*'E' ] } + params = {"ssid": "radius-acct-open", + 'acct_server_addr': "127.0.0.1", + 'acct_server_port': "1813", + 'acct_server_shared_secret': "radius", + 'radius_acct_interim_interval': "1", + 'nas_identifier': 250*'A', + 'radius_acct_req_attr': ["126:s:" + 250*'B', + "77:s:" + 250*'C', + "127:s:" + 250*'D', + "181:s:" + 250*'E']} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -1572,9 +1572,9 @@ def test_radius_acct_failure_oom(dev, apdev): dev[1].request("REMOVE_NETWORK all") dev[1].wait_disconnected() - tests = [ (1, "radius_msg_add_attr;?radius_msg_add_attr_int32;=accounting_msg"), - (2, "radius_msg_add_attr;accounting_msg"), - (3, "radius_msg_add_attr;accounting_msg") ] + tests = [(1, "radius_msg_add_attr;?radius_msg_add_attr_int32;=accounting_msg"), + (2, "radius_msg_add_attr;accounting_msg"), + (3, "radius_msg_add_attr;accounting_msg")] for count, func in tests: with fail_test(hapd, count, func): dev[0].connect("radius-acct-open", key_mgmt="NONE", @@ -1600,11 +1600,11 @@ def test_radius_acct_failure_oom_rsn(dev, apdev): params['acct_server_port'] = "1813" params['acct_server_shared_secret'] = "radius" params['radius_acct_interim_interval'] = "1" - params['nas_identifier'] = 250*'A' - params['radius_acct_req_attr'] = [ "126:s:" + 250*'B', - "77:s:" + 250*'C', - "127:s:" + 250*'D', - "181:s:" + 250*'E' ] + params['nas_identifier'] = 250*'A' + params['radius_acct_req_attr'] = ["126:s:" + 250*'B', + "77:s:" + 250*'C', + "127:s:" + 250*'D', + "181:s:" + 250*'E'] hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -1631,10 +1631,10 @@ def test_radius_acct_failure_oom_rsn(dev, apdev): def test_radius_acct_failure_sta_data(dev, apdev): """RADIUS Accounting and failure to get STA data""" - params = { "ssid": "radius-acct-open", - 'acct_server_addr': "127.0.0.1", - 'acct_server_port': "1813", - 'acct_server_shared_secret': "radius" } + params = {"ssid": "radius-acct-open", + 'acct_server_addr': "127.0.0.1", + 'acct_server_port': "1813", + 'acct_server_shared_secret': "radius"} hapd = hostapd.add_ap(apdev[0], params) with fail_test(hapd, 1, "accounting_sta_update_stats"): diff --git a/tests/hwsim/test_rfkill.py b/tests/hwsim/test_rfkill.py index 775e2c4c6..560f010e5 100644 --- a/tests/hwsim/test_rfkill.py +++ b/tests/hwsim/test_rfkill.py @@ -30,7 +30,7 @@ def test_rfkill_open(dev, apdev): """rfkill block/unblock during open mode connection""" rfk = get_rfkill(dev[0]) - 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: logger.info("rfkill block") @@ -182,7 +182,7 @@ def test_rfkill_p2p_discovery_p2p_dev(dev, apdev): def test_rfkill_hostapd(dev, apdev): """rfkill block/unblock during and prior to hostapd operations""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) rfk = get_rfkill(hapd) @@ -211,7 +211,7 @@ def test_rfkill_hostapd(dev, apdev): hglobal.flush() hglobal.remove(apdev[0]['ifname']) - hapd = hostapd.add_ap(apdev[0], { "ssid": "open2" }, + hapd = hostapd.add_ap(apdev[0], {"ssid": "open2"}, no_enable=True) if "FAIL" not in hapd.request("ENABLE"): raise Exception("ENABLE succeeded unexpectedly (rfkill)") diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py index 882b434a0..1ee455273 100644 --- a/tests/hwsim/test_rrm.py +++ b/tests/hwsim/test_rrm.py @@ -31,13 +31,13 @@ def check_tx_power_support(dev): if rrm & 0x8 != 0x8: raise HwsimSkip("Required RRM capabilities are not supported") -nr="00112233445500000000510107" -lci="01000800101298c0b512926666f6c2f1001c00004104050000c00012" -civic="01000b0011223344556677889900998877665544332211aabbccddeeff" +nr = "00112233445500000000510107" +lci = "01000800101298c0b512926666f6c2f1001c00004104050000c00012" +civic = "01000b0011223344556677889900998877665544332211aabbccddeeff" def check_nr_results(dev, bssids=None, lci=False, civic=False): if bssids is None: - ev = dev.wait_event(["RRM-NEIGHBOR-REP-REQUEST-FAILED" ], timeout=10) + ev = dev.wait_event(["RRM-NEIGHBOR-REP-REQUEST-FAILED"], timeout=10) if ev is None: raise Exception("RRM neighbor report failure not received") return @@ -65,7 +65,7 @@ def check_nr_results(dev, bssids=None, lci=False, civic=False): def test_rrm_neighbor_db(dev, apdev): """hostapd ctrl_iface SET_NEIGHBOR""" - params = { "ssid": "test", "rrm_neighbor_report": "1" } + params = {"ssid": "test", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) # Bad BSSID @@ -164,13 +164,13 @@ def test_rrm_neighbor_rep_req(dev, apdev): """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST""" check_rrm_support(dev[0]) - nr1="00112233445500000000510107" - nr2="00112233445600000000510107" - nr3="dd112233445500000000510107" + nr1 = "00112233445500000000510107" + nr2 = "00112233445600000000510107" + nr3 = "dd112233445500000000510107" - params = { "ssid": "test" } + params = {"ssid": "test"} hostapd.add_ap(apdev[0]['ifname'], params) - params = { "ssid": "test2", "rrm_neighbor_report": "1" } + params = {"ssid": "test2", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[1]['ifname'], params) bssid1 = apdev[1]['bssid'] @@ -268,11 +268,11 @@ def test_rrm_neighbor_rep_oom(dev, apdev): """hostapd neighbor report OOM""" check_rrm_support(dev[0]) - nr1="00112233445500000000510107" - nr2="00112233445600000000510107" - nr3="dd112233445500000000510107" + nr1 = "00112233445500000000510107" + nr2 = "00112233445600000000510107" + nr3 = "dd112233445500000000510107" - params = { "ssid": "test", "rrm_neighbor_report": "1" } + params = {"ssid": "test", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test", key_mgmt="NONE", scan_freq="2412") @@ -288,7 +288,7 @@ def test_rrm_lci_req(dev, apdev): """hostapd lci request""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) # station not specified @@ -321,7 +321,7 @@ def test_rrm_lci_req_timeout(dev, apdev): """hostapd lci request timeout""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].request("SET LCI " + lci) @@ -352,7 +352,7 @@ def test_rrm_lci_req_oom(dev, apdev): """LCI report generation OOM""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].request("SET LCI " + lci) @@ -375,7 +375,7 @@ def test_rrm_lci_req_ap_oom(dev, apdev): """LCI report generation AP OOM and failure""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].request("SET LCI " + lci) @@ -393,7 +393,7 @@ def test_rrm_lci_req_get_reltime_failure(dev, apdev): """LCI report generation and os_get_reltime() failure""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].request("SET LCI " + lci) @@ -408,8 +408,8 @@ def test_rrm_neighbor_rep_req_from_conf(dev, apdev): """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST and hostapd config""" check_rrm_support(dev[0]) - params = { "ssid": "test2", "rrm_neighbor_report": "1", - "stationary_ap": "1", "lci": lci, "civic": civic } + params = {"ssid": "test2", "rrm_neighbor_report": "1", + "stationary_ap": "1", "lci": lci, "civic": civic} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = apdev[0]['bssid'] @@ -424,8 +424,8 @@ def test_rrm_neighbor_rep_req_timeout(dev, apdev): """wpa_supplicant behavior on NEIGHBOR_REP_REQUEST response timeout""" check_rrm_support(dev[0]) - params = { "ssid": "test2", "rrm_neighbor_report": "1", - "stationary_ap": "1", "lci": lci, "civic": civic } + params = {"ssid": "test2", "rrm_neighbor_report": "1", + "stationary_ap": "1", "lci": lci, "civic": civic} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") @@ -443,8 +443,8 @@ def test_rrm_neighbor_rep_req_oom(dev, apdev): """wpa_supplicant ctrl_iface NEIGHBOR_REP_REQUEST OOM""" check_rrm_support(dev[0]) - params = { "ssid": "test2", "rrm_neighbor_report": "1", - "stationary_ap": "1", "lci": lci, "civic": civic } + params = {"ssid": "test2", "rrm_neighbor_report": "1", + "stationary_ap": "1", "lci": lci, "civic": civic} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") @@ -468,8 +468,8 @@ def test_rrm_neighbor_rep_req_disconnect(dev, apdev): """wpa_supplicant behavior on disconnection during NEIGHBOR_REP_REQUEST""" check_rrm_support(dev[0]) - params = { "ssid": "test2", "rrm_neighbor_report": "1", - "stationary_ap": "1", "lci": lci, "civic": civic } + params = {"ssid": "test2", "rrm_neighbor_report": "1", + "stationary_ap": "1", "lci": lci, "civic": civic} hapd = hostapd.add_ap(apdev[0]['ifname'], params) if "FAIL" not in dev[0].request("NEIGHBOR_REP_REQUEST"): @@ -491,7 +491,7 @@ def test_rrm_neighbor_rep_req_not_supported(dev, apdev): """NEIGHBOR_REP_REQUEST for AP not supporting neighbor report""" check_rrm_support(dev[0]) - params = { "ssid": "test2", "rrm_beacon_report": "1" } + params = {"ssid": "test2", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") @@ -503,8 +503,8 @@ def test_rrm_neighbor_rep_req_busy(dev, apdev): """wpa_supplicant and concurrent NEIGHBOR_REP_REQUEST commands""" check_rrm_support(dev[0]) - params = { "ssid": "test2", "rrm_neighbor_report": "1", - "stationary_ap": "1", "lci": lci, "civic": civic } + params = {"ssid": "test2", "rrm_neighbor_report": "1", + "stationary_ap": "1", "lci": lci, "civic": civic} hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test2", key_mgmt="NONE", scan_freq="2412") @@ -529,7 +529,7 @@ def test_rrm_ftm_range_req(dev, apdev): dev[1].request("VENDOR_ELEM_REMOVE 13 *") def run_rrm_ftm_range_req(dev, apdev): - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -615,7 +615,7 @@ def test_rrm_ftm_range_req_timeout(dev, apdev): dev[1].request("VENDOR_ELEM_REMOVE 13 *") def run_rrm_ftm_range_req_timeout(dev, apdev): - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -655,7 +655,7 @@ def test_rrm_ftm_range_req_failure(dev, apdev): dev[1].request("VENDOR_ELEM_REMOVE 13 *") def run_rrm_ftm_range_req_failure(dev, apdev): - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -683,9 +683,9 @@ def test_rrm_ftm_capa_indication(dev, apdev): dev[0].request("SET ftm_responder 0") def _test_rrm_ftm_capa_indication(dev, apdev): - params = { "ssid": "ftm", - "ftm_responder": "1", - "ftm_initiator": "1", } + params = {"ssid": "ftm", + "ftm_responder": "1", + "ftm_initiator": "1",} hapd = hostapd.add_ap(apdev[0]['ifname'], params) if "OK" not in dev[0].request("SET ftm_initiator 1"): @@ -708,7 +708,7 @@ class BeaconReport: self.frame_body_fragment_id = None self.last_indication = None while len(report) >= 2: - eid,elen = struct.unpack('BB', report[0:2]) + eid, elen = struct.unpack('BB', report[0:2]) report = report[2:] if len(report) < elen: raise Exception("Invalid subelement in beacon report") @@ -757,15 +757,15 @@ def run_req_beacon(hapd, addr, request): @remote_compatible def test_rrm_beacon_req_table(dev, apdev): """Beacon request - beacon table mode""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another"}) - tests = [ "REQ_BEACON ", - "REQ_BEACON q", - "REQ_BEACON 11:22:33:44:55:66 1", - "REQ_BEACON 11:22:33:44:55:66 1q", - "REQ_BEACON 11:22:33:44:55:66 11223344556677889900aabbccddeeff" ] + tests = ["REQ_BEACON ", + "REQ_BEACON q", + "REQ_BEACON 11:22:33:44:55:66 1", + "REQ_BEACON 11:22:33:44:55:66 1q", + "REQ_BEACON 11:22:33:44:55:66 11223344556677889900aabbccddeeff"] for t in tests: if "FAIL" not in hapd.request(t): raise Exception("Invalid command accepted: " + t) @@ -799,7 +799,7 @@ def test_rrm_beacon_req_table(dev, apdev): def test_rrm_beacon_req_frame_body_fragmentation(dev, apdev): """Beacon request - beacon table mode - frame body fragmentation""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) hapd.set('vendor_elements', ("dd051122330203dd0400137400dd04001374ffdd0511" @@ -845,10 +845,10 @@ def test_rrm_beacon_req_frame_body_fragmentation(dev, apdev): def test_rrm_beacon_req_last_frame_indication(dev, apdev): """Beacon request - beacon table mode - last frame indication""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -902,7 +902,7 @@ def test_rrm_beacon_req_last_frame_indication(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_detail(dev, apdev): """Beacon request - beacon table mode - reporting detail""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -965,7 +965,7 @@ def test_rrm_beacon_req_table_detail(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_request(dev, apdev): """Beacon request - beacon table mode - request element""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1008,7 +1008,7 @@ def test_rrm_beacon_req_table_request(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_request_oom(dev, apdev): """Beacon request - beacon table mode - request element OOM""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1051,9 +1051,9 @@ def test_rrm_beacon_req_table_request_oom(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_bssid(dev, apdev): """Beacon request - beacon table mode - specific BSSID""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1075,9 +1075,9 @@ def test_rrm_beacon_req_table_bssid(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_ssid(dev, apdev): """Beacon request - beacon table mode - specific SSID""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1118,7 +1118,7 @@ def test_rrm_beacon_req_table_ssid(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_info(dev, apdev): """Beacon request - beacon table mode - Reporting Information subelement""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1145,7 +1145,7 @@ def test_rrm_beacon_req_table_info(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_unknown_subelem(dev, apdev): """Beacon request - beacon table mode - unknown subelement""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1162,7 +1162,7 @@ def test_rrm_beacon_req_table_unknown_subelem(dev, apdev): @remote_compatible def test_rrm_beacon_req_table_truncated_subelem(dev, apdev): """Beacon request - beacon table mode - Truncated subelement""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1203,29 +1203,29 @@ def test_rrm_beacon_req_table_vht(dev, apdev): clear_scan_cache(apdev[0]) try: hapd = None - params = { "ssid": "rrm-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", - "rrm_beacon_report": "1" } + params = {"ssid": "rrm-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", + "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - params = { "ssid": "test-vht40", - "country_code": "FI", - "hw_mode": "a", - "channel": "48", - "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": "FI", + "hw_mode": "a", + "channel": "48", + "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) dev[0].scan_for_bss(apdev[1]['bssid'], freq=5240) @@ -1262,9 +1262,9 @@ def test_rrm_beacon_req_table_vht(dev, apdev): @remote_compatible def test_rrm_beacon_req_active(dev, apdev): """Beacon request - active scan mode""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1288,11 +1288,11 @@ def test_rrm_beacon_req_active(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_ignore_old_result(dev, apdev): """Beacon request - active scan mode and old scan result""" - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another"}) dev[0].scan_for_bss(apdev[1]['bssid'], freq=2412) hapd2.disable() - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1338,7 +1338,7 @@ def test_rrm_beacon_req_active_many(dev, apdev): start_ap(dev[1]) start_ap(dev[2]) - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} params['vendor_elements'] = "dd50" + 80*'aa' hapd = hostapd.add_ap(apdev[1]['ifname'], params) @@ -1366,9 +1366,9 @@ def test_rrm_beacon_req_active_many(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_ap_channels(dev, apdev): """Beacon request - active scan mode with AP Channel Report subelement""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1392,9 +1392,9 @@ def test_rrm_beacon_req_active_ap_channels(dev, apdev): @remote_compatible def test_rrm_beacon_req_passive_ap_channels(dev, apdev): """Beacon request - passive scan mode with AP Channel Report subelement""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1418,9 +1418,9 @@ def test_rrm_beacon_req_passive_ap_channels(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_single_channel(dev, apdev): """Beacon request - active scan mode with single channel""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1437,9 +1437,9 @@ def test_rrm_beacon_req_active_single_channel(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_ap_channels_unknown_opclass(dev, apdev): """Beacon request - active scan mode with AP Channel Report subelement and unknown opclass""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1457,9 +1457,9 @@ def test_rrm_beacon_req_active_ap_channels_unknown_opclass(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_ap_channel_oom(dev, apdev): """Beacon request - AP Channel Report subelement and OOM""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1477,7 +1477,7 @@ def test_rrm_beacon_req_active_ap_channel_oom(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_scan_fail(dev, apdev): """Beacon request - Active scan failure""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1496,9 +1496,9 @@ def test_rrm_beacon_req_active_scan_fail(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_zero_duration(dev, apdev): """Beacon request - Action scan and zero duration""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1511,7 +1511,7 @@ def test_rrm_beacon_req_active_zero_duration(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_fail_random(dev, apdev): """Beacon request - active scan mode os_get_random failure""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1528,9 +1528,9 @@ def test_rrm_beacon_req_active_fail_random(dev, apdev): @remote_compatible def test_rrm_beacon_req_passive(dev, apdev): """Beacon request - passive scan mode""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "another", "channel": "11" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "another", "channel": "11"}) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") addr = dev[0].own_addr() @@ -1554,7 +1554,7 @@ def test_rrm_beacon_req_passive(dev, apdev): @remote_compatible def test_rrm_beacon_req_passive_no_match(dev, apdev): """Beacon request - passive scan mode and no matching BSS""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1571,7 +1571,7 @@ def test_rrm_beacon_req_passive_no_match(dev, apdev): @remote_compatible def test_rrm_beacon_req_passive_no_match_oom(dev, apdev): """Beacon request - passive scan mode and no matching BSS (OOM)""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1596,7 +1596,7 @@ def test_rrm_beacon_req_passive_no_match_oom(dev, apdev): @remote_compatible def test_rrm_beacon_req_active_duration_mandatory(dev, apdev): """Beacon request - Action scan and duration mandatory""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("rrm", key_mgmt="NONE", scan_freq="2412") @@ -1625,17 +1625,17 @@ def test_rrm_beacon_req_passive_scan_vht(dev, apdev): clear_scan_cache(apdev[0]) try: hapd = None - params = { "ssid": "rrm-vht", - "country_code": "FI", - 'ieee80211d': '1', - "hw_mode": "a", - "channel": "36", - "ht_capab": "[HT40+]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "1", - "vht_oper_centr_freq_seg0_idx": "42", - "rrm_beacon_report": "1" } + params = {"ssid": "rrm-vht", + "country_code": "FI", + 'ieee80211d': '1', + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42", + "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=5180) @@ -1682,17 +1682,17 @@ def test_rrm_beacon_req_passive_scan_vht160(dev, apdev): clear_scan_cache(apdev[0]) try: hapd = None - params = { "ssid": "rrm-vht", - "country_code": "ZA", - 'ieee80211d': '1', - "hw_mode": "a", - "channel": "104", - "ht_capab": "[HT40-]", - "ieee80211n": "1", - "ieee80211ac": "1", - "vht_oper_chwidth": "2", - "vht_oper_centr_freq_seg0_idx": "114", - "rrm_beacon_report": "1" } + params = {"ssid": "rrm-vht", + "country_code": "ZA", + 'ieee80211d': '1', + "hw_mode": "a", + "channel": "104", + "ht_capab": "[HT40-]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "2", + "vht_oper_centr_freq_seg0_idx": "114", + "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].scan_for_bss(apdev[0]['bssid'], freq=5520) @@ -1734,7 +1734,7 @@ def test_rrm_beacon_req_ap_errors(dev, apdev): dev[1].request("VENDOR_ELEM_REMOVE 13 *") def run_rrm_beacon_req_ap_errors(dev, apdev): - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() dev[0].scan_for_bss(bssid, freq=2412) @@ -1781,7 +1781,7 @@ def run_rrm_beacon_req_ap_errors(dev, apdev): def test_rrm_req_reject_oom(dev, apdev): """Radio measurement request - OOM while rejecting a request""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -1804,7 +1804,7 @@ def test_rrm_req_reject_oom(dev, apdev): def test_rrm_req_when_rrm_not_used(dev, apdev): """Radio/link measurement request for non-RRM association""" - params = { "ssid": "rrm" } + params = {"ssid": "rrm"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -1834,7 +1834,7 @@ def test_rrm_req_when_rrm_not_used(dev, apdev): @remote_compatible def test_rrm_req_proto(dev, apdev): """Radio measurement request - protocol testing""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -1849,34 +1849,34 @@ def test_rrm_req_proto(dev, apdev): tests = [] # "RRM: Ignoring too short radio measurement request" - tests += [ "0500", "050001", "05000100" ] + tests += ["0500", "050001", "05000100"] # No measurement request element at all - tests += [ "0500010000" ] + tests += ["0500010000"] # "RRM: Truncated element" - tests += [ "050001000026" ] + tests += ["050001000026"] # "RRM: Element length too short" - tests += [ "05000100002600", "0500010000260111", "050001000026021122" ] + tests += ["05000100002600", "0500010000260111", "050001000026021122"] # "RRM: Element length too long" - tests += [ "05000100002603", "0500010000260311", "050001000026031122" ] + tests += ["05000100002603", "0500010000260311", "050001000026031122"] # "RRM: Enable bit not supported, ignore" - tests += [ "05000100002603010200" ] + tests += ["05000100002603010200"] # "RRM: Measurement report failed. TX power insertion not supported" # OR # "RRM: Link measurement report failed. Request too short" - tests += [ "0502" ] + tests += ["0502"] # Too short LCI request - tests += [ "05000100002603010008" ] + tests += ["05000100002603010008"] # Too short neighbor report response - tests += [ "0505" ] + tests += ["0505"] # Unexpected neighbor report response - tests += [ "050500", "050501", "050502", "050503", "050504", "050505" ] + tests += ["050500", "050501", "050502", "050503", "050504", "050505"] # Too short beacon request - tests += [ "05000100002603010005", - "0500010000260f010005112233445566778899aabbcc" ] + tests += ["05000100002603010005", + "0500010000260f010005112233445566778899aabbcc"] # Unknown beacon report mode - tests += [ "05000100002610010005112233445566778899aabbccdd" ] + tests += ["05000100002610010005112233445566778899aabbccdd"] # "RRM: Expected Measurement Request element, but EID is 0" - tests += [ "05000100000000" ] + tests += ["05000100000000"] for t in tests: if "OK" not in dev[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): raise Exception("MGMT_RX_PROCESS failed") @@ -1886,13 +1886,13 @@ def test_rrm_req_proto(dev, apdev): tests = [] # "RRM: Parallel measurements are not supported, reject" - tests += [ "05000100002603010105" ] + tests += ["05000100002603010105"] # "RRM: Unsupported radio measurement type 254" - tests += [ "050001000026030100fe" ] + tests += ["050001000026030100fe"] # Reject LCI request - tests += [ "0500010000260701000811223344" ] + tests += ["0500010000260701000811223344"] # Beacon report info subelement; no valid channels - tests += [ "05000100002614010005112233445566008899aabbccdd01020000" ] + tests += ["05000100002614010005112233445566008899aabbccdd01020000"] for t in tests: if "OK" not in dev[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): raise Exception("MGMT_RX_PROCESS failed") @@ -1904,7 +1904,7 @@ def test_rrm_req_proto(dev, apdev): dev[0].request("SET LCI " + lci) tests = [] # "Not building LCI report - bad location subject" - tests += [ "0500010000260701000811223344" ] + tests += ["0500010000260701000811223344"] for t in tests: if "OK" not in dev[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): raise Exception("MGMT_RX_PROCESS failed") @@ -1914,9 +1914,9 @@ def test_rrm_req_proto(dev, apdev): tests = [] # LCI report or reject - tests += [ "0500010000260701000801223344", - "05000100002607010008010402ff", - "05000100002608010008010402ffff" ] + tests += ["0500010000260701000801223344", + "05000100002607010008010402ff", + "05000100002608010008010402ffff"] for t in tests: if "OK" not in dev[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): raise Exception("MGMT_RX_PROCESS failed") @@ -1943,7 +1943,7 @@ def test_rrm_req_proto(dev, apdev): def test_rrm_link_measurement(dev, apdev): """Radio measurement request - link measurement""" check_tx_power_support(dev[0]) - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -1964,7 +1964,7 @@ def test_rrm_link_measurement(dev, apdev): def test_rrm_link_measurement_oom(dev, apdev): """Radio measurement request - link measurement OOM""" check_tx_power_support(dev[0]) - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -1994,7 +1994,7 @@ def test_rrm_rep_parse_proto(dev, apdev): """hostapd rrm report parsing protocol testing""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "1" } + params = {"ssid": "rrm", "rrm_neighbor_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -2005,17 +2005,17 @@ def test_rrm_rep_parse_proto(dev, apdev): hdr = "d0003a01" + bssid.replace(':', '') + addr.replace(':', '') + bssid.replace(':', '') + "1000" hapd.set("ext_mgmt_frame_handling", "1") - tests = [ "0501", - "05ff01", - "0501012703fffffe2700", - "0501012703ffff05", - "05010127ffffff05" + 252*"00", - "0504012603ffffff2600", - "0504012603ffff08", - "0504012608ffff08ffffffffff", - "0504012608ffff08ff04021234", - "0504012608ffff08ff04020100", - "0504012608ffff08ff0402ffff" ] + tests = ["0501", + "05ff01", + "0501012703fffffe2700", + "0501012703ffff05", + "05010127ffffff05" + 252*"00", + "0504012603ffffff2600", + "0504012603ffff08", + "0504012608ffff08ffffffffff", + "0504012608ffff08ff04021234", + "0504012608ffff08ff04020100", + "0504012608ffff08ff0402ffff"] for t in tests: if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): raise Exception("MGMT_RX_PROCESS failed for " + t) @@ -2029,7 +2029,7 @@ def test_rrm_unexpected(dev, apdev): """hostapd unexpected rrm""" check_rrm_support(dev[0]) - params = { "ssid": "rrm", "rrm_neighbor_report": "0" } + params = {"ssid": "rrm", "rrm_neighbor_report": "0"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() @@ -2039,7 +2039,7 @@ def test_rrm_unexpected(dev, apdev): hdr = "d0003a01" + bssid.replace(':', '') + addr.replace(':', '') + bssid.replace(':', '') + "1000" hapd.set("ext_mgmt_frame_handling", "1") - tests = [ "050401" ] + tests = ["050401"] for t in tests: if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + hdr + t): raise Exception("MGMT_RX_PROCESS failed for " + t) @@ -2055,7 +2055,7 @@ def check_beacon_req(hapd, addr, idx): def test_rrm_reassociation(dev, apdev): """Radio measurement request - reassociation""" - params = { "ssid": "rrm", "rrm_beacon_report": "1" } + params = {"ssid": "rrm", "rrm_beacon_report": "1"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) bssid = hapd.own_addr() diff --git a/tests/hwsim/test_sae.py b/tests/hwsim/test_sae.py index ca0add280..3bd13a844 100644 --- a/tests/hwsim/test_sae.py +++ b/tests/hwsim/test_sae.py @@ -102,7 +102,7 @@ def test_sae_pmksa_caching(dev, apdev): dev[0].request("SET sae_groups ") dev[0].connect("test-sae", psk="12345678", key_mgmt="SAE", 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") dev[0].request("DISCONNECT") @@ -126,7 +126,7 @@ def test_sae_pmksa_caching_disabled(dev, apdev): dev[0].request("SET sae_groups ") dev[0].connect("test-sae", psk="12345678", key_mgmt="SAE", 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") dev[0].request("DISCONNECT") @@ -144,12 +144,12 @@ def test_sae_groups(dev, apdev): # MODP) and group 21 (521-bit random ECP group) are a bit too slow on some # VMs and can result in hitting the mac80211 authentication timeout, so # allow them to fail and just report such failures in the debug log. - sae_groups = [ 19, 25, 26, 20, 21, 1, 2, 5, 14, 15, 16, 22, 23, 24 ] + sae_groups = [19, 25, 26, 20, 21, 1, 2, 5, 14, 15, 16, 22, 23, 24] tls = dev[0].request("GET tls_library") if tls.startswith("OpenSSL") and "run=OpenSSL 1." in tls: logger.info("Add Brainpool EC groups since OpenSSL is new enough") - sae_groups += [ 27, 28, 29, 30 ] - heavy_groups = [ 14, 15, 16 ] + sae_groups += [27, 28, 29, 30] + heavy_groups = [14, 15, 16] groups = [str(g) for g in sae_groups] params = hostapd.wpa2_params(ssid="test-sae-groups", passphrase="12345678") @@ -174,7 +174,7 @@ def test_sae_groups(dev, apdev): else: ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10) if ev is None: - if "BoringSSL" in tls and int(g) in [ 25 ]: + if "BoringSSL" in tls and int(g) in [25]: logger.info("Ignore connection failure with group " + g + " with BoringSSL") dev[0].remove_network(id) dev[0].dump_monitor() @@ -217,7 +217,7 @@ def test_sae_group_nego_no_match(dev, apdev): dev[0].request("SET sae_groups ") dev[0].connect("test-sae-group-nego", psk="12345678", key_mgmt="SAE", scan_freq="2412", wait_connect=False) - ev = dev[0].wait_event([ "CTRL-EVENT-SSID-TEMP-DISABLED" ], timeout=10) + ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED"], timeout=10) dev[0].request("REMOVE_NETWORK all") if ev is None: raise Exception("Network profile disabling not reported") @@ -550,39 +550,39 @@ def test_sae_proto_ecc(dev, apdev): dev[0].request("SET sae_groups 19") - tests = [ ("Confirm mismatch", - "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - "0000800edebc3f260dc1fe7e0b20888af2b8a3316252ec37388a8504e25b73dc4240"), - ("Commit without even full cyclic group field", - "13", - None), - ("Too short commit", - "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02", - None), - ("Invalid commit scalar (0)", - "1300" + "0000000000000000000000000000000000000000000000000000000000000000" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - None), - ("Invalid commit scalar (1)", - "1300" + "0000000000000000000000000000000000000000000000000000000000000001" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - None), - ("Invalid commit scalar (> r)", - "1300" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - None), - ("Commit element not on curve", - "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728d0000000000000000000000000000000000000000000000000000000000000000", - None), - ("Invalid commit element (y coordinate > P)", - "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - None), - ("Invalid commit element (x coordinate > P)", - "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - None), - ("Different group in commit", - "1400" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - None), - ("Too short confirm", - "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", - "0000800edebc3f260dc1fe7e0b20888af2b8a3316252ec37388a8504e25b73dc42")] + tests = [("Confirm mismatch", + "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + "0000800edebc3f260dc1fe7e0b20888af2b8a3316252ec37388a8504e25b73dc4240"), + ("Commit without even full cyclic group field", + "13", + None), + ("Too short commit", + "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02", + None), + ("Invalid commit scalar (0)", + "1300" + "0000000000000000000000000000000000000000000000000000000000000000" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + None), + ("Invalid commit scalar (1)", + "1300" + "0000000000000000000000000000000000000000000000000000000000000001" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + None), + ("Invalid commit scalar (> r)", + "1300" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + None), + ("Commit element not on curve", + "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728d0000000000000000000000000000000000000000000000000000000000000000", + None), + ("Invalid commit element (y coordinate > P)", + "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + None), + ("Invalid commit element (x coordinate > P)", + "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + None), + ("Different group in commit", + "1400" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + None), + ("Too short confirm", + "1300" + "033d3635b39666ed427fd4a3e7d37acec2810afeaf1687f746a14163ff0e6d03" + "559cb8928db4ce4e3cbd6555e837591995e5ebe503ef36b503d9ca519d63728dd3c7c676b8e8081831b6bc3a64bdf136061a7de175e17d1965bfa41983ed02f8", + "0000800edebc3f260dc1fe7e0b20888af2b8a3316252ec37388a8504e25b73dc42")] for (note, commit, confirm) in tests: logger.info(note) dev[0].scan_for_bss(bssid, freq=2412) @@ -649,21 +649,21 @@ def test_sae_proto_ffc(dev, apdev): dev[0].request("SET sae_groups 2") - tests = [ ("Confirm mismatch", - "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "a8c00117493cdffa5dd671e934bc9cb1a69f39e25e9dd9cd9afd3aea2441a0f5491211c7ba50a753563f9ce943b043557cb71193b28e86ed9544f4289c471bf91b70af5c018cf4663e004165b0fd0bc1d8f3f78adf42eee92bcbc55246fd3ee9f107ab965dc7d4986f23eb71d616ebfe6bfe0a6c1ac5dc1718acee17c9a17486", - "0000f3116a9731f1259622e3eb55d4b3b50ba16f8c5f5565b28e609b180c51460251"), - ("Too short commit", - "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "a8c00117493cdffa5dd671e934bc9cb1a69f39e25e9dd9cd9afd3aea2441a0f5491211c7ba50a753563f9ce943b043557cb71193b28e86ed9544f4289c471bf91b70af5c018cf4663e004165b0fd0bc1d8f3f78adf42eee92bcbc55246fd3ee9f107ab965dc7d4986f23eb71d616ebfe6bfe0a6c1ac5dc1718acee17c9a174", - None), - ("Invalid element (0) in commit", - "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - None), - ("Invalid element (1) in commit", - "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - None), - ("Invalid element (> P) in commit", - "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - None) ] + tests = [("Confirm mismatch", + "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "a8c00117493cdffa5dd671e934bc9cb1a69f39e25e9dd9cd9afd3aea2441a0f5491211c7ba50a753563f9ce943b043557cb71193b28e86ed9544f4289c471bf91b70af5c018cf4663e004165b0fd0bc1d8f3f78adf42eee92bcbc55246fd3ee9f107ab965dc7d4986f23eb71d616ebfe6bfe0a6c1ac5dc1718acee17c9a17486", + "0000f3116a9731f1259622e3eb55d4b3b50ba16f8c5f5565b28e609b180c51460251"), + ("Too short commit", + "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "a8c00117493cdffa5dd671e934bc9cb1a69f39e25e9dd9cd9afd3aea2441a0f5491211c7ba50a753563f9ce943b043557cb71193b28e86ed9544f4289c471bf91b70af5c018cf4663e004165b0fd0bc1d8f3f78adf42eee92bcbc55246fd3ee9f107ab965dc7d4986f23eb71d616ebfe6bfe0a6c1ac5dc1718acee17c9a174", + None), + ("Invalid element (0) in commit", + "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + None), + ("Invalid element (1) in commit", + "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", + None), + ("Invalid element (> P) in commit", + "0200" + "0c70519d874e3e4930a917cc5e17ea7a26028211159f217bab28b8d6c56691805e49f03249b2c6e22c7c9f86b30e04ccad2deedd5e5108ae07b737c00001c59cd0eb08b1dfc7f1b06a1542e2b6601a963c066e0c65940983a03917ae57a101ce84b5cbbc76ff33ebb990aac2e54aa0f0ab6ec0a58113d927683502b2cb2347d2" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + None)] for (note, commit, confirm) in tests: logger.info(note) dev[0].scan_for_bss(bssid, freq=2412) @@ -1005,10 +1005,10 @@ def test_sae_no_random(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].request("SET sae_groups ") - tests = [ (1, "os_get_random;sae_get_rand"), - (1, "os_get_random;get_rand_1_to_p_1"), - (1, "os_get_random;get_random_qr_qnr"), - (1, "os_get_random;sae_derive_pwe_ecc") ] + tests = [(1, "os_get_random;sae_get_rand"), + (1, "os_get_random;get_rand_1_to_p_1"), + (1, "os_get_random;get_random_qr_qnr"), + (1, "os_get_random;sae_derive_pwe_ecc")] for count, func in tests: with fail_test(dev[0], count, func): dev[0].connect("test-sae", psk="12345678", key_mgmt="SAE", @@ -1068,33 +1068,33 @@ def test_sae_bignum_failure(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].request("SET sae_groups 19") - tests = [ (1, "crypto_bignum_init_set;get_rand_1_to_p_1"), - (1, "crypto_bignum_init;is_quadratic_residue_blind"), - (1, "crypto_bignum_mulmod;is_quadratic_residue_blind"), - (2, "crypto_bignum_mulmod;is_quadratic_residue_blind"), - (3, "crypto_bignum_mulmod;is_quadratic_residue_blind"), - (1, "crypto_bignum_legendre;is_quadratic_residue_blind"), - (1, "crypto_bignum_init_set;sae_test_pwd_seed_ecc"), - (1, "crypto_ec_point_compute_y_sqr;sae_test_pwd_seed_ecc"), - (1, "crypto_bignum_init_set;get_random_qr_qnr"), - (1, "crypto_bignum_to_bin;sae_derive_pwe_ecc"), - (1, "crypto_ec_point_init;sae_derive_pwe_ecc"), - (1, "crypto_ec_point_solve_y_coord;sae_derive_pwe_ecc"), - (1, "crypto_ec_point_init;sae_derive_commit_element_ecc"), - (1, "crypto_ec_point_mul;sae_derive_commit_element_ecc"), - (1, "crypto_ec_point_invert;sae_derive_commit_element_ecc"), - (1, "crypto_bignum_init;=sae_derive_commit"), - (1, "crypto_ec_point_init;sae_derive_k_ecc"), - (1, "crypto_ec_point_mul;sae_derive_k_ecc"), - (1, "crypto_ec_point_add;sae_derive_k_ecc"), - (2, "crypto_ec_point_mul;sae_derive_k_ecc"), - (1, "crypto_ec_point_to_bin;sae_derive_k_ecc"), - (1, "crypto_bignum_legendre;get_random_qr_qnr"), - (1, "sha256_prf;sae_derive_keys"), - (1, "crypto_bignum_init;sae_derive_keys"), - (1, "crypto_bignum_init_set;sae_parse_commit_scalar"), - (1, "crypto_bignum_to_bin;sae_parse_commit_element_ecc"), - (1, "crypto_ec_point_from_bin;sae_parse_commit_element_ecc") ] + tests = [(1, "crypto_bignum_init_set;get_rand_1_to_p_1"), + (1, "crypto_bignum_init;is_quadratic_residue_blind"), + (1, "crypto_bignum_mulmod;is_quadratic_residue_blind"), + (2, "crypto_bignum_mulmod;is_quadratic_residue_blind"), + (3, "crypto_bignum_mulmod;is_quadratic_residue_blind"), + (1, "crypto_bignum_legendre;is_quadratic_residue_blind"), + (1, "crypto_bignum_init_set;sae_test_pwd_seed_ecc"), + (1, "crypto_ec_point_compute_y_sqr;sae_test_pwd_seed_ecc"), + (1, "crypto_bignum_init_set;get_random_qr_qnr"), + (1, "crypto_bignum_to_bin;sae_derive_pwe_ecc"), + (1, "crypto_ec_point_init;sae_derive_pwe_ecc"), + (1, "crypto_ec_point_solve_y_coord;sae_derive_pwe_ecc"), + (1, "crypto_ec_point_init;sae_derive_commit_element_ecc"), + (1, "crypto_ec_point_mul;sae_derive_commit_element_ecc"), + (1, "crypto_ec_point_invert;sae_derive_commit_element_ecc"), + (1, "crypto_bignum_init;=sae_derive_commit"), + (1, "crypto_ec_point_init;sae_derive_k_ecc"), + (1, "crypto_ec_point_mul;sae_derive_k_ecc"), + (1, "crypto_ec_point_add;sae_derive_k_ecc"), + (2, "crypto_ec_point_mul;sae_derive_k_ecc"), + (1, "crypto_ec_point_to_bin;sae_derive_k_ecc"), + (1, "crypto_bignum_legendre;get_random_qr_qnr"), + (1, "sha256_prf;sae_derive_keys"), + (1, "crypto_bignum_init;sae_derive_keys"), + (1, "crypto_bignum_init_set;sae_parse_commit_scalar"), + (1, "crypto_bignum_to_bin;sae_parse_commit_element_ecc"), + (1, "crypto_ec_point_from_bin;sae_parse_commit_element_ecc")] for count, func in tests: with fail_test(dev[0], count, func): hapd.request("NOTE STA failure testing %d:%s" % (count, func)) @@ -1106,24 +1106,24 @@ def test_sae_bignum_failure(dev, apdev): hapd.dump_monitor() dev[0].request("SET sae_groups 5") - tests = [ (1, "crypto_bignum_init_set;sae_set_group"), - (2, "crypto_bignum_init_set;sae_set_group"), - (1, "crypto_bignum_init_set;sae_get_rand"), - (1, "crypto_bignum_init_set;sae_test_pwd_seed_ffc"), - (1, "crypto_bignum_exptmod;sae_test_pwd_seed_ffc"), - (1, "crypto_bignum_init;sae_derive_pwe_ffc"), - (1, "crypto_bignum_init;sae_derive_commit_element_ffc"), - (1, "crypto_bignum_exptmod;sae_derive_commit_element_ffc"), - (1, "crypto_bignum_inverse;sae_derive_commit_element_ffc"), - (1, "crypto_bignum_init;sae_derive_k_ffc"), - (1, "crypto_bignum_exptmod;sae_derive_k_ffc"), - (1, "crypto_bignum_mulmod;sae_derive_k_ffc"), - (2, "crypto_bignum_exptmod;sae_derive_k_ffc"), - (1, "crypto_bignum_to_bin;sae_derive_k_ffc"), - (1, "crypto_bignum_init_set;sae_parse_commit_element_ffc"), - (1, "crypto_bignum_init;sae_parse_commit_element_ffc"), - (2, "crypto_bignum_init_set;sae_parse_commit_element_ffc"), - (1, "crypto_bignum_exptmod;sae_parse_commit_element_ffc") ] + tests = [(1, "crypto_bignum_init_set;sae_set_group"), + (2, "crypto_bignum_init_set;sae_set_group"), + (1, "crypto_bignum_init_set;sae_get_rand"), + (1, "crypto_bignum_init_set;sae_test_pwd_seed_ffc"), + (1, "crypto_bignum_exptmod;sae_test_pwd_seed_ffc"), + (1, "crypto_bignum_init;sae_derive_pwe_ffc"), + (1, "crypto_bignum_init;sae_derive_commit_element_ffc"), + (1, "crypto_bignum_exptmod;sae_derive_commit_element_ffc"), + (1, "crypto_bignum_inverse;sae_derive_commit_element_ffc"), + (1, "crypto_bignum_init;sae_derive_k_ffc"), + (1, "crypto_bignum_exptmod;sae_derive_k_ffc"), + (1, "crypto_bignum_mulmod;sae_derive_k_ffc"), + (2, "crypto_bignum_exptmod;sae_derive_k_ffc"), + (1, "crypto_bignum_to_bin;sae_derive_k_ffc"), + (1, "crypto_bignum_init_set;sae_parse_commit_element_ffc"), + (1, "crypto_bignum_init;sae_parse_commit_element_ffc"), + (2, "crypto_bignum_init_set;sae_parse_commit_element_ffc"), + (1, "crypto_bignum_exptmod;sae_parse_commit_element_ffc")] for count, func in tests: with fail_test(dev[0], count, func): hapd.request("NOTE STA failure testing %d:%s" % (count, func)) @@ -1135,9 +1135,9 @@ def test_sae_bignum_failure(dev, apdev): hapd.dump_monitor() dev[0].request("SET sae_groups 22") - tests = [ (1, "crypto_bignum_init_set;sae_test_pwd_seed_ffc"), - (1, "crypto_bignum_sub;sae_test_pwd_seed_ffc"), - (1, "crypto_bignum_div;sae_test_pwd_seed_ffc") ] + tests = [(1, "crypto_bignum_init_set;sae_test_pwd_seed_ffc"), + (1, "crypto_bignum_sub;sae_test_pwd_seed_ffc"), + (1, "crypto_bignum_div;sae_test_pwd_seed_ffc")] for count, func in tests: with fail_test(dev[0], count, func): hapd.request("NOTE STA failure testing %d:%s" % (count, func)) @@ -1306,9 +1306,9 @@ def run_sae_password_id(dev, apdev, groups=None): params['sae_groups'] = groups else: groups = "" - params['sae_password'] = [ 'secret|mac=ff:ff:ff:ff:ff:ff|id=pw id', - 'foo|mac=02:02:02:02:02:02', - 'another secret|mac=ff:ff:ff:ff:ff:ff|id=' + 29*'A' ] + params['sae_password'] = ['secret|mac=ff:ff:ff:ff:ff:ff|id=pw id', + 'foo|mac=02:02:02:02:02:02', + 'another secret|mac=ff:ff:ff:ff:ff:ff|id=' + 29*'A'] hapd = hostapd.add_ap(apdev[0], params) dev[0].request("SET sae_groups " + groups) @@ -1424,9 +1424,9 @@ def build_sae_commit(bssid, addr, group=21, token=None): def sae_rx_commit_token_req(sock, radiotap, send_two=False): msg = sock.recv(1500) - ver,pad,len,present = struct.unpack('= 5260 and f <= 5320) or (f >= 5500 and f <= 5700): raise Exception("Active scan on DFS channel: %d" % f) - if f in [ 2467, 2472 ]: + if f in [2467, 2472]: raise Exception("Active scan on US-disallowed channel: %d" % f) @remote_compatible @@ -1030,7 +1030,7 @@ def test_scan_abort(dev, apdev): @remote_compatible def test_scan_abort_on_connect(dev, apdev): """Aborting a full scan on connection request""" - hostapd.add_ap(apdev[0], { "ssid": "test-scan" }) + hostapd.add_ap(apdev[0], {"ssid": "test-scan"}) bssid = apdev[0]['bssid'] dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -1044,7 +1044,7 @@ def test_scan_abort_on_connect(dev, apdev): @remote_compatible def test_scan_ext(dev, apdev): """Custom IE in Probe Request frame""" - hostapd.add_ap(apdev[0], { "ssid": "test-scan" }) + hostapd.add_ap(apdev[0], {"ssid": "test-scan"}) bssid = apdev[0]['bssid'] try: @@ -1140,7 +1140,7 @@ def test_scan_fail(dev, apdev): wpas.request("SET preassoc_mac_addr 0") wpas.dump_monitor() - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) with alloc_fail(dev[0], 1, "wpa_bss_add"): dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412") @@ -1153,7 +1153,7 @@ def test_scan_fail_type_only(dev, apdev): raise Exception("Scan trigger failure not reported") # Verify that scan_only_handler() does not get left set as the # wpa_s->scan_res_handler in failure case. - 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") @remote_compatible @@ -1166,7 +1166,7 @@ def test_scan_freq_list(dev, apdev): finally: dev[0].request("SET freq_list ") - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan"}) dev[0].connect("test-scan", key_mgmt="NONE", scan_freq="2412") try: if "OK" not in dev[0].request("SET scan_cur_freq 1"): @@ -1191,10 +1191,10 @@ def _test_scan_bss_limit(dev, apdev): # count to one so that the second AP would not fit in the BSS list and the # first AP cannot be removed from the list since it is still in use. dev[0].request("SET bss_max_count 1") - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan"}) dev[0].connect("test-scan", key_mgmt="NONE", scan_freq="2412") - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "test-scan-2", - "channel": "6" }) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "test-scan-2", + "channel": "6"}) dev[0].scan_for_bss(apdev[1]['bssid'], freq=2437, force_scan=True) def run_scan(dev, bssid, exp_freq): @@ -1218,7 +1218,7 @@ def test_scan_chan_switch(dev, apdev): # has multiple (one for each frequency) BSS entries for the same BSS. csa_supported(dev[0]) - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan", "channel": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan", "channel": "1"}) csa_supported(hapd) bssid = hapd.own_addr() @@ -1255,7 +1255,7 @@ def test_scan_new_only(dev, apdev): dev[0].set("ignore_old_scan_res", "0") def _test_scan_new_only(dev, apdev): dev[0].flush_scan_cache() - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan"}) dev[0].set("ignore_old_scan_res", "1") # Get the BSS added to cfg80211 BSS list bssid = hapd.own_addr() @@ -1284,7 +1284,7 @@ def _test_scan_new_only(dev, apdev): def test_scan_flush(dev, apdev): """Ongoing scan and FLUSH""" dev[0].flush_scan_cache() - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan"}) dev[0].dump_monitor() dev[0].request("SCAN TYPE=ONLY freq=2412-2472 passive=1") ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=10) @@ -1303,8 +1303,8 @@ def test_scan_flush(dev, apdev): def test_scan_ies(dev, apdev): """Scan and both Beacon and Probe Response frame IEs""" dev[0].flush_scan_cache() - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan", - "beacon_int": "20" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan", + "beacon_int": "20"}) bssid = hapd.own_addr() dev[0].dump_monitor() @@ -1340,43 +1340,43 @@ def test_scan_parsing(dev, apdev): if "FAIL" not in dev[0].request("DRIVER_EVENT SCAN_RES foo "): raise Exception("Invalid DRIVER_EVENT SCAN_RES accepted") - tests = [ "", - "flags=ffffffff", - "bssid=02:03:04:05:06:07", - "freq=1234", - "beacon_int=102", - "caps=1234", - "qual=10", - "noise=10", - "level=10", - "tsf=1122334455667788", - "age=123", - "est_throughput=100", - "snr=10", - "parent_tsf=1122334455667788", - "tsf_bssid=02:03:04:05:06:07", - "ie=00", - "beacon_ie=00", - # Too long SSID - "bssid=02:ff:00:00:00:01 ie=0033" + 33*'FF', - # All parameters - "flags=ffffffff bssid=02:ff:00:00:00:02 freq=1234 beacon_int=102 caps=1234 qual=10 noise=10 level=10 tsf=1122334455667788 age=123456 est_throughput=100 snr=10 parent_tsf=1122334455667788 tsf_bssid=02:03:04:05:06:07 ie=000474657374 beacon_ie=000474657374", - # Beacon IEs truncated - "bssid=02:ff:00:00:00:03 ie=0000 beacon_ie=0003ffff", - # Probe Response IEs truncated - "bssid=02:ff:00:00:00:04 ie=00000101 beacon_ie=0000", - # DMG (invalid caps) - "bssid=02:ff:00:00:00:05 freq=58320 ie=0003646d67", - # DMG (IBSS) - "bssid=02:ff:00:00:00:06 freq=60480 caps=0001 ie=0003646d67", - # DMG (PBSS) - "bssid=02:ff:00:00:00:07 freq=62640 caps=0002 ie=0003646d67", - # DMG (AP) - "bssid=02:ff:00:00:00:08 freq=64800 caps=0003 ie=0003646d67", - # Test BSS for updates - "bssid=02:ff:00:00:00:09 freq=2412 caps=0011 level=1 ie=0003757064010182", - # Minimal BSS data - "bssid=02:ff:00:00:00:00 ie=0000" ] + tests = ["", + "flags=ffffffff", + "bssid=02:03:04:05:06:07", + "freq=1234", + "beacon_int=102", + "caps=1234", + "qual=10", + "noise=10", + "level=10", + "tsf=1122334455667788", + "age=123", + "est_throughput=100", + "snr=10", + "parent_tsf=1122334455667788", + "tsf_bssid=02:03:04:05:06:07", + "ie=00", + "beacon_ie=00", + # Too long SSID + "bssid=02:ff:00:00:00:01 ie=0033" + 33*'FF', + # All parameters + "flags=ffffffff bssid=02:ff:00:00:00:02 freq=1234 beacon_int=102 caps=1234 qual=10 noise=10 level=10 tsf=1122334455667788 age=123456 est_throughput=100 snr=10 parent_tsf=1122334455667788 tsf_bssid=02:03:04:05:06:07 ie=000474657374 beacon_ie=000474657374", + # Beacon IEs truncated + "bssid=02:ff:00:00:00:03 ie=0000 beacon_ie=0003ffff", + # Probe Response IEs truncated + "bssid=02:ff:00:00:00:04 ie=00000101 beacon_ie=0000", + # DMG (invalid caps) + "bssid=02:ff:00:00:00:05 freq=58320 ie=0003646d67", + # DMG (IBSS) + "bssid=02:ff:00:00:00:06 freq=60480 caps=0001 ie=0003646d67", + # DMG (PBSS) + "bssid=02:ff:00:00:00:07 freq=62640 caps=0002 ie=0003646d67", + # DMG (AP) + "bssid=02:ff:00:00:00:08 freq=64800 caps=0003 ie=0003646d67", + # Test BSS for updates + "bssid=02:ff:00:00:00:09 freq=2412 caps=0011 level=1 ie=0003757064010182", + # Minimal BSS data + "bssid=02:ff:00:00:00:00 ie=0000"] for t in tests: if "OK" not in dev[0].request("DRIVER_EVENT SCAN_RES BSS " + t): raise Exception("DRIVER_EVENT SCAN_RES BSS failed") @@ -1406,12 +1406,12 @@ def test_scan_parsing(dev, apdev): res = dev[0].request("BSS NEXT-" + id) logger.info("Discovered BSSs: " + str(bss)) - invalid_bss = [ "02:03:04:05:06:07", "02:ff:00:00:00:01" ] - valid_bss = [ "02:ff:00:00:00:00", "02:ff:00:00:00:02", - "02:ff:00:00:00:03", "02:ff:00:00:00:04", - "02:ff:00:00:00:05", "02:ff:00:00:00:06", - "02:ff:00:00:00:07", "02:ff:00:00:00:08", - "02:ff:00:00:00:09" ] + invalid_bss = ["02:03:04:05:06:07", "02:ff:00:00:00:01"] + valid_bss = ["02:ff:00:00:00:00", "02:ff:00:00:00:02", + "02:ff:00:00:00:03", "02:ff:00:00:00:04", + "02:ff:00:00:00:05", "02:ff:00:00:00:06", + "02:ff:00:00:00:07", "02:ff:00:00:00:08", + "02:ff:00:00:00:09"] for bssid in invalid_bss: if bssid in bss: raise Exception("Invalid BSS included: " + bssid) @@ -1432,8 +1432,8 @@ def test_scan_parsing(dev, apdev): def test_scan_specific_bssid(dev, apdev): """Scan for a specific BSSID""" dev[0].flush_scan_cache() - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan", - "beacon_int": "1000" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan", + "beacon_int": "1000"}) bssid = hapd.own_addr() time.sleep(0.1) @@ -1461,7 +1461,7 @@ def test_scan_specific_bssid(dev, apdev): def test_scan_probe_req_events(dev, apdev): """Probe Request frame RX events from hostapd""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) hapd2 = hostapd.Hostapd(apdev[0]['ifname']) if "OK" not in hapd2.mon.request("ATTACH probe_rx_events=1"): raise Exception("Failed to register for events") @@ -1486,7 +1486,7 @@ def test_scan_probe_req_events(dev, apdev): if ev is not None: raise Exception("Unexpected RX-PROBE-REQUEST") - tests = [ "probe_rx_events", "probe_rx_events=-1", "probe_rx_events=2" ] + tests = ["probe_rx_events", "probe_rx_events=-1", "probe_rx_events=2"] for val in tests: if "FAIL" not in hapd2.mon.request("ATTACH " + val): raise Exception("Invalid ATTACH command accepted") @@ -1538,12 +1538,12 @@ def test_scan_multi_bssid(dev, apdev): check_multibss_sta_capa(dev[0]) dev[0].flush_scan_cache() - params = { "ssid": "test-scan" } + params = {"ssid": "test-scan"} # Max BSSID Indicator 0 (max 1 BSSID) and no subelements params['vendor_elements'] = elem_multibssid(b'', 0) hostapd.add_ap(apdev[0], params) - params = { "ssid": "test-scan" } + params = {"ssid": "test-scan"} elems = elem_capab(0x0401) + elem_ssid("1") + elem_bssid_index(1) profile1 = struct.pack('BB', 0, len(elems)) + elems params['vendor_elements'] = elem_multibssid(profile1, 1) @@ -1551,9 +1551,9 @@ def test_scan_multi_bssid(dev, apdev): bssid0 = apdev[0]['bssid'] bssid1 = apdev[1]['bssid'] - check = [ (bssid0, 'test-scan', 0x401), - (bssid1, 'test-scan', 0x401), - (bssid1[0:16] + '1', '1', 0x401) ] + check = [(bssid0, 'test-scan', 0x401), + (bssid1, 'test-scan', 0x401), + (bssid1[0:16] + '1', '1', 0x401)] run_scans(dev[0], check) def test_scan_multi_bssid_2(dev, apdev): @@ -1561,7 +1561,7 @@ def test_scan_multi_bssid_2(dev, apdev): check_multibss_sta_capa(dev[0]) dev[0].flush_scan_cache() - params = { "ssid": "transmitted" } + params = {"ssid": "transmitted"} # Duplicated entry for the transmitted BSS (not a normal use case) elems = elem_capab(1) + elem_ssid("transmitted") + elem_bssid_index(0) @@ -1578,9 +1578,9 @@ def test_scan_multi_bssid_2(dev, apdev): hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - check = [ (bssid, 'transmitted', 0x401), - (bssid[0:16] + '1', 'nontransmitted', 0x1), - (bssid[0:16] + '2', 'nontransmitted_2', 0x1) ] + check = [(bssid, 'transmitted', 0x401), + (bssid[0:16] + '1', 'nontransmitted', 0x1), + (bssid[0:16] + '2', 'nontransmitted_2', 0x1)] run_scans(dev[0], check) def test_scan_multi_bssid_3(dev, apdev): @@ -1588,7 +1588,7 @@ def test_scan_multi_bssid_3(dev, apdev): check_multibss_sta_capa(dev[0]) dev[0].flush_scan_cache() - params = { "ssid": "transmitted" } + params = {"ssid": "transmitted"} # Duplicated nontransmitted BSS (not a normal use case) elems = elem_capab(1) + elem_ssid("nontransmitted") + elem_bssid_index(1) @@ -1602,8 +1602,8 @@ def test_scan_multi_bssid_3(dev, apdev): hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] - check = [ (bssid, 'transmitted', 0x401), - (bssid[0:16] + '1', 'nontransmitted', 0x1) ] + check = [(bssid, 'transmitted', 0x401), + (bssid[0:16] + '1', 'nontransmitted', 0x1)] run_scans(dev[0], check) def test_scan_multi_bssid_4(dev, apdev): @@ -1615,8 +1615,8 @@ def test_scan_multi_bssid_4(dev, apdev): bssid = apdev[0]['bssid'] hapd = None try: - params = { "ssid": "transmitted", - "bssid": bssid[0:16] + '1'} + params = {"ssid": "transmitted", + "bssid": bssid[0:16] + '1'} elems = elem_capab(1) + elem_ssid("1") + elem_bssid_index(1) profile1 = struct.pack('BB', 0, len(elems)) + elems @@ -1631,10 +1631,10 @@ def test_scan_multi_bssid_4(dev, apdev): params['vendor_elements'] = elem_multibssid(profiles, 2) hapd = hostapd.add_ap(apdev[0], params) - check = [ (bssid[0:16] + '1', 'transmitted', 0x401), - (bssid[0:16] + '2', '1', 0x1), - (bssid[0:16] + '3', '2', 0x1), - (bssid[0:16] + '0', '3', 0x1) ] + check = [(bssid[0:16] + '1', 'transmitted', 0x401), + (bssid[0:16] + '2', '1', 0x1), + (bssid[0:16] + '3', '2', 0x1), + (bssid[0:16] + '0', '3', 0x1)] run_scans(dev[0], check) finally: if hapd: @@ -1647,7 +1647,7 @@ def test_scan_multi_bssid_check_ie(dev, apdev): check_multibss_sta_capa(dev[0]) dev[0].flush_scan_cache() - params = { "ssid": "transmitted" } + params = {"ssid": "transmitted"} # Duplicated entry for the transmitted BSS (not a normal use case) elems = elem_capab(1) + elem_ssid("transmitted") + elem_bssid_index(0) @@ -1720,7 +1720,7 @@ def test_scan_multi_bssid_fms(dev, apdev): check_multibss_sta_capa(dev[0]) dev[0].flush_scan_cache() - params = { "ssid": "transmitted" } + params = {"ssid": "transmitted"} # construct transmitting BSS Beacon with FMS IE elems = elem_capab(1) + elem_ssid("transmitted") + elem_bssid_index(0) + elem_fms1() @@ -1785,8 +1785,8 @@ def test_scan_multiple_mbssid_ie(dev, apdev): hapd = None # construct 2 MBSSID IEs, each MBSSID IE contains 1 profile - params = { "ssid": "transmitted", - "bssid": bssid } + params = {"ssid": "transmitted", + "bssid": bssid} elems = elem_capab(1) + elem_ssid("1") + elem_bssid_index(1) profile1 = struct.pack('BB', 0, len(elems)) + elems @@ -1794,12 +1794,12 @@ def test_scan_multiple_mbssid_ie(dev, apdev): elems = elem_capab(2) + elem_ssid("2") + elem_bssid_index(2) profile2 = struct.pack('BB', 0, len(elems)) + elems - params['vendor_elements'] = elem_multibssid(profile1, 2) + elem_multibssid(profile2,2) + params['vendor_elements'] = elem_multibssid(profile1, 2) + elem_multibssid(profile2, 2) hapd = hostapd.add_ap(apdev[0], params) - check = [ (bssid, 'transmitted', 0x401), - (bssid[0:16] + '1', '1', 0x1), - (bssid[0:16] + '2', '2', 0x2) ] + check = [(bssid, 'transmitted', 0x401), + (bssid[0:16] + '1', '1', 0x1), + (bssid[0:16] + '2', '2', 0x2)] run_scans(dev[0], check) def test_scan_mbssid_hidden_ssid(dev, apdev): @@ -1812,8 +1812,8 @@ def test_scan_mbssid_hidden_ssid(dev, apdev): hapd = None # construct 2 MBSSID IEs, each MBSSID IE contains 1 profile - params = { "ssid": "transmitted", - "bssid": bssid } + params = {"ssid": "transmitted", + "bssid": bssid} elems = elem_capab(1) + elem_ssid("") + elem_bssid_index(1) profile1 = struct.pack('BB', 0, len(elems)) + elems @@ -1825,9 +1825,9 @@ def test_scan_mbssid_hidden_ssid(dev, apdev): params['vendor_elements'] = elem_multibssid(profiles, 2) hapd = hostapd.add_ap(apdev[0], params) - check = [ (bssid, 'transmitted', 0x401), - (bssid[0:16] + '1', '', 0x1), - (bssid[0:16] + '2', '2', 0x2) ] + check = [(bssid, 'transmitted', 0x401), + (bssid[0:16] + '1', '', 0x1), + (bssid[0:16] + '2', '2', 0x2)] run_scans(dev[0], check) def test_connect_mbssid_open_1(dev, apdev): @@ -1836,7 +1836,7 @@ def test_connect_mbssid_open_1(dev, apdev): dev[0].flush_scan_cache() bssid = apdev[0]['bssid'] - params = { "ssid": "transmitted" } + params = {"ssid": "transmitted"} elems = elem_capab(1) + elem_ssid("nontransmitted") + elem_bssid_index(1) profile1 = struct.pack('BB', 0, len(elems)) + elems diff --git a/tests/hwsim/test_sigma_dut.py b/tests/hwsim/test_sigma_dut.py index 2ae95a921..77a39989a 100644 --- a/tests/hwsim/test_sigma_dut.py +++ b/tests/hwsim/test_sigma_dut.py @@ -73,21 +73,21 @@ def sigma_dut_cmd_check(cmd, port=9000, timeout=2): def start_sigma_dut(ifname, debug=False, hostapd_logdir=None, cert_path=None, bridge=None): check_sigma_dut() - cmd = [ './sigma_dut', - '-M', ifname, - '-S', ifname, - '-F', '../../hostapd/hostapd', - '-G', - '-w', '/var/run/wpa_supplicant/', - '-j', ifname ] + cmd = ['./sigma_dut', + '-M', ifname, + '-S', ifname, + '-F', '../../hostapd/hostapd', + '-G', + '-w', '/var/run/wpa_supplicant/', + '-j', ifname] if debug: - cmd += [ '-d' ] + cmd += ['-d'] if hostapd_logdir: - cmd += [ '-H', hostapd_logdir ] + cmd += ['-H', hostapd_logdir] if cert_path: - cmd += [ '-C', cert_path ] + cmd += ['-C', cert_path] if bridge: - cmd += [ '-b', bridge ] + cmd += ['-b', bridge] sigma = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) for i in range(20): @@ -122,11 +122,11 @@ def test_sigma_dut_basic(dev, apdev): if "status,INVALID,errorCode,Unknown command" not in res: raise Exception("Unexpected sigma_dut response to unknown command") - tests = [ ("ca_get_version", "status,COMPLETE,version,1.0"), - ("device_get_info", "status,COMPLETE,vendor"), - ("device_list_interfaces,interfaceType,foo", "status,ERROR"), - ("device_list_interfaces,interfaceType,802.11", - "status,COMPLETE,interfaceType,802.11,interfaceID," + dev[0].ifname) ] + tests = [("ca_get_version", "status,COMPLETE,version,1.0"), + ("device_get_info", "status,COMPLETE,vendor"), + ("device_list_interfaces,interfaceType,foo", "status,ERROR"), + ("device_list_interfaces,interfaceType,802.11", + "status,COMPLETE,interfaceType,802.11,interfaceID," + dev[0].ifname)] for cmd, response in tests: res = sigma_dut_cmd(cmd) if response not in res: @@ -145,7 +145,7 @@ def run_sigma_dut_open(dev, apdev): ifname = dev[0].ifname sigma = start_sigma_dut(ifname) - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) sigma_dut_cmd_check("sta_set_encryption,interface,%s,ssid,%s,encpType,none" % (ifname, "open")) @@ -339,8 +339,8 @@ def run_sigma_dut_sta_override_rsne(dev, apdev): sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) - tests = [ "30120100000fac040100000fac040100000fac02", - "30140100000fac040100000fac040100000fac02ffff" ] + tests = ["30120100000fac040100000fac040100000fac02", + "30140100000fac040100000fac040100000fac02ffff"] for test in tests: sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,type,PSK,passphrase,%s,EncpType,aes-ccmp,KeyMgmtType,wpa2" % (ifname, "test-psk", "12345678")) sigma_dut_cmd_check("dev_configure_ie,interface,%s,IE_Name,RSNE,Contents,%s" % (ifname, test)) @@ -440,17 +440,17 @@ def test_sigma_dut_suite_b(dev, apdev, params): params['openssl_ciphers'] = 'SUITEB192' hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "18129", - 'auth_server_shared_secret': "radius", - 'nas_identifier': "nas.w1.fi" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "18129", + 'auth_server_shared_secret': "radius", + 'nas_identifier': "nas.w1.fi"} hapd = hostapd.add_ap(apdev[0], params) ifname = dev[0].ifname @@ -491,9 +491,9 @@ def test_sigma_dut_suite_b_rsa(dev, apdev, params): cmd = "sta_set_security,type,eaptls,interface,%s,ssid,%s,PairwiseCipher,AES-GCMP-256,GroupCipher,AES-GCMP-256,GroupMgntCipher,BIP-GMAC-256,keymgmttype,SuiteB,clientCertificate,suite_b_rsa.pem,trustedRootCA,suite_b_ca_rsa.pem,CertType,RSA" % (ifname, "test-suite-b") - tests = [ "", - ",TLSCipher,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", - ",TLSCipher,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" ] + tests = ["", + ",TLSCipher,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + ",TLSCipher,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384"] for extra in tests: sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname) sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) @@ -749,11 +749,11 @@ def run_sigma_dut_owe(dev, apdev): sigma = start_sigma_dut(ifname) try: - params = { "ssid": "owe", - "wpa": "2", - "wpa_key_mgmt": "OWE", - "ieee80211w": "2", - "rsn_pairwise": "CCMP" } + params = {"ssid": "owe", + "wpa": "2", + "wpa_key_mgmt": "OWE", + "ieee80211w": "2", + "rsn_pairwise": "CCMP"} hapd = hostapd.add_ap(apdev[0], params) bssid = hapd.own_addr() @@ -999,14 +999,14 @@ def test_sigma_dut_dpp_qr_init_enrollee(dev, apdev): ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" - params = { "ssid": "DPPNET01", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "DPP", - "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign_pub, - "dpp_netaccesskey": ap_netaccesskey } + params = {"ssid": "DPPNET01", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "DPP", + "rsn_pairwise": "CCMP", + "dpp_connector": ap_connector, + "dpp_csign": csign_pub, + "dpp_netaccesskey": ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1060,14 +1060,14 @@ def run_sigma_dut_dpp_qr_mutual_init_enrollee_check(dev, apdev, extra=''): ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" - params = { "ssid": "DPPNET01", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "DPP", - "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign_pub, - "dpp_netaccesskey": ap_netaccesskey } + params = {"ssid": "DPPNET01", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "DPP", + "rsn_pairwise": "CCMP", + "dpp_connector": ap_connector, + "dpp_csign": csign_pub, + "dpp_netaccesskey": ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1142,14 +1142,14 @@ def run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev, apdev, extra=None): ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" - params = { "ssid": "DPPNET01", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "DPP", - "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign_pub, - "dpp_netaccesskey": ap_netaccesskey } + params = {"ssid": "DPPNET01", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "DPP", + "rsn_pairwise": "CCMP", + "dpp_connector": ap_connector, + "dpp_csign": csign_pub, + "dpp_netaccesskey": ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1231,14 +1231,14 @@ def run_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev, resp_pending): ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" - params = { "ssid": "DPPNET01", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "DPP", - "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign_pub, - "dpp_netaccesskey": ap_netaccesskey } + params = {"ssid": "DPPNET01", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "DPP", + "rsn_pairwise": "CCMP", + "dpp_connector": ap_connector, + "dpp_csign": csign_pub, + "dpp_netaccesskey": ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1691,21 +1691,21 @@ def test_sigma_dut_dpp_proto_initiator(dev, apdev): """sigma_dut DPP protocol testing - Initiator""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("InvalidValue", "AuthenticationRequest", "WrappedData", - "BootstrapResult,OK,AuthResult,Errorsent", - None), - ("InvalidValue", "AuthenticationConfirm", "WrappedData", - "BootstrapResult,OK,AuthResult,Errorsent", - None), - ("MissingAttribute", "AuthenticationRequest", "InitCapabilities", - "BootstrapResult,OK,AuthResult,Errorsent", - "Missing or invalid I-capabilities"), - ("InvalidValue", "AuthenticationConfirm", "InitAuthTag", - "BootstrapResult,OK,AuthResult,Errorsent", - "Mismatching Initiator Authenticating Tag"), - ("MissingAttribute", "ConfigurationResponse", "EnrolleeNonce", - "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", - "Missing or invalid Enrollee Nonce attribute") ] + tests = [("InvalidValue", "AuthenticationRequest", "WrappedData", + "BootstrapResult,OK,AuthResult,Errorsent", + None), + ("InvalidValue", "AuthenticationConfirm", "WrappedData", + "BootstrapResult,OK,AuthResult,Errorsent", + None), + ("MissingAttribute", "AuthenticationRequest", "InitCapabilities", + "BootstrapResult,OK,AuthResult,Errorsent", + "Missing or invalid I-capabilities"), + ("InvalidValue", "AuthenticationConfirm", "InitAuthTag", + "BootstrapResult,OK,AuthResult,Errorsent", + "Mismatching Initiator Authenticating Tag"), + ("MissingAttribute", "ConfigurationResponse", "EnrolleeNonce", + "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", + "Missing or invalid Enrollee Nonce attribute")] for step, frame, attr, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -1745,12 +1745,12 @@ def test_sigma_dut_dpp_proto_responder(dev, apdev): """sigma_dut DPP protocol testing - Responder""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("MissingAttribute", "AuthenticationResponse", "DPPStatus", - "BootstrapResult,OK,AuthResult,Errorsent", - "Missing or invalid required DPP Status attribute"), - ("MissingAttribute", "ConfigurationRequest", "EnrolleeNonce", - "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", - "Missing or invalid Enrollee Nonce attribute") ] + tests = [("MissingAttribute", "AuthenticationResponse", "DPPStatus", + "BootstrapResult,OK,AuthResult,Errorsent", + "Missing or invalid required DPP Status attribute"), + ("MissingAttribute", "ConfigurationRequest", "EnrolleeNonce", + "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", + "Missing or invalid Enrollee Nonce attribute")] for step, frame, attr, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -1790,12 +1790,12 @@ def test_sigma_dut_dpp_proto_stop_at_initiator(dev, apdev): """sigma_dut DPP protocol testing - Stop at RX on Initiator""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("AuthenticationResponse", - "BootstrapResult,OK,AuthResult,Errorsent", - None), - ("ConfigurationRequest", - "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", - None)] + tests = [("AuthenticationResponse", + "BootstrapResult,OK,AuthResult,Errorsent", + None), + ("ConfigurationRequest", + "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", + None)] for frame, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -1833,9 +1833,9 @@ def test_sigma_dut_dpp_proto_stop_at_initiator_enrollee(dev, apdev): """sigma_dut DPP protocol testing - Stop at TX on Initiator/Enrollee""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("AuthenticationConfirm", - "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponse", - None) ] + tests = [("AuthenticationConfirm", + "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponse", + None)] for frame, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -1875,12 +1875,12 @@ def test_sigma_dut_dpp_proto_stop_at_responder(dev, apdev): """sigma_dut DPP protocol testing - Stop at RX on Responder""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("AuthenticationRequest", - "BootstrapResult,OK,AuthResult,Errorsent", - None), - ("AuthenticationConfirm", - "BootstrapResult,OK,AuthResult,Errorsent", - None) ] + tests = [("AuthenticationRequest", + "BootstrapResult,OK,AuthResult,Errorsent", + None), + ("AuthenticationConfirm", + "BootstrapResult,OK,AuthResult,Errorsent", + None)] for frame, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -1934,15 +1934,15 @@ def test_sigma_dut_dpp_proto_initiator_pkex(dev, apdev): """sigma_dut DPP protocol testing - Initiator (PKEX)""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("InvalidValue", "PKEXCRRequest", "WrappedData", - "BootstrapResult,Errorsent", - None), - ("MissingAttribute", "PKEXExchangeRequest", "FiniteCyclicGroup", - "BootstrapResult,Errorsent", - "Missing or invalid Finite Cyclic Group attribute"), - ("MissingAttribute", "PKEXCRRequest", "BSKey", - "BootstrapResult,Errorsent", - "No valid peer bootstrapping key found") ] + tests = [("InvalidValue", "PKEXCRRequest", "WrappedData", + "BootstrapResult,Errorsent", + None), + ("MissingAttribute", "PKEXExchangeRequest", "FiniteCyclicGroup", + "BootstrapResult,Errorsent", + "Missing or invalid Finite Cyclic Group attribute"), + ("MissingAttribute", "PKEXCRRequest", "BSKey", + "BootstrapResult,Errorsent", + "No valid peer bootstrapping key found")] for step, frame, attr, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -1981,15 +1981,15 @@ def test_sigma_dut_dpp_proto_responder_pkex(dev, apdev): """sigma_dut DPP protocol testing - Responder (PKEX)""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - tests = [ ("InvalidValue", "PKEXCRResponse", "WrappedData", - "BootstrapResult,Errorsent", - None), - ("MissingAttribute", "PKEXExchangeResponse", "DPPStatus", - "BootstrapResult,Errorsent", - "No DPP Status attribute"), - ("MissingAttribute", "PKEXCRResponse", "BSKey", - "BootstrapResult,Errorsent", - "No valid peer bootstrapping key found") ] + tests = [("InvalidValue", "PKEXCRResponse", "WrappedData", + "BootstrapResult,Errorsent", + None), + ("MissingAttribute", "PKEXExchangeResponse", "DPPStatus", + "BootstrapResult,Errorsent", + "No DPP Status attribute"), + ("MissingAttribute", "PKEXCRResponse", "BSKey", + "BootstrapResult,Errorsent", + "No valid peer bootstrapping key found")] for step, frame, attr, result, fail in tests: dev[0].request("FLUSH") dev[1].request("FLUSH") @@ -2025,14 +2025,14 @@ def init_sigma_dut_dpp_proto_peer_disc_req(dev, apdev): ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" - params = { "ssid": "DPPNET01", - "wpa": "2", - "ieee80211w": "2", - "wpa_key_mgmt": "DPP", - "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign_pub, - "dpp_netaccesskey": ap_netaccesskey } + params = {"ssid": "DPPNET01", + "wpa": "2", + "ieee80211w": "2", + "wpa_key_mgmt": "DPP", + "rsn_pairwise": "CCMP", + "dpp_connector": ap_connector, + "dpp_csign": csign_pub, + "dpp_netaccesskey": ap_netaccesskey} try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -2077,7 +2077,7 @@ def test_sigma_dut_dpp_self_config(dev, apdev): """sigma_dut DPP Configurator enrolling an AP and using self-configuration""" 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) sigma = start_sigma_dut(dev[0].ifname) @@ -2179,9 +2179,9 @@ def test_sigma_dut_wps_pbc(dev, apdev): def run_sigma_dut_wps_pbc(dev, apdev): ssid = "test-wps-conf" 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" }) + {"ssid": "wps", "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) hapd.request("WPS_PBC") ifname = dev[0].ifname @@ -2200,7 +2200,7 @@ def run_sigma_dut_wps_pbc(dev, apdev): def test_sigma_dut_sta_scan_bss(dev, apdev): """sigma_dut sta_scan_bss""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test"}) sigma = start_sigma_dut(dev[0].ifname) try: cmd = "sta_scan_bss,Interface,%s,BSSID,%s" % (dev[0].ifname, \ @@ -2412,8 +2412,8 @@ def run_sigma_dut_venue_url(dev, apdev): url2 = "https://example.org/venue-info/" params["venue_group"] = str(venue_group) params["venue_type"] = str(venue_type) - params["venue_name"] = [ lang1 + ":" + name1, lang2 + ":" + name2 ] - params["venue_url"] = [ "1:" + url1, "2:" + url2 ] + params["venue_name"] = [lang1 + ":" + name1, lang2 + ":" + name2] + params["venue_url"] = ["1:" + url1, "2:" + url2] hapd = hostapd.add_ap(apdev[0], params) diff --git a/tests/hwsim/test_ssid.py b/tests/hwsim/test_ssid.py index 68034e2c9..d4ee4e370 100644 --- a/tests/hwsim/test_ssid.py +++ b/tests/hwsim/test_ssid.py @@ -14,13 +14,13 @@ import hostapd @remote_compatible def test_ssid_hex_encoded(dev, apdev): """SSID configuration using hex encoded version""" - hostapd.add_ap(apdev[0], { "ssid2": '68656c6c6f' }) + hostapd.add_ap(apdev[0], {"ssid2": '68656c6c6f'}) dev[0].connect("hello", key_mgmt="NONE", scan_freq="2412") dev[1].connect(ssid2="68656c6c6f", key_mgmt="NONE", scan_freq="2412") def test_ssid_printf_encoded(dev, apdev): """SSID configuration using printf encoded version""" - hostapd.add_ap(apdev[0], { "ssid2": 'P"\\0hello\\nthere"' }) + hostapd.add_ap(apdev[0], {"ssid2": 'P"\\0hello\\nthere"'}) dev[0].connect(ssid2="0068656c6c6f0a7468657265", key_mgmt="NONE", scan_freq="2412") dev[1].connect(ssid2='P"\\x00hello\\nthere"', key_mgmt="NONE", @@ -34,14 +34,14 @@ def test_ssid_printf_encoded(dev, apdev): @remote_compatible def test_ssid_1_octet(dev, apdev): """SSID with one octet""" - hostapd.add_ap(apdev[0], { "ssid": '1' }) + hostapd.add_ap(apdev[0], {"ssid": '1'}) dev[0].connect("1", key_mgmt="NONE", scan_freq="2412") @remote_compatible def test_ssid_32_octets(dev, apdev): """SSID with 32 octets""" hostapd.add_ap(apdev[0], - { "ssid": '1234567890abcdef1234567890ABCDEF' }) + {"ssid": '1234567890abcdef1234567890ABCDEF'}) dev[0].connect("1234567890abcdef1234567890ABCDEF", key_mgmt="NONE", scan_freq="2412") @@ -49,19 +49,19 @@ def test_ssid_32_octets_nul_term(dev, apdev): """SSID with 32 octets with nul at the end""" ssid = 'P"1234567890abcdef1234567890ABCDE\\x00"' hostapd.add_ap(apdev[0], - { "ssid2": ssid }) + {"ssid2": ssid}) dev[0].connect(ssid2=ssid, key_mgmt="NONE", scan_freq="2412") @remote_compatible def test_ssid_utf8(dev, apdev): """SSID with UTF8 encoding""" - hapd = hostapd.add_ap(apdev[0], { "ssid": 'testi-åäöÅÄÖ-testi', - "utf8_ssid": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'testi-åäöÅÄÖ-testi', + "utf8_ssid": "1"}) dev[0].connect("testi-åäöÅÄÖ-testi", key_mgmt="NONE", scan_freq="2412") dev[1].connect(ssid2="74657374692dc3a5c3a4c3b6c385c384c3962d7465737469", key_mgmt="NONE", scan_freq="2412") # verify ctrl_iface for coverage - addrs = [ dev[0].p2p_interface_addr(), dev[1].p2p_interface_addr() ] + addrs = [dev[0].p2p_interface_addr(), dev[1].p2p_interface_addr()] sta = hapd.get_sta(None) if sta['addr'] not in addrs: raise Exception("Unexpected STA address") @@ -89,8 +89,8 @@ def clear_scan_cache(hapd, dev): @remote_compatible def test_ssid_hidden(dev, apdev): """Hidden SSID""" - 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[1].connect("secret", key_mgmt="NONE", scan_freq="2412", wait_connect=False) dev[0].connect("secret", key_mgmt="NONE", scan_freq="2412", scan_ssid="1") @@ -102,8 +102,8 @@ def test_ssid_hidden(dev, apdev): @remote_compatible def test_ssid_hidden2(dev, apdev): """Hidden SSID using zero octets as payload""" - hapd = hostapd.add_ap(apdev[0], { "ssid": 'secret2', - "ignore_broadcast_ssid": "2" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": 'secret2', + "ignore_broadcast_ssid": "2"}) dev[1].connect("secret2", key_mgmt="NONE", scan_freq="2412", wait_connect=False) dev[0].connect("secret2", key_mgmt="NONE", scan_freq="2412", scan_ssid="1") diff --git a/tests/hwsim/test_sta_dynamic.py b/tests/hwsim/test_sta_dynamic.py index efb2f00f7..0093b14da 100644 --- a/tests/hwsim/test_sta_dynamic.py +++ b/tests/hwsim/test_sta_dynamic.py @@ -26,7 +26,7 @@ def test_sta_dynamic(dev, apdev): def test_sta_ap_scan_0(dev, apdev): """Dynamically added wpa_supplicant interface with AP_SCAN 0 connection""" - hostapd.add_ap(apdev[0], { "ssid": "test" }) + hostapd.add_ap(apdev[0], {"ssid": "test"}) bssid = apdev[0]['bssid'] logger.info("Create a dynamic wpa_supplicant interface and connect") @@ -48,7 +48,7 @@ def test_sta_ap_scan_0(dev, apdev): def test_sta_ap_scan_2(dev, apdev): """Dynamically added wpa_supplicant interface with AP_SCAN 2 connection""" - hostapd.add_ap(apdev[0], { "ssid": "test" }) + hostapd.add_ap(apdev[0], {"ssid": "test"}) bssid = apdev[0]['bssid'] logger.info("Create a dynamic wpa_supplicant interface and connect") @@ -80,7 +80,7 @@ def test_sta_ap_scan_2(dev, apdev): def test_sta_ap_scan_2b(dev, apdev): """Dynamically added wpa_supplicant interface with AP_SCAN 2 operation""" - hapd = hostapd.add_ap(apdev[0], { "ssid": "test" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test"}) bssid = apdev[0]['bssid'] logger.info("Create a dynamic wpa_supplicant interface and connect") diff --git a/tests/hwsim/test_suite_b.py b/tests/hwsim/test_suite_b.py index b0633d2ee..e87378624 100644 --- a/tests/hwsim/test_suite_b.py +++ b/tests/hwsim/test_suite_b.py @@ -27,7 +27,7 @@ def check_suite_b_tls_lib(dev, dhe=False, level128=False): if not tls.startswith("OpenSSL"): raise HwsimSkip("TLS library not supported for Suite B: " + tls) supported = False - for ver in [ '1.0.2', '1.1.0', '1.1.1' ]: + for ver in ['1.0.2', '1.1.0', '1.1.1']: if "build=OpenSSL " + ver in tls and "run=OpenSSL " + ver in tls: supported = True break @@ -38,20 +38,20 @@ def check_suite_b_tls_lib(dev, dhe=False, level128=False): raise HwsimSkip("OpenSSL version not supported for Suite B: " + tls) def suite_b_ap_params(): - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B", - "rsn_pairwise": "GCMP", - "group_mgmt_cipher": "BIP-GMAC-128", - "ieee80211w": "2", - "ieee8021x": "1", - "openssl_ciphers": "SUITEB128", - #"dh_file": "auth_serv/dh.conf", - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ec-ca.pem", - "server_cert": "auth_serv/ec-server.pem", - "private_key": "auth_serv/ec-server.key" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B", + "rsn_pairwise": "GCMP", + "group_mgmt_cipher": "BIP-GMAC-128", + "ieee80211w": "2", + "ieee8021x": "1", + "openssl_ciphers": "SUITEB128", + #"dh_file": "auth_serv/dh.conf", + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ec-ca.pem", + "server_cert": "auth_serv/ec-server.pem", + "private_key": "auth_serv/ec-server.key"} return params def test_suite_b(dev, apdev): @@ -126,17 +126,17 @@ def test_suite_b_radius(dev, apdev): params = suite_b_as_params() hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B", - "rsn_pairwise": "GCMP", - "group_mgmt_cipher": "BIP-GMAC-128", - "ieee80211w": "2", - "ieee8021x": "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "18129", - 'auth_server_shared_secret': "radius", - 'nas_identifier': "nas.w1.fi" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B", + "rsn_pairwise": "GCMP", + "group_mgmt_cipher": "BIP-GMAC-128", + "ieee80211w": "2", + "ieee8021x": "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "18129", + 'auth_server_shared_secret': "radius", + 'nas_identifier': "nas.w1.fi"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B", ieee80211w="2", @@ -157,19 +157,19 @@ def check_suite_b_192_capa(dev, dhe=False): check_suite_b_tls_lib(dev, dhe=dhe) def suite_b_192_ap_params(): - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - "openssl_ciphers": "SUITEB192", - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/ec2-ca.pem", - "server_cert": "auth_serv/ec2-server.pem", - "private_key": "auth_serv/ec2-server.key" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + "openssl_ciphers": "SUITEB192", + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/ec2-ca.pem", + "server_cert": "auth_serv/ec2-server.pem", + "private_key": "auth_serv/ec2-server.key"} return params def test_suite_b_192(dev, apdev): @@ -238,17 +238,17 @@ def test_suite_b_192_radius(dev, apdev): params['openssl_ciphers'] = 'SUITEB192' hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "18129", - 'auth_server_shared_secret': "radius", - 'nas_identifier': "nas.w1.fi" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "18129", + 'auth_server_shared_secret': "radius", + 'nas_identifier': "nas.w1.fi"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", @@ -271,17 +271,17 @@ def test_suite_b_192_radius_and_p256_cert(dev, apdev): params['openssl_ciphers'] = 'SUITEB192' hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "18129", - 'auth_server_shared_secret': "radius", - 'nas_identifier': "nas.w1.fi" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "18129", + 'auth_server_shared_secret': "radius", + 'nas_identifier': "nas.w1.fi"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", @@ -375,20 +375,20 @@ def test_suite_b_192_mic_failure(dev, apdev): dev[0].wait_disconnected() def suite_b_192_rsa_ap_params(): - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - "tls_flags": "[SUITEB]", - "dh_file": "auth_serv/dh_param_3072.pem", - "eap_server": "1", - "eap_user_file": "auth_serv/eap_user.conf", - "ca_cert": "auth_serv/rsa3072-ca.pem", - "server_cert": "auth_serv/rsa3072-server.pem", - "private_key": "auth_serv/rsa3072-server.key" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + "tls_flags": "[SUITEB]", + "dh_file": "auth_serv/dh_param_3072.pem", + "eap_server": "1", + "eap_user_file": "auth_serv/eap_user.conf", + "ca_cert": "auth_serv/rsa3072-ca.pem", + "server_cert": "auth_serv/rsa3072-server.pem", + "private_key": "auth_serv/rsa3072-server.key"} return params def test_suite_b_192_rsa(dev, apdev): @@ -523,17 +523,17 @@ def test_suite_b_192_rsa_radius(dev, apdev): hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "18129", - 'auth_server_shared_secret': "radius", - 'nas_identifier': "nas.w1.fi" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "18129", + 'auth_server_shared_secret': "radius", + 'nas_identifier': "nas.w1.fi"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", @@ -577,17 +577,17 @@ def run_suite_b_192_rsa_radius_rsa2048_client(dev, apdev, ecdhe): hostapd.add_ap(apdev[1], params) - params = { "ssid": "test-suite-b", - "wpa": "2", - "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", - "rsn_pairwise": "GCMP-256", - "group_mgmt_cipher": "BIP-GMAC-256", - "ieee80211w": "2", - "ieee8021x": "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "18129", - 'auth_server_shared_secret': "radius", - 'nas_identifier': "nas.w1.fi" } + params = {"ssid": "test-suite-b", + "wpa": "2", + "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", + "rsn_pairwise": "GCMP-256", + "group_mgmt_cipher": "BIP-GMAC-256", + "ieee80211w": "2", + "ieee8021x": "1", + 'auth_server_addr': "127.0.0.1", + 'auth_server_port': "18129", + 'auth_server_shared_secret': "radius", + 'nas_identifier': "nas.w1.fi"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", diff --git a/tests/hwsim/test_tnc.py b/tests/hwsim/test_tnc.py index c26f8a0ce..0c444bb7c 100644 --- a/tests/hwsim/test_tnc.py +++ b/tests/hwsim/test_tnc.py @@ -47,8 +47,8 @@ def test_tnc_peap_soh_errors(dev, apdev): params["tnc"] = "1" hostapd.add_ap(apdev[0], params) - tests = [ (1, "tncc_build_soh"), - (1, "eap_msg_alloc;=eap_peap_phase2_request") ] + tests = [(1, "tncc_build_soh"), + (1, "eap_msg_alloc;=eap_peap_phase2_request")] for count, func in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -121,36 +121,36 @@ def test_tnc_ttls_errors(dev, apdev): params["fragment_size"] = "150" hostapd.add_ap(apdev[0], params) - tests = [ (1, "eap_ttls_process_phase2_eap;eap_ttls_process_tnc_start", - "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), - (1, "eap_ttls_process_phase2_eap;eap_ttls_process_tnc_start", - "mschap user", "auth=MSCHAP"), - (1, "=eap_tnc_init", "chap user", "auth=CHAP"), - (1, "tncc_init;eap_tnc_init", "pap user", "auth=PAP"), - (1, "eap_msg_alloc;eap_tnc_build_frag_ack", - "pap user", "auth=PAP"), - (1, "eap_msg_alloc;eap_tnc_build_msg", - "pap user", "auth=PAP"), - (1, "wpabuf_alloc;=eap_tnc_process_fragment", - "pap user", "auth=PAP"), - (1, "eap_msg_alloc;=eap_tnc_process", "pap user", "auth=PAP"), - (1, "wpabuf_alloc;=eap_tnc_process", "pap user", "auth=PAP"), - (1, "dup_binstr;tncc_process_if_tnccs", "pap user", "auth=PAP"), - (1, "tncc_get_base64;tncc_process_if_tnccs", - "pap user", "auth=PAP"), - (1, "tncc_if_tnccs_start", "pap user", "auth=PAP"), - (1, "tncc_if_tnccs_end", "pap user", "auth=PAP"), - (1, "tncc_parse_imc", "pap user", "auth=PAP"), - (2, "tncc_parse_imc", "pap user", "auth=PAP"), - (3, "tncc_parse_imc", "pap user", "auth=PAP"), - (1, "os_readfile;tncc_read_config", "pap user", "auth=PAP"), - (1, "tncc_init", "pap user", "auth=PAP"), - (1, "TNC_TNCC_ReportMessageTypes", "pap user", "auth=PAP"), - (1, "base64_gen_encode;?base64_encode;TNC_TNCC_SendMessage", - "pap user", "auth=PAP"), - (1, "=TNC_TNCC_SendMessage", "pap user", "auth=PAP"), - (1, "tncc_get_base64;tncc_process_if_tnccs", - "pap user", "auth=PAP") ] + tests = [(1, "eap_ttls_process_phase2_eap;eap_ttls_process_tnc_start", + "DOMAIN\mschapv2 user", "auth=MSCHAPV2"), + (1, "eap_ttls_process_phase2_eap;eap_ttls_process_tnc_start", + "mschap user", "auth=MSCHAP"), + (1, "=eap_tnc_init", "chap user", "auth=CHAP"), + (1, "tncc_init;eap_tnc_init", "pap user", "auth=PAP"), + (1, "eap_msg_alloc;eap_tnc_build_frag_ack", + "pap user", "auth=PAP"), + (1, "eap_msg_alloc;eap_tnc_build_msg", + "pap user", "auth=PAP"), + (1, "wpabuf_alloc;=eap_tnc_process_fragment", + "pap user", "auth=PAP"), + (1, "eap_msg_alloc;=eap_tnc_process", "pap user", "auth=PAP"), + (1, "wpabuf_alloc;=eap_tnc_process", "pap user", "auth=PAP"), + (1, "dup_binstr;tncc_process_if_tnccs", "pap user", "auth=PAP"), + (1, "tncc_get_base64;tncc_process_if_tnccs", + "pap user", "auth=PAP"), + (1, "tncc_if_tnccs_start", "pap user", "auth=PAP"), + (1, "tncc_if_tnccs_end", "pap user", "auth=PAP"), + (1, "tncc_parse_imc", "pap user", "auth=PAP"), + (2, "tncc_parse_imc", "pap user", "auth=PAP"), + (3, "tncc_parse_imc", "pap user", "auth=PAP"), + (1, "os_readfile;tncc_read_config", "pap user", "auth=PAP"), + (1, "tncc_init", "pap user", "auth=PAP"), + (1, "TNC_TNCC_ReportMessageTypes", "pap user", "auth=PAP"), + (1, "base64_gen_encode;?base64_encode;TNC_TNCC_SendMessage", + "pap user", "auth=PAP"), + (1, "=TNC_TNCC_SendMessage", "pap user", "auth=PAP"), + (1, "tncc_get_base64;tncc_process_if_tnccs", + "pap user", "auth=PAP")] for count, func, identity, phase2 in tests: with alloc_fail(dev[0], count, func): dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", @@ -174,7 +174,7 @@ def test_tnc_fast(dev, apdev): check_eap_capa(dev[0], "FAST") params = int_eap_server_params() params["tnc"] = "1" - params["pac_opaque_encr_key"] ="000102030405060708090a0b0c0d0e00" + params["pac_opaque_encr_key"] = "000102030405060708090a0b0c0d0e00" params["eap_fast_a_id"] = "101112131415161718191a1b1c1d1e00" params["eap_fast_a_id_info"] = "test server2" diff --git a/tests/hwsim/test_wep.py b/tests/hwsim/test_wep.py index 8f2fa217a..318018460 100644 --- a/tests/hwsim/test_wep.py +++ b/tests/hwsim/test_wep.py @@ -16,8 +16,8 @@ import hwsim_utils def test_wep_open_auth(dev, apdev): """WEP Open System authentication""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-open", - "wep_key0": '"hello"' }) + {"ssid": "wep-open", + "wep_key0": '"hello"'}) dev[0].flush_scan_cache() dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"', scan_freq="2412") @@ -35,9 +35,9 @@ def test_wep_open_auth(dev, apdev): def test_wep_shared_key_auth(dev, apdev): """WEP Shared Key authentication""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-shared-key", - "wep_key0": '"hello12345678"', - "auth_algs": "2" }) + {"ssid": "wep-shared-key", + "wep_key0": '"hello12345678"', + "auth_algs": "2"}) dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", wep_key0='"hello12345678"', scan_freq="2412") @@ -50,9 +50,9 @@ def test_wep_shared_key_auth(dev, apdev): def test_wep_shared_key_auth_not_allowed(dev, apdev): """WEP Shared Key authentication not allowed""" hostapd.add_ap(apdev[0], - { "ssid": "wep-shared-key", - "wep_key0": '"hello12345678"', - "auth_algs": "1" }) + {"ssid": "wep-shared-key", + "wep_key0": '"hello12345678"', + "auth_algs": "1"}) dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", wep_key0='"hello12345678"', scan_freq="2412", wait_connect=False) @@ -63,10 +63,10 @@ def test_wep_shared_key_auth_not_allowed(dev, apdev): def test_wep_shared_key_auth_multi_key(dev, apdev): """WEP Shared Key authentication with multiple keys""" 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"}) dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", wep_key0='"hello12345678"', scan_freq="2412") @@ -94,17 +94,17 @@ def test_wep_ht_vht(dev, apdev): dev[0].flush_scan_cache() try: hapd = None - params = { "ssid": "test-vht40-wep", - "country_code": "SE", - "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", - "wep_key0": '"hello"' } + params = {"ssid": "test-vht40-wep", + "country_code": "SE", + "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", + "wep_key0": '"hello"'} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-vht40-wep", scan_freq="5180", key_mgmt="NONE", wep_key0='"hello"') @@ -127,8 +127,8 @@ def test_wep_ht_vht(dev, apdev): def test_wep_ifdown(dev, apdev): """AP with WEP and external ifconfig down""" hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-open", - "wep_key0": '"hello"' }) + {"ssid": "wep-open", + "wep_key0": '"hello"'}) dev[0].flush_scan_cache() id = dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"', scan_freq="2412") diff --git a/tests/hwsim/test_wext.py b/tests/hwsim/test_wext.py index 2bf3451ef..1668ccd69 100644 --- a/tests/hwsim/test_wext.py +++ b/tests/hwsim/test_wext.py @@ -30,7 +30,7 @@ def test_wext_open(dev, apdev): """WEXT driver interface with open network""" wpas = get_wext_interface() - params = { "ssid": "wext-open" } + params = {"ssid": "wext-open"} hapd = hostapd.add_ap(apdev[0], params) wpas.connect("wext-open", key_mgmt="NONE") @@ -151,8 +151,8 @@ def test_wext_wep_open_auth(dev, apdev): wpas = get_wext_interface() hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-open", - "wep_key0": '"hello"' }) + {"ssid": "wep-open", + "wep_key0": '"hello"'}) wpas.connect("wep-open", key_mgmt="NONE", wep_key0='"hello"', scan_freq="2412") hwsim_utils.test_connectivity(wpas, hapd) @@ -164,9 +164,9 @@ def test_wext_wep_shared_key_auth(dev, apdev): wpas = get_wext_interface() hapd = hostapd.add_ap(apdev[0], - { "ssid": "wep-shared-key", - "wep_key0": '"hello12345678"', - "auth_algs": "2" }) + {"ssid": "wep-shared-key", + "wep_key0": '"hello12345678"', + "auth_algs": "2"}) wpas.connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", wep_key0='"hello12345678"', scan_freq="2412") hwsim_utils.test_connectivity(wpas, hapd) @@ -197,10 +197,10 @@ def test_wext_scan_hidden(dev, apdev): """WEXT with hidden SSID""" wpas = get_wext_interface() - hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan", - "ignore_broadcast_ssid": "1" }) - hapd2 = hostapd.add_ap(apdev[1], { "ssid": "test-scan2", - "ignore_broadcast_ssid": "1" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "test-scan", + "ignore_broadcast_ssid": "1"}) + hapd2 = hostapd.add_ap(apdev[1], {"ssid": "test-scan2", + "ignore_broadcast_ssid": "1"}) id1 = wpas.connect("test-scan", key_mgmt="NONE", scan_ssid="1", only_add_network=True) @@ -234,7 +234,7 @@ def test_wext_rfkill(dev, apdev): wpas = get_wext_interface() - hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) + hapd = hostapd.add_ap(apdev[0], {"ssid": "open"}) wpas.connect("open", key_mgmt="NONE", scan_freq="2412") try: logger.info("rfkill block") diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py index 3550d7b14..0a8810194 100644 --- a/tests/hwsim/test_wmediumd.py +++ b/tests/hwsim/test_wmediumd.py @@ -19,7 +19,7 @@ class LocalVariables: CFG = """ ifaces : { - ids = ["%s", "%s" ] + ids = ["%s", "%s"] links = ( (0, 1, 30) ) @@ -47,7 +47,7 @@ model: CFG3 = """ ifaces : { - ids = ["%s", "%s", "%s", "%s", "%s" ] + ids = ["%s", "%s", "%s", "%s", "%s"] } model: @@ -284,8 +284,8 @@ def _test_wmediumd_path_ttl(dev, ok): raise Exception("Unexpected mode: " + mode) # set mesh path request ttl - subprocess.check_call([ "iw", "dev", dev[0].ifname, "set", "mesh_param", - "mesh_element_ttl=" + ("4" if ok else "3") ]) + subprocess.check_call(["iw", "dev", dev[0].ifname, "set", "mesh_param", + "mesh_element_ttl=" + ("4" if ok else "3")]) # Check for peer connected for i in range(0, 5): @@ -350,7 +350,7 @@ def test_wmediumd_path_rann(dev, apdev, params): filt = "wlan.fc.type_subtype == 0x000d && " + \ "wlan_mgt.fixed.mesh_action == 0x01 && " + \ "wlan_mgt.tag.number == 126" - out = run_tshark(capfile, filt, [ "wlan.rann.root_sta" ]) + out = run_tshark(capfile, filt, ["wlan.rann.root_sta"]) if out is None: raise Exception("No captured data found\n") if out.find(dev[2].own_addr()) == -1 or \ @@ -363,7 +363,7 @@ def test_wmediumd_path_rann(dev, apdev, params): "wlan.fc.type_subtype == 0x000d && " + \ "wlan_mgt.fixed.mesh_action == 0x01 && " + \ "wlan_mgt.tag.number == 126" - out = run_tshark(capfile, filt, [ "frame.time_relative" ]) + out = run_tshark(capfile, filt, ["frame.time_relative"]) if out is None: raise Exception("No captured data found\n") lines = out.splitlines() @@ -380,7 +380,7 @@ def test_wmediumd_path_rann(dev, apdev, params): "wlan.fc.type_subtype == 0x000d && " + \ "wlan_mgt.fixed.mesh_action == 0x01 && " + \ "wlan_mgt.tag.number == 130" - out = run_tshark(capfile, filt, [ "wlan.sa", "wlan.da" ]) + out = run_tshark(capfile, filt, ["wlan.sa", "wlan.da"]) if out is None: raise Exception("No captured data found\n") if len(out) > 0: diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py index ea959e76a..952cb86cb 100644 --- a/tests/hwsim/test_wnm.py +++ b/tests/hwsim/test_wnm.py @@ -40,11 +40,11 @@ def clear_regdom_state(dev, hapd, hapd2): @remote_compatible def test_wnm_bss_transition_mgmt(dev, apdev): """WNM BSS Transition Management""" - params = { "ssid": "test-wnm", - "time_advertisement": "2", - "time_zone": "EST5", - "wnm_sleep_mode": "1", - "bss_transition": "1" } + params = {"ssid": "test-wnm", + "time_advertisement": "2", + "time_zone": "EST5", + "wnm_sleep_mode": "1", + "bss_transition": "1"} hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -52,7 +52,7 @@ def test_wnm_bss_transition_mgmt(dev, apdev): def test_wnm_bss_transition_mgmt_oom(dev, apdev): """WNM BSS Transition Management OOM""" - params = { "ssid": "test-wnm", "bss_transition": "1" } + params = {"ssid": "test-wnm", "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -63,11 +63,11 @@ def test_wnm_bss_transition_mgmt_oom(dev, apdev): @remote_compatible def test_wnm_disassoc_imminent(dev, apdev): """WNM Disassociation Imminent""" - params = { "ssid": "test-wnm", - "time_advertisement": "2", - "time_zone": "EST5", - "wnm_sleep_mode": "1", - "bss_transition": "1" } + params = {"ssid": "test-wnm", + "time_advertisement": "2", + "time_zone": "EST5", + "wnm_sleep_mode": "1", + "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -84,7 +84,7 @@ def test_wnm_disassoc_imminent(dev, apdev): def test_wnm_disassoc_imminent_fail(dev, apdev): """WNM Disassociation Imminent failure""" - params = { "ssid": "test-wnm", "bss_transition": "1" } + params = {"ssid": "test-wnm", "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -96,11 +96,11 @@ def test_wnm_disassoc_imminent_fail(dev, apdev): @remote_compatible def test_wnm_ess_disassoc_imminent(dev, apdev): """WNM ESS Disassociation Imminent""" - params = { "ssid": "test-wnm", - "time_advertisement": "2", - "time_zone": "EST5", - "wnm_sleep_mode": "1", - "bss_transition": "1" } + params = {"ssid": "test-wnm", + "time_advertisement": "2", + "time_zone": "EST5", + "wnm_sleep_mode": "1", + "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -117,7 +117,7 @@ def test_wnm_ess_disassoc_imminent(dev, apdev): def test_wnm_ess_disassoc_imminent_fail(dev, apdev): """WNM ESS Disassociation Imminent failure""" - params = { "ssid": "test-wnm", "bss_transition": "1" } + params = {"ssid": "test-wnm", "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -130,8 +130,8 @@ def test_wnm_ess_disassoc_imminent_fail(dev, apdev): def test_wnm_ess_disassoc_imminent_reject(dev, apdev): """WNM ESS Disassociation Imminent getting rejected""" - params = { "ssid": "test-wnm", - "bss_transition": "1" } + params = {"ssid": "test-wnm", + "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -209,31 +209,31 @@ def check_wnm_sleep_mode_enter_exit(hapd, dev, interval=None, tfs_req=None): @remote_compatible def test_wnm_sleep_mode_open(dev, apdev): """WNM Sleep Mode - open""" - params = { "ssid": "test-wnm", - "time_advertisement": "2", - "time_zone": "EST5", - "wnm_sleep_mode": "1", - "bss_transition": "1" } + params = {"ssid": "test-wnm", + "time_advertisement": "2", + "time_zone": "EST5", + "wnm_sleep_mode": "1", + "bss_transition": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", 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") check_wnm_sleep_mode_enter_exit(hapd, dev[0]) check_wnm_sleep_mode_enter_exit(hapd, dev[0], interval=100) check_wnm_sleep_mode_enter_exit(hapd, dev[0], tfs_req="5b17010001130e110000071122334455661122334455661234") - cmds = [ "foo", - "exit tfs_req=123 interval=10", - "enter tfs_req=qq interval=10" ] + cmds = ["foo", + "exit tfs_req=123 interval=10", + "enter tfs_req=qq interval=10"] for cmd in cmds: if "FAIL" not in dev[0].request("WNM_SLEEP " + cmd): raise Exception("Invalid WNM_SLEEP accepted") def test_wnm_sleep_mode_open_fail(dev, apdev): """WNM Sleep Mode - open (fail)""" - params = { "ssid": "test-wnm", "wnm_sleep_mode": "1" } + params = {"ssid": "test-wnm", "wnm_sleep_mode": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412") @@ -252,7 +252,7 @@ def test_wnm_sleep_mode_rsn(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm-rsn", psk="12345678", 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") check_wnm_sleep_mode_enter_exit(hapd, dev[0]) @@ -260,12 +260,12 @@ def test_wnm_sleep_mode_rsn(dev, apdev): @remote_compatible def test_wnm_sleep_mode_ap_oom(dev, apdev): """WNM Sleep Mode - AP side OOM""" - params = { "ssid": "test-wnm", - "wnm_sleep_mode": "1" } + params = {"ssid": "test-wnm", + "wnm_sleep_mode": "1"} hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("test-wnm", 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") with alloc_fail(hapd, 1, "ieee802_11_send_wnmsleep_resp"): @@ -294,7 +294,7 @@ def test_wnm_sleep_mode_rsn_pmf(dev, apdev): dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK-SHA256", proto="WPA2", 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") check_wnm_sleep_mode_enter_exit(hapd, dev[0]) @@ -324,13 +324,13 @@ def test_wnm_sleep_mode_rsn_ocv(dev, apdev): dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2", ocv="1", key_mgmt="WPA-PSK-SHA256", proto="WPA2", 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") check_wnm_sleep_mode_enter_exit(hapd, dev[0]) # Check if OCV succeeded or failed - ev = dev[0].wait_event([ "OCV failed" ], timeout=1) + ev = dev[0].wait_event(["OCV failed"], timeout=1) if ev is not None: raise Exception("OCI verification failed: " + ev) @@ -355,10 +355,10 @@ def test_wnm_sleep_mode_rsn_badocv(dev, apdev): dev[0].request("WNM_SLEEP enter") time.sleep(0.1) - msg = { 'fc': MGMT_SUBTYPE_ACTION << 4, - 'da': bssid, - 'sa': dev[0].own_addr(), - 'bssid': bssid } + msg = {'fc': MGMT_SUBTYPE_ACTION << 4, + 'da': bssid, + 'sa': dev[0].own_addr(), + 'bssid': bssid} logger.debug("WNM Sleep Mode Request - Missing OCI element") msg['payload'] = struct.pack("= 2: - ie,elen = struct.unpack('BB', data[0:2]) + ie, elen = struct.unpack('BB', data[0:2]) data = data[2:] if elen > len(data): break diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py index d659abbf0..5f56ffac1 100755 --- a/tests/hwsim/vm/parallel-vm.py +++ b/tests/hwsim/vm/parallel-vm.py @@ -19,65 +19,65 @@ import errno logger = logging.getLogger() # Test cases that take significantly longer time to execute than average. -long_tests = [ "ap_roam_open", - "wpas_mesh_password_mismatch_retry", - "wpas_mesh_password_mismatch", - "hostapd_oom_wpa2_psk_connect", - "ap_hs20_fetch_osu_stop", - "ap_roam_wpa2_psk", - "ibss_wpa_none_ccmp", - "nfc_wps_er_handover_pk_hash_mismatch_sta", - "go_neg_peers_force_diff_freq", - "p2p_cli_invite", - "sta_ap_scan_2b", - "ap_pmf_sta_unprot_deauth_burst", - "ap_bss_add_remove_during_ht_scan", - "wext_scan_hidden", - "autoscan_exponential", - "nfc_p2p_client", - "wnm_bss_keep_alive", - "ap_inactivity_disconnect", - "scan_bss_expiration_age", - "autoscan_periodic", - "discovery_group_client", - "concurrent_p2pcli", - "ap_bss_add_remove", - "wpas_ap_wps", - "wext_pmksa_cache", - "ibss_wpa_none", - "ap_ht_40mhz_intolerant_ap", - "ibss_rsn", - "discovery_pd_retries", - "ap_wps_setup_locked_timeout", - "ap_vht160", - "dfs_radar", - "dfs", - "dfs_ht40_minus", - "dfs_etsi", - "ap_acs_dfs", - "grpform_cred_ready_timeout", - "hostapd_oom_wpa2_eap_connect", - "wpas_ap_dfs", - "autogo_many", - "hostapd_oom_wpa2_eap", - "ibss_open", - "proxyarp_open_ebtables", - "proxyarp_open_ebtables_ipv6", - "radius_failover", - "obss_scan_40_intolerant", - "dbus_connect_oom", - "proxyarp_open", - "proxyarp_open_ipv6", - "ap_wps_iteration", - "ap_wps_iteration_error", - "ap_wps_pbc_timeout", - "ap_wps_http_timeout", - "p2p_go_move_reg_change", - "p2p_go_move_active", - "p2p_go_move_scm", - "p2p_go_move_scm_peer_supports", - "p2p_go_move_scm_peer_does_not_support", - "p2p_go_move_scm_multi" ] +long_tests = ["ap_roam_open", + "wpas_mesh_password_mismatch_retry", + "wpas_mesh_password_mismatch", + "hostapd_oom_wpa2_psk_connect", + "ap_hs20_fetch_osu_stop", + "ap_roam_wpa2_psk", + "ibss_wpa_none_ccmp", + "nfc_wps_er_handover_pk_hash_mismatch_sta", + "go_neg_peers_force_diff_freq", + "p2p_cli_invite", + "sta_ap_scan_2b", + "ap_pmf_sta_unprot_deauth_burst", + "ap_bss_add_remove_during_ht_scan", + "wext_scan_hidden", + "autoscan_exponential", + "nfc_p2p_client", + "wnm_bss_keep_alive", + "ap_inactivity_disconnect", + "scan_bss_expiration_age", + "autoscan_periodic", + "discovery_group_client", + "concurrent_p2pcli", + "ap_bss_add_remove", + "wpas_ap_wps", + "wext_pmksa_cache", + "ibss_wpa_none", + "ap_ht_40mhz_intolerant_ap", + "ibss_rsn", + "discovery_pd_retries", + "ap_wps_setup_locked_timeout", + "ap_vht160", + "dfs_radar", + "dfs", + "dfs_ht40_minus", + "dfs_etsi", + "ap_acs_dfs", + "grpform_cred_ready_timeout", + "hostapd_oom_wpa2_eap_connect", + "wpas_ap_dfs", + "autogo_many", + "hostapd_oom_wpa2_eap", + "ibss_open", + "proxyarp_open_ebtables", + "proxyarp_open_ebtables_ipv6", + "radius_failover", + "obss_scan_40_intolerant", + "dbus_connect_oom", + "proxyarp_open", + "proxyarp_open_ipv6", + "ap_wps_iteration", + "ap_wps_iteration_error", + "ap_wps_pbc_timeout", + "ap_wps_http_timeout", + "p2p_go_move_reg_change", + "p2p_go_move_active", + "p2p_go_move_scm", + "p2p_go_move_scm_peer_supports", + "p2p_go_move_scm_peer_does_not_support", + "p2p_go_move_scm_multi"] def get_failed(vm): failed = [] @@ -389,9 +389,9 @@ def main(): debug_level = logging.DEBUG extra_args = [] if args.valgrind: - extra_args += [ '--valgrind' ] + extra_args += ['--valgrind'] if args.long: - extra_args += [ '--long' ] + extra_args += ['--long'] if args.codecov: print("Code coverage - build separate binaries") logdir = os.path.join(dir, str(timestamp)) @@ -409,10 +409,9 @@ def main(): tests = args.params else: tests = [] - cmd = [ os.path.join(os.path.dirname(scriptsdir), 'run-tests.py'), - '-L' ] + cmd = [os.path.join(os.path.dirname(scriptsdir), 'run-tests.py'), '-L'] if args.testmodules: - cmd += [ "-f" ] + cmd += ["-f"] cmd += args.testmodules lst = subprocess.Popen(cmd, stdout=subprocess.PIPE) for l in lst.stdout.readlines(): @@ -454,7 +453,7 @@ def main(): '--ext', 'srv.%d' % (i + 1), '-i'] + codecov_args + extra_args if args.telnet: - cmd += [ '--telnet', str(args.telnet + i) ] + cmd += ['--telnet', str(args.telnet + i)] vm[i] = {} vm[i]['first_run_done'] = False vm[i]['proc'] = subprocess.Popen(cmd, @@ -466,7 +465,7 @@ def main(): vm[i]['err'] = "" vm[i]['failed'] = [] vm[i]['fail_seq'] = [] - for stream in [ vm[i]['proc'].stdout, vm[i]['proc'].stderr ]: + for stream in [vm[i]['proc'].stdout, vm[i]['proc'].stderr]: fd = stream.fileno() fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) diff --git a/tests/hwsim/wlantest.py b/tests/hwsim/wlantest.py index 95c09bb99..5bb268f85 100644 --- a/tests/hwsim/wlantest.py +++ b/tests/hwsim/wlantest.py @@ -241,4 +241,4 @@ class Wlantest: for tid in range(0, 17): tx[tid] = self.get_tx_tid(bssid, addr, tid) rx[tid] = self.get_rx_tid(bssid, addr, tid) - return [ tx, rx ] + return [tx, rx] diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index f5cc851d0..aca05709d 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -323,7 +323,7 @@ class WpaSupplicant: for l in lines: if "network id" in l: continue - [id,ssid,bssid,flags] = l.split('\t') + [id, ssid, bssid, flags] = l.split('\t') network = {} network['id'] = id network['ssid'] = ssid @@ -376,20 +376,20 @@ class WpaSupplicant: def add_cred_values(self, params): id = self.add_cred() - quoted = [ "realm", "username", "password", "domain", "imsi", - "excluded_ssid", "milenage", "ca_cert", "client_cert", - "private_key", "domain_suffix_match", "provisioning_sp", - "roaming_partner", "phase1", "phase2", "private_key_passwd", - "roaming_consortiums" ] + quoted = ["realm", "username", "password", "domain", "imsi", + "excluded_ssid", "milenage", "ca_cert", "client_cert", + "private_key", "domain_suffix_match", "provisioning_sp", + "roaming_partner", "phase1", "phase2", "private_key_passwd", + "roaming_consortiums"] for field in quoted: if field in params: self.set_cred_quoted(id, field, params[field]) - not_quoted = [ "eap", "roaming_consortium", "priority", - "required_roaming_consortium", "sp_priority", - "max_bss_load", "update_identifier", "req_conn_capab", - "min_dl_bandwidth_home", "min_ul_bandwidth_home", - "min_dl_bandwidth_roaming", "min_ul_bandwidth_roaming" ] + not_quoted = ["eap", "roaming_consortium", "priority", + "required_roaming_consortium", "sp_priority", + "max_bss_load", "update_identifier", "req_conn_capab", + "min_dl_bandwidth_home", "min_ul_bandwidth_home", + "min_dl_bandwidth_roaming", "min_ul_bandwidth_roaming"] for field in not_quoted: if field in params: self.set_cred(id, field, params[field]) @@ -436,7 +436,7 @@ class WpaSupplicant: vals = dict() for l in lines: try: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value except ValueError as e: logger.info(self.ifname + ": Ignore unexpected STATUS line: " + l) @@ -458,7 +458,7 @@ class WpaSupplicant: vals = dict() for l in lines: try: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) except ValueError: logger.info(self.ifname + ": Ignore unexpected status line: " + l) continue @@ -482,7 +482,7 @@ class WpaSupplicant: vals = dict() for l in lines: try: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) except ValueError: logger.info(self.ifname + ": Ignore unexpected status-driver line: " + l) continue @@ -505,7 +505,7 @@ class WpaSupplicant: vals = dict() for l in lines: try: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value except ValueError as e: logger.info(self.ifname + ": Ignore unexpected MIB line: " + l) @@ -589,7 +589,7 @@ class WpaSupplicant: vals = dict() for l in lines: if '=' in l: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals @@ -994,34 +994,34 @@ class WpaSupplicant: elif ssid2: self.set_network(id, "ssid", ssid2) - quoted = [ "psk", "identity", "anonymous_identity", "password", - "ca_cert", "client_cert", "private_key", - "private_key_passwd", "ca_cert2", "client_cert2", - "private_key2", "phase1", "phase2", "domain_suffix_match", - "altsubject_match", "subject_match", "pac_file", "dh_file", - "bgscan", "ht_mcs", "id_str", "openssl_ciphers", - "domain_match", "dpp_connector", "sae_password", - "sae_password_id", "check_cert_subject" ] + quoted = ["psk", "identity", "anonymous_identity", "password", + "ca_cert", "client_cert", "private_key", + "private_key_passwd", "ca_cert2", "client_cert2", + "private_key2", "phase1", "phase2", "domain_suffix_match", + "altsubject_match", "subject_match", "pac_file", "dh_file", + "bgscan", "ht_mcs", "id_str", "openssl_ciphers", + "domain_match", "dpp_connector", "sae_password", + "sae_password_id", "check_cert_subject"] for field in quoted: if field in kwargs and kwargs[field]: self.set_network_quoted(id, field, kwargs[field]) - not_quoted = [ "proto", "key_mgmt", "ieee80211w", "pairwise", - "group", "wep_key0", "wep_key1", "wep_key2", "wep_key3", - "wep_tx_keyidx", "scan_freq", "freq_list", "eap", - "eapol_flags", "fragment_size", "scan_ssid", "auth_alg", - "wpa_ptk_rekey", "disable_ht", "disable_vht", "bssid", - "disable_max_amsdu", "ampdu_factor", "ampdu_density", - "disable_ht40", "disable_sgi", "disable_ldpc", - "ht40_intolerant", "update_identifier", "mac_addr", - "erp", "bg_scan_period", "bssid_blacklist", - "bssid_whitelist", "mem_only_psk", "eap_workaround", - "engine", "fils_dh_group", "bssid_hint", - "dpp_csign", "dpp_csign_expiry", - "dpp_netaccesskey", "dpp_netaccesskey_expiry", - "group_mgmt", "owe_group", - "roaming_consortium_selection", "ocv", - "multi_ap_backhaul_sta", "rx_stbc", "tx_stbc" ] + not_quoted = ["proto", "key_mgmt", "ieee80211w", "pairwise", + "group", "wep_key0", "wep_key1", "wep_key2", "wep_key3", + "wep_tx_keyidx", "scan_freq", "freq_list", "eap", + "eapol_flags", "fragment_size", "scan_ssid", "auth_alg", + "wpa_ptk_rekey", "disable_ht", "disable_vht", "bssid", + "disable_max_amsdu", "ampdu_factor", "ampdu_density", + "disable_ht40", "disable_sgi", "disable_ldpc", + "ht40_intolerant", "update_identifier", "mac_addr", + "erp", "bg_scan_period", "bssid_blacklist", + "bssid_whitelist", "mem_only_psk", "eap_workaround", + "engine", "fils_dh_group", "bssid_hint", + "dpp_csign", "dpp_csign_expiry", + "dpp_netaccesskey", "dpp_netaccesskey_expiry", + "group_mgmt", "owe_group", + "roaming_consortium_selection", "ocv", + "multi_ap_backhaul_sta", "rx_stbc", "tx_stbc"] for field in not_quoted: if field in kwargs and kwargs[field]: self.set_network(id, field, kwargs[field]) @@ -1191,7 +1191,7 @@ class WpaSupplicant: lines = res.splitlines() vals = dict() for l in lines: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value if len(vals) == 0: return None @@ -1205,10 +1205,10 @@ class WpaSupplicant: continue vals = dict() try: - [index,aa,pmkid,expiration,opportunistic] = l.split(' ') + [index, aa, pmkid, expiration, opportunistic] = l.split(' ') cache_id = None except ValueError: - [index,aa,pmkid,expiration,opportunistic,cache_id] = l.split(' ') + [index, aa, pmkid, expiration, opportunistic, cache_id] = l.split(' ') vals['index'] = index vals['pmkid'] = pmkid vals['expiration'] = expiration @@ -1234,7 +1234,7 @@ class WpaSupplicant: vals['addr'] = l first = False else: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals @@ -1244,17 +1244,17 @@ class WpaSupplicant: return None msg = {} items = ev.split(' ') - field,val = items[1].split('=') + field, val = items[1].split('=') if field != "freq": raise Exception("Unexpected MGMT-RX event format: " + ev) msg['freq'] = val - field,val = items[2].split('=') + field, val = items[2].split('=') if field != "datarate": raise Exception("Unexpected MGMT-RX event format: " + ev) msg['datarate'] = val - field,val = items[3].split('=') + field, val = items[3].split('=') if field != "ssi_signal": raise Exception("Unexpected MGMT-RX event format: " + ev) msg['ssi_signal'] = val @@ -1303,7 +1303,7 @@ class WpaSupplicant: lines = res.splitlines() vals = dict() for l in lines: - [name,value] = l.split('=', 1) + [name, value] = l.split('=', 1) vals[name] = value return vals diff --git a/tests/remote/config.py b/tests/remote/config.py index cf3b77f95..55c601316 100644 --- a/tests/remote/config.py +++ b/tests/remote/config.py @@ -16,19 +16,19 @@ logger = logging.getLogger() # You can put your settings in cfg.py file with setup_params, devices # definitions in the format as below. In other case HWSIM cfg will be used. # -setup_params = { "setup_hw" : "./tests/setup_hw.sh", - "hostapd" : "./tests/hostapd", - "wpa_supplicant" : "./tests/wpa_supplicant", - "iperf" : "iperf", - "wlantest" : "./tests/wlantest", - "wlantest_cli" : "./tests/wlantest_cli", - "country" : "US", - "log_dir" : "/tmp/", - "ipv4_test_net" : "192.168.12.0", - "trace_start" : "./tests/trace_start.sh", - "trace_stop" : "./tests/trace_stop.sh", - "perf_start" : "./tests/perf_start.sh", - "perf_stop" : "./tests/perf_stop.sh" } +setup_params = {"setup_hw" : "./tests/setup_hw.sh", + "hostapd" : "./tests/hostapd", + "wpa_supplicant" : "./tests/wpa_supplicant", + "iperf" : "iperf", + "wlantest" : "./tests/wlantest", + "wlantest_cli" : "./tests/wlantest_cli", + "country" : "US", + "log_dir" : "/tmp/", + "ipv4_test_net" : "192.168.12.0", + "trace_start" : "./tests/trace_start.sh", + "trace_stop" : "./tests/trace_stop.sh", + "perf_start" : "./tests/perf_start.sh", + "perf_stop" : "./tests/perf_stop.sh"} # #devices = [{"hostname": "192.168.254.58", "ifname" : "wlan0", "port": "9877", "name" : "t2-ath9k", "flags" : "AP_HT40 STA_HT40"}, diff --git a/tests/remote/monitor.py b/tests/remote/monitor.py index a71501006..47b5e3bbd 100644 --- a/tests/remote/monitor.py +++ b/tests/remote/monitor.py @@ -30,10 +30,10 @@ def create(devices, setup_params, refs, duts, monitors): if dev is None: continue - host = Host(host = dev['hostname'], - ifname = dev['ifname'], - port = dev['port'], - name = dev['name']) + host = Host(host=dev['hostname'], + ifname=dev['ifname'], + port=dev['port'], + name=dev['name']) try: host.execute(["iw", "reg", "set", setup_params['country']]) @@ -145,8 +145,8 @@ def get_monitor_params(wpa, is_p2p=False): get_status_field_f = wpa.get_status_field freq = get_status_field_f("freq") bw = "20" - center_freq1="" - center_freq2="" + center_freq1 = "" + center_freq2 = "" vht_oper_chwidth = get_status_field_f("vht_oper_chwidth") secondary_channel = get_status_field_f("secondary_channel") @@ -173,9 +173,9 @@ def get_monitor_params(wpa, is_p2p=False): else: pass - monitor_params = { "freq" : freq, - "bw" : bw, - "center_freq1" : center_freq1, - "center_freq2" : center_freq2 } + monitor_params = {"freq" : freq, + "bw" : bw, + "center_freq1" : center_freq1, + "center_freq2" : center_freq2} return monitor_params diff --git a/tests/remote/run-tests.py b/tests/remote/run-tests.py index 75497b4c9..550071253 100755 --- a/tests/remote/run-tests.py +++ b/tests/remote/run-tests.py @@ -161,7 +161,7 @@ def main(): if m: 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])) @@ -173,7 +173,7 @@ def main(): if m: 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_"): hwsim_tests.append(val) diff --git a/tests/remote/rutils.py b/tests/remote/rutils.py index 879fadc8b..70255b999 100644 --- a/tests/remote/rutils.py +++ b/tests/remote/rutils.py @@ -19,10 +19,10 @@ class TestSkip(Exception): # get host based on name def get_host(devices, dev_name): dev = config.get_device(devices, dev_name) - host = Host(host = dev['hostname'], - ifname = dev['ifname'], - port = dev['port'], - name = dev['name']) + host = Host(host=dev['hostname'], + ifname=dev['ifname'], + port=dev['port'], + name=dev['name']) host.dev = dev return host @@ -191,13 +191,13 @@ def get_ap_params(channel="1", bw="HT20", country="US", security="open", ht_capa elif security == "mixed": sec_params = hostapd.wpa_mixed_params(passphrase="testtest") elif security == "wep": - sec_params = { "wep_key0" : "123456789a", - "wep_default_key" : "0", - "auth_algs" : "1"} + sec_params = {"wep_key0" : "123456789a", + "wep_default_key" : "0", + "auth_algs" : "1"} elif security == "wep_shared": - sec_params = { "wep_key0" : "123456789a", - "wep_default_key" : "0", - "auth_algs" : "2" } + sec_params = {"wep_key0" : "123456789a", + "wep_default_key" : "0", + "auth_algs" : "2"} else: sec_params = {} @@ -339,7 +339,7 @@ def ping_wait(host, thread, timeout=None): def flush_arp_cache(host): host.execute(["ip", "-s", "-s", "neigh", "flush", "all"]) -def check_connectivity(a, b, addr_type = "ipv4", deadline="5", qos=None): +def check_connectivity(a, b, addr_type="ipv4", deadline="5", qos=None): addr_a = get_ip(a, addr_type) addr_b = get_ip(b, addr_type) @@ -399,7 +399,7 @@ def get_iperf_speed(iperf_res, pattern="Mbits/sec"): # first find last SUM line for line in lines: - res = line.find("[SUM]") + res = line.find("[SUM]") if res != -1: sum_line = line @@ -461,7 +461,7 @@ def iperf_run(server, client, server_ip, client_res, server_res, iperf_server = iperf_server + ["-p", port] elif l3 == "ipv6": iperf_client = [iperf, "-V", "-c", server_ip + "%" + ifname, "-p", port] - iperf_server = iperf_server + ["-V", "-p", port] + iperf_server = iperf_server + ["-V", "-p", port] else: return -1, -1 @@ -474,7 +474,7 @@ def iperf_run(server, client, server_ip, client_res, server_res, if l4 == "udp": if iperf != "iperf3": iperf_server = iperf_server + ["-u"] - iperf_client = iperf_client + ["-u", "-b", bw] + iperf_client = iperf_client + ["-u", "-b", bw] if qos: iperf_client = iperf_client + ["-Q", ac_to_iperf_ac(qos)] diff --git a/tests/remote/test_example.py b/tests/remote/test_example.py index 09c7e7708..1550665c3 100644 --- a/tests/remote/test_example.py +++ b/tests/remote/test_example.py @@ -58,8 +58,8 @@ def test_example(devices, setup_params, refs, duts, monitors): # connect to hostapd/wpa_supplicant UDP CTRL iface hapd = hostapd.add_ap(ap.dev, ap_params) freq = hapd.get_status_field("freq") - wpas = WpaSupplicant(hostname = sta.host, global_iface="udp", - global_port = sta.port) + wpas = WpaSupplicant(hostname=sta.host, global_iface="udp", + global_port=sta.port) wpas.interface_add(sta.ifname) # setup standalone monitor based on hapd; could be multi interface