3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-19 01:42:33 +01:00

autotests: Add new DBus methods to PSKAgent

This commit is contained in:
Andrew Zaborowski 2018-04-18 07:03:39 +02:00 committed by Denis Kenzior
parent a8c30cd25e
commit 099f2ecc12

View File

@ -532,10 +532,13 @@ class OrderedNetwork(object):
class PSKAgent(dbus.service.Object):
def __init__(self, passphrases = []):
def __init__(self, passphrases=[], users=[]):
if type(passphrases) != list:
passphrases = [passphrases]
self._passphrases = passphrases
self.passphrases = passphrases
if type(users) != list:
users = [users]
self.users = users
self._path = '/test/agent/' + str(int(round(time.time() * 1000)))
dbus.service.Object.__init__(self, dbus.SystemBus(), self._path)
@ -548,22 +551,57 @@ class PSKAgent(dbus.service.Object):
def Release(self):
print("Agent released")
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='o',
out_signature='s')
def RequestPassphrase(self, path):
print('Requested passphrase for ' + path)
if not self._passphrases:
raise CanceledEx("canceled")
return self._passphrases.pop(0)
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='s',
out_signature='')
def Cancel(self, reason):
print("Cancel: " + reason)
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='o',
out_signature='s')
def RequestPassphrase(self, path):
print('Requested PSK for ' + path)
if not self.passphrases:
raise CanceledEx("canceled")
return self.passphrases.pop(0)
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='o',
out_signature='s')
def RequestPrivateKeyPassphrase(self, path):
print('Requested private-key passphrase for ' + path)
if not self.passphrases:
raise CanceledEx("canceled")
return self.passphrases.pop(0)
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='o',
out_signature='ss')
def RequestUserNameAndPassword(self, path):
print('Requested the user name and password for ' + path)
if not self.users:
raise CanceledEx("canceled")
return self.users.pop(0)
@dbus.service.method(IWD_AGENT_INTERFACE, in_signature='os',
out_signature='s')
def RequestUserPassword(self, path, req_user):
print('Requested the password for ' + path + ' for user ' + req_user)
if not self.users:
raise CanceledEx("canceled")
user, passwd = self.users.pop(0)
if user != req_user:
raise CanceledEx("canceled")
return passwd
class IWD(AsyncOpAbstract):
''''''
_bus = dbus.SystemBus()