aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-04-23 21:46:24 (GMT)
committerJouni Malinen <j@w1.fi>2015-04-23 22:22:15 (GMT)
commit9bbce25772a8420062b41622abcc523403e4a5af (patch)
tree7b8915b648750906087b3aa523546b82c4d7e4ff
parent5bf30c67158df7beb1d6c01e1653497841e9d098 (diff)
downloadhostap-9bbce25772a8420062b41622abcc523403e4a5af.zip
hostap-9bbce25772a8420062b41622abcc523403e4a5af.tar.gz
hostap-9bbce25772a8420062b41622abcc523403e4a5af.tar.bz2
tests: D-Bus AddNetwork for AP mode
Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--tests/hwsim/test_dbus.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py
index 7ec3114..288c250 100644
--- a/tests/hwsim/test_dbus.py
+++ b/tests/hwsim/test_dbus.py
@@ -4260,3 +4260,61 @@ def test_dbus_introspect(dev, apdev):
raise Exception("No Introspect response")
if len(res2) >= len(res):
raise Exception("Unexpected Introspect response")
+
+def test_dbus_ap(dev, apdev):
+ """D-Bus AddNetwork for AP mode"""
+ (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
+ iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
+
+ ssid = "test-wpa2-psk"
+ passphrase = 'qwertyuiop'
+
+ class TestDbusConnect(TestDbus):
+ def __init__(self, bus):
+ TestDbus.__init__(self, bus)
+ self.started = False
+
+ def __enter__(self):
+ gobject.timeout_add(1, self.run_connect)
+ gobject.timeout_add(15000, self.timeout)
+ self.add_signal(self.networkAdded, WPAS_DBUS_IFACE, "NetworkAdded")
+ self.add_signal(self.networkSelected, WPAS_DBUS_IFACE,
+ "NetworkSelected")
+ self.add_signal(self.propertiesChanged, WPAS_DBUS_IFACE,
+ "PropertiesChanged")
+ self.loop.run()
+ return self
+
+ def networkAdded(self, network, properties):
+ logger.debug("networkAdded: %s" % str(network))
+ logger.debug(str(properties))
+
+ def networkSelected(self, network):
+ logger.debug("networkSelected: %s" % str(network))
+ self.network_selected = True
+
+ def propertiesChanged(self, properties):
+ logger.debug("propertiesChanged: %s" % str(properties))
+ if 'State' in properties and properties['State'] == "completed":
+ self.started = True
+ self.loop.quit()
+
+ def run_connect(self, *args):
+ logger.debug("run_connect")
+ args = dbus.Dictionary({ 'ssid': ssid,
+ 'key_mgmt': 'WPA-PSK',
+ 'psk': passphrase,
+ 'mode': 2,
+ 'frequency': 2412 },
+ signature='sv')
+ self.netw = iface.AddNetwork(args)
+ iface.SelectNetwork(self.netw)
+ return False
+
+ def success(self):
+ return self.started
+
+ with TestDbusConnect(bus) as t:
+ if not t.success():
+ raise Exception("Expected signals not seen")
+ dev[1].connect(ssid, psk=passphrase, scan_freq="2412")