Add test script for changing device policy
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 28 Dec 2008 01:54:09 +0000 (02:54 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 28 Dec 2008 01:54:09 +0000 (02:54 +0100)
test/Makefile.am
test/set-policy [new file with mode: 0755]

index 30546b9..f39d13e 100644 (file)
@@ -3,6 +3,6 @@ EXTRA_DIST = get-state list-profiles list-connections select-connection \
                list-devices enable-device disable-device start-scanning \
                list-networks select-network disable-network create-network \
                set-passphrase set-address simple-agent show-introspection \
-               test-manager test-compat monitor-connman
+               set-policy test-manager test-compat monitor-connman
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/set-policy b/test/set-policy
new file mode 100755 (executable)
index 0000000..5f26690
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 3):
+       print "Usage: %s <device> <policy>" % (sys.argv[0])
+       sys.exit(1)
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
+                                       "org.moblin.connman.Manager")
+
+properties = manager.GetProperties()
+
+for path in properties["Devices"]:
+       device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Device")
+
+       properties = device.GetProperties()
+
+       if properties["Interface"] != sys.argv[1]:
+               continue;
+
+       print "Setting policy \"%s\" for %s" % (sys.argv[2], path)
+
+       device.SetProperty("Policy", sys.argv[2])