tests: Encode Disconnect-Request attributes in sorted order for python3
This is needed to fix issues with dict iteration resulting in different order of attributes when trying to calculate Message-Authenticator externally to pyrad. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
55845e190b
commit
200ac5daf6
2 changed files with 8 additions and 2 deletions
|
@ -16,7 +16,10 @@ class DisconnectPacket(pyrad.packet.Packet):
|
||||||
**attributes)
|
**attributes)
|
||||||
|
|
||||||
def RequestPacket(self):
|
def RequestPacket(self):
|
||||||
attr = self._PktEncodeAttributes()
|
attr = b''
|
||||||
|
for code,datalst in sorted(self.items()):
|
||||||
|
for data in datalst:
|
||||||
|
attr += self._PktEncodeAttribute(code, data)
|
||||||
|
|
||||||
if self.id is None:
|
if self.id is None:
|
||||||
self.id = random.randrange(0, 256)
|
self.id = random.randrange(0, 256)
|
||||||
|
|
|
@ -730,7 +730,10 @@ def add_message_auth_req(req):
|
||||||
|
|
||||||
# request attributes
|
# request attributes
|
||||||
req.AddAttribute("Message-Authenticator", 16*b"\x00")
|
req.AddAttribute("Message-Authenticator", 16*b"\x00")
|
||||||
attrs = req._PktEncodeAttributes()
|
attrs = b''
|
||||||
|
for code,datalst in sorted(req.items()):
|
||||||
|
for data in datalst:
|
||||||
|
attrs += req._PktEncodeAttribute(code, data)
|
||||||
|
|
||||||
# Length
|
# Length
|
||||||
flen = 4 + 16 + len(attrs)
|
flen = 4 + 16 + len(attrs)
|
||||||
|
|
Loading…
Reference in a new issue