3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 02:19:26 +01:00

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

View File

@ -532,8 +532,10 @@ class OrderedNetwork(object):
class PSKAgent(dbus.service.Object): class PSKAgent(dbus.service.Object):
def __init__(self, passphrase = None): def __init__(self, passphrases = []):
self._passphrase = passphrase if type(passphrases) != list:
passphrases = [passphrases]
self._passphrases = passphrases
self._path = '/test/agent/' + str(int(round(time.time() * 1000))) self._path = '/test/agent/' + str(int(round(time.time() * 1000)))
dbus.service.Object.__init__(self, dbus.SystemBus(), self._path) dbus.service.Object.__init__(self, dbus.SystemBus(), self._path)
@ -551,10 +553,10 @@ class PSKAgent(dbus.service.Object):
def RequestPassphrase(self, path): def RequestPassphrase(self, path):
print('Requested passphrase for ' + path) print('Requested passphrase for ' + path)
if self._passphrase is None: if not self._passphrases:
raise CanceledEx("canceled") raise CanceledEx("canceled")
return self._passphrase return self._passphrases.pop(0)
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='s', @dbus.service.method(IWD_AGENT_INTERFACE, in_signature='s',
out_signature='') out_signature='')