From d9e2a057c85db593f266a7f56e2c54fbf03a77cb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 20 Jun 2015 22:08:55 +0300 Subject: [PATCH] tests: D-Bus AddNetwork and connection with WPA+WPA2-Enterprise AP Signed-off-by: Jouni Malinen --- tests/hwsim/test_dbus.py | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index 990e56edd..5affbc8f6 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -4549,3 +4549,59 @@ def test_dbus_ap(dev, apdev): if not t.success(): raise Exception("Expected signals not seen") dev[1].connect(ssid, psk=passphrase, scan_freq="2412") + +def test_dbus_connect_wpa_eap(dev, apdev): + """D-Bus AddNetwork and connection with WPA+WPA2-Enterprise AP""" + (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0]) + iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) + + ssid = "test-wpa-eap" + params = hostapd.wpa_eap_params(ssid=ssid) + params["wpa"] = "3" + params["rsn_pairwise"] = "CCMP" + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + + class TestDbusConnect(TestDbus): + def __init__(self, bus): + TestDbus.__init__(self, bus) + self.done = False + + def __enter__(self): + gobject.timeout_add(1, self.run_connect) + gobject.timeout_add(15000, self.timeout) + self.add_signal(self.propertiesChanged, WPAS_DBUS_IFACE, + "PropertiesChanged") + self.add_signal(self.eap, WPAS_DBUS_IFACE, "EAP") + self.loop.run() + return self + + def propertiesChanged(self, properties): + logger.debug("propertiesChanged: %s" % str(properties)) + if 'State' in properties and properties['State'] == "completed": + self.done = True + self.loop.quit() + + def eap(self, status, parameter): + logger.debug("EAP: status=%s parameter=%s" % (status, parameter)) + + def run_connect(self, *args): + logger.debug("run_connect") + args = dbus.Dictionary({ 'ssid': ssid, + 'key_mgmt': 'WPA-EAP', + 'eap': 'PEAP', + 'identity': 'user', + 'password': 'password', + 'ca_cert': 'auth_serv/ca.pem', + 'phase2': 'auth=MSCHAPV2', + 'scan_freq': 2412 }, + signature='sv') + self.netw = iface.AddNetwork(args) + iface.SelectNetwork(self.netw) + return False + + def success(self): + return self.done + + with TestDbusConnect(bus) as t: + if not t.success(): + raise Exception("Expected signals not seen")