diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2011-08-29 18:25:08 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-09-12 19:46:02 +0200 |
commit | d2871979c271fcf62f7348b0d2a33fc9fd17fb6d (patch) | |
tree | 60811c4f4eb6831f0aa25941d337c78b80c774e5 /test | |
parent | 3b89d5171aaff25dbd8f813f2e64f60067f7df4d (diff) | |
download | connman-d2871979c271fcf62f7348b0d2a33fc9fd17fb6d.tar.gz connman-d2871979c271fcf62f7348b0d2a33fc9fd17fb6d.tar.bz2 connman-d2871979c271fcf62f7348b0d2a33fc9fd17fb6d.zip |
test: Added Username/Password input support in simple-agent
Diffstat (limited to 'test')
-rwxr-xr-x | test/simple-agent | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/test/simple-agent b/test/simple-agent index b0990de6..cda96931 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -14,6 +14,8 @@ class Agent(dbus.service.Object): identity = None passphrase = None wpspin = None + username = None + password = None @dbus.service.method("net.connman.Agent", in_signature='', out_signature='') @@ -21,12 +23,7 @@ class Agent(dbus.service.Object): print("Release") mainloop.quit() - @dbus.service.method("net.connman.Agent", - in_signature='oa{sv}', - out_signature='a{sv}') - def RequestInput(self, path, fields): - print "RequestInput (%s,%s)" % (path, fields) - + def input_passphrase(self): response = {} if not self.identity and not self.passphrase and not self.wpspin: @@ -53,6 +50,46 @@ class Agent(dbus.service.Object): if self.wpspin: response["WPS"] = self.wpspin + return response + + def input_username(self): + response = {} + + if not self.username and not self.password: + args = raw_input('Answer: ') + + for arg in args.split(): + if arg.startswith("Username="): + username = arg.replace("Username=", "", 1) + response["Username"] = username + break + if arg.startswith("Password="): + password = arg.replace("Password=", "", 1) + response["Password"] = password + break + else: + if self.username: + response["Username"] = self.username + if self.password: + response["Password"] = self.password + + return response + + @dbus.service.method("net.connman.Agent", + in_signature='oa{sv}', + out_signature='a{sv}') + def RequestInput(self, path, fields): + print "RequestInput (%s,%s)" % (path, fields) + + response = None + + if fields.has_key("Passphrase"): + response = self.input_passphrase() + elif fields.has_key("Username"): + response = self.input_username() + else: + print "No method to answer the input request" + print "returning (%s)" % (response) return response @@ -78,8 +115,12 @@ class Agent(dbus.service.Object): print "Cancel" def print_usage(): - print "Usage: %s Identity=<identity> Passphrase=<passphrase> WPS=<wpspin>" % (sys.argv[0]) - print "Help: %s help" % (sys.ar[0]) + print "Usage:" + print "For EAP/WPA input:" + print "%s Identity=<identity> Passphrase=<passphrase> WPS=<wpspin>" % (sys.argv[0]) + print "For WISPr login input:" + print "%s Username=<username> Password=<password>" % (sys.argv[0]) + print "Help: %s help" % (sys.argv[0]) sys.exit(1) if __name__ == '__main__': @@ -103,6 +144,10 @@ if __name__ == '__main__': object.passphrase = arg.replace("Passphrase=", "", 1) elif arg.startswith("WPS="): object.wpspin = arg.replace("WPS=", "", 1) + elif arg.startswith("Username="): + object.username = arg.replace("Username=", "", 1) + elif arg.startswith("Password="): + object.password = arg.replace("Password=", "", 1) else: print_usage() |