Skip to contentSkip to conversation

auto-t: correctly import Mapping from collections

PATCH In review James Prestwood 2 participants 3 messages Jun 1, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/2 auto-t: correctly import Mapping from collections

The current way this was being done was to import collections and use collections.Mapping. This has been deprecated since python 3.3 but has worked up until python 3.10. After python 3.10 this will no longer work, and Mapping must be imported from collections.abc.

---
 autotests/util/ead.py   | 4 ++--
 autotests/util/hwsim.py | 6 +++---
 autotests/util/iwd.py   | 5 +++--
 3 files changed, 8 insertions(+), 7 deletions(-)
autotests/util/ead.py +2 -2
index 06716914..00596042 100644
@@ -3,9 +3,9 @@
 from gi.repository import GLib
 import dbus
 import time
-import collections
 
 import iwd
+from collections.abc import Mapping
 from config import ctx
 
 EAD_SERVICE =                   'net.connman.ead'
@@ -38,7 +38,7 @@ class Adapter(iwd.IWDDBusAbstract):
         return self._properties['Authenticated']
 
 
-class AdapterList(collections.Mapping):
+class AdapterList(Mapping):
     def __init__(self, ead):
         self._dict = {}
 
autotests/util/hwsim.py +3 -3
index b8eec252..5456d30b 100755
@@ -1,8 +1,8 @@
 #!/usr/bin/python3
 import dbus
 import sys
-import collections
 
+from collections.abc import Mapping
 from weakref import WeakValueDictionary
 from abc import ABCMeta, abstractmethod
 from enum import Enum
@@ -210,7 +210,7 @@ class Rule(HwsimDBusAbstract):
                prefix + '\tDelay:\t' + str(self.delay) + '\n' + \
                prefix + '\tEnabled:\t' + str(self.enabled) + '\n'
 
-class RuleSet(collections.Mapping):
+class RuleSet(Mapping):
     def __init__(self, hwsim, objects):
         self._dict = {}
         self._rule_manager = hwsim.rule_manager
@@ -275,7 +275,7 @@ class Radio(HwsimDBusAbstract):
                prefix + '\tName:\t\t' + self.name + '\n' + \
                prefix + '\tAddresses:\t' + repr(self.destination) + '\n'
 
-class RadioList(collections.Mapping):
+class RadioList(Mapping):
     def __init__(self, hwsim, objects):
         self._dict = {}
         self._radio_manager = hwsim.radio_manager
autotests/util/iwd.py +3 -2
index a2062258..6cee1e07 100755
@@ -8,10 +8,11 @@ import sys
 import os
 import threading
 import time
-import collections
+import collections.abc
 import datetime
 import weakref
 
+from collections.abc import Mapping
 from abc import ABCMeta, abstractmethod
 from enum import Enum
 
@@ -1018,7 +1019,7 @@ class P2PPeer(IWDDBusAbstract):
         self._iface.Disconnect()
 
 
-class DeviceList(collections.Mapping):
+class DeviceList(Mapping):
     def __init__(self, iwd):
         self._dict = {}
         self._p2p_dict = {}
Signature · 1 line
2.34.1
#1 lore raw

Hi James,

Quoted 10 lines · James Prestwood

The current way this was being done was to import collections and use collections.Mapping. This has been deprecated since python 3.3 but has worked up until python 3.10. After python 3.10 this will no longer work, and Mapping must be imported from collections.abc.

---
  autotests/util/ead.py   | 4 ++--
  autotests/util/hwsim.py | 6 +++---
  autotests/util/iwd.py   | 5 +++--
  3 files changed, 8 insertions(+), 7 deletions(-)

Both applied, thanks.

Regards,
-Denis

author
#2 lore raw

PATCH 2/2 auto-t: allow wildcard phase1 for EAP tests

In reply to James Prestwood

This allows the EAP tests to pass, but the fix really needs to be in hostapd itself. Hostapd currently tries to lookup the EAP session immediately after receiving EAPOL_REAUTH. This uses the identity it has stored which, in the case of PEAP/TTLS, will always be a phase2 identity. During this initial lookup hostapd hard codes the identity to be phase1 which is not true for PEAP/TTLS, and the lookup fails.

---
 autotests/misc/secrets/eap-user.text | 5 +++++
 1 file changed, 5 insertions(+)
autotests/misc/secrets/eap-user.text +5 -0
index 6f64b2f8..a34726d4 100644
@@ -20,3 +20,8 @@
 "ttls-mschapv2-phase2(a)example.com"	TTLS-MSCHAPV2	"Password" [2]
 "ttls-pap-phase2(a)example.com"		TTLS-PAP	"Password" [2]
 "112345678(a)phonesim.org"		SIM [2]
+
+# TODO: Hostapd is broken with phase1 lookups for reauthentication.
+# Allowing a wildcard phase1 for PEAP/TTLS is a stop gap until
+# hostapd is actually fixed.
+*					PEAP,TTLS
Signature · 1 line
2.34.1