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:
Jouni Malinen 2019-02-04 19:27:57 +02:00
parent 55845e190b
commit 200ac5daf6
2 changed files with 8 additions and 2 deletions

View file

@ -16,7 +16,10 @@ class DisconnectPacket(pyrad.packet.Packet):
**attributes)
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:
self.id = random.randrange(0, 256)

View file

@ -730,7 +730,10 @@ def add_message_auth_req(req):
# request attributes
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
flen = 4 + 16 + len(attrs)