3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

test: Avoid input() in simple-agent.py.

That function reads a string of python code and immediately executes
it.  This required passphrases to be input as python literals, we
can just use a string as passphrase instead.
This commit is contained in:
Andrew Zaborowski 2015-05-26 19:51:26 +02:00 committed by Denis Kenzior
parent 99cdb860c0
commit 4bf109a7ce

View File

@ -20,42 +20,20 @@ class Agent(dbus.service.Object):
print("Release")
mainloop.quit()
def input_passphrase(self):
response = {}
if not self.passphrase:
print("Service credentials requested, type cancel to cancel")
args = input('Answer: ')
for arg in args.split():
if arg.startswith("cancel"):
response["Error"] = arg
if arg.startswith("Passphrase="):
passphrase = arg.replace("Passphrase=", "", 1)
response["Passphrase"] = passphrase
else:
if self.passphrase:
response["Passphrase"] = self.passphrase
return response
@dbus.service.method("net.connman.iwd.Agent",
in_signature='o',
out_signature='s')
def RequestPassphrase(self, path):
print("RequestPassphrase (%s)" % (path))
response = {}
response.update(self.input_passphrase())
print("Service credentials requested, type cancel to cancel")
passphrase = raw_input('Answer: ')
if response.has_key("Error"):
if response["Error"] == "cancel":
raise Canceled("canceled")
return
if not passphrase or passphrase == 'cancel':
raise Canceled("canceled")
print("returning (%s)" % (response["Passphrase"]))
return response["Passphrase"]
print("returning (%s)" % (passphrase))
return passphrase
@dbus.service.method("net.connman.iwd.Agent",
in_signature='', out_signature='')