From 200ac5daf699a8f93d7b3991db3fc8feaf4b9ee1 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 4 Feb 2019 19:27:57 +0200 Subject: [PATCH] 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 --- tests/hwsim/radius_das.py | 5 ++++- tests/hwsim/test_radius.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/radius_das.py b/tests/hwsim/radius_das.py index 300681a71..58dc9d6fa 100644 --- a/tests/hwsim/radius_das.py +++ b/tests/hwsim/radius_das.py @@ -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) diff --git a/tests/hwsim/test_radius.py b/tests/hwsim/test_radius.py index 144ad83b3..1ab343f5a 100644 --- a/tests/hwsim/test_radius.py +++ b/tests/hwsim/test_radius.py @@ -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)