diff options
author | Tomasz Bursztyka <tomasz.bursztyka@nokia.com> | 2011-01-26 10:09:43 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-01-27 12:55:52 +0100 |
commit | 30444fa5481de11e6ad2c2847d4dbca9254b0e5e (patch) | |
tree | e3114b48948b7139a69242d3a1e7f66a042104c7 | |
parent | bab3e488db5083315e13a15ba642d6a125f0d62c (diff) | |
download | connman-30444fa5481de11e6ad2c2847d4dbca9254b0e5e.tar.gz connman-30444fa5481de11e6ad2c2847d4dbca9254b0e5e.tar.bz2 connman-30444fa5481de11e6ad2c2847d4dbca9254b0e5e.zip |
test: WPS input added in agent test script
-rwxr-xr-x | test/simple-agent | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/test/simple-agent b/test/simple-agent index 859d4037..5c735995 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -11,7 +11,8 @@ class Canceled(dbus.DBusException): _dbus_error_name = "net.connman.Error.Canceled" class Agent(dbus.service.Object): - passphrase = "" + passphrase = None + wpspin = None @dbus.service.method("net.connman.Agent", in_signature='', out_signature='') @@ -25,8 +26,25 @@ class Agent(dbus.service.Object): def RequestInput(self, path, fields): print "RequestInput (%s,%s)" % (path, fields) - response = {} - response["Passphrase"] = self.passphrase + if not self.passphrase and not self.wpspin: + args = raw_input('Answer: ') + + response = {} + + for arg in args.split(): + if arg.startswith("Passphrase="): + passphrase = arg.replace("Passphrase=", "", 1) + response["Passphrase"] = passphrase + break + if arg.startswith("WPS="): + wpspin = arg.replace("WPS=", "", 1) + response["WPS"] = wpspin + break + else: + if self.passphrase: + response["Passphrase"] = self.passphrase + else: + response["WPS"] = self.wpspin print "returning (%s)" % (response) @@ -52,12 +70,14 @@ class Agent(dbus.service.Object): def Cancel(self): print "Cancel" - +def print_usage(): + print "Usage: %s Passphrase=<passphrase> WPS=<wpspin>" % (sys.argv[0]) + print "Help: %s help" % (sys.ar[0]) + sys.exit(1) if __name__ == '__main__': - if len(sys.argv) < 2: - print "Usage: %s <passphrase>" % (sys.argv[0]) - sys.exit(1) + if len(sys.argv) == 2 and sys.argv[1] == "help": + print_usage() dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) @@ -67,7 +87,15 @@ if __name__ == '__main__': path = "/test/agent" object = Agent(bus, path) - object.passphrase = sys.argv[1] + + if len(sys.argv) >= 2: + for arg in sys.argv[1:]: + if arg.startswith("Passphrase="): + object.passphrase = arg.replace("Passphrase=", "", 1) + elif arg.startswith("WPS="): + object.wpspin = arg.replace("WPS=", "", 1) + else: + print_usage() manager.RegisterAgent(path) |