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.
This commit is contained in:
Andrew Zaborowski 2018-04-18 07:03:38 +02:00 committed by Denis Kenzior
parent 2382dc7ffa
commit a8c30cd25e
1 changed files with 6 additions and 4 deletions

View File

@ -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='')