From a8c30cd25e5ec12ac5c71071b16c05932a17a3b7 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Wed, 18 Apr 2018 07:03:38 +0200 Subject: [PATCH] autotests: Accept a list of passphrases in PSKAgent Allow passing a list of passphrases for subsequent agent requests to the PSKAgent constructor. This also makes existing tests stricter because a spurious agent request will not receive the same passphrase. --- autotests/util/iwd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 4958373a..28c7c449 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -532,8 +532,10 @@ class OrderedNetwork(object): class PSKAgent(dbus.service.Object): - def __init__(self, passphrase = None): - self._passphrase = passphrase + def __init__(self, passphrases = []): + if type(passphrases) != list: + passphrases = [passphrases] + self._passphrases = passphrases self._path = '/test/agent/' + str(int(round(time.time() * 1000))) dbus.service.Object.__init__(self, dbus.SystemBus(), self._path) @@ -551,10 +553,10 @@ class PSKAgent(dbus.service.Object): def RequestPassphrase(self, path): print('Requested passphrase for ' + path) - if self._passphrase is None: + if not self._passphrases: raise CanceledEx("canceled") - return self._passphrase + return self._passphrases.pop(0) @dbus.service.method(IWD_AGENT_INTERFACE, in_signature='s', out_signature='')