From: Jouni Malinen Date: Sat, 17 Dec 2022 09:35:58 +0000 (+0200) Subject: tests: More coverage for D-Bus CreateInterface() parameters X-Git-Tag: hostap_2_11~1380 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c58178b922a3207d749a225447f3c8b7df86f825;p=thirdparty%2Fhostap.git tests: More coverage for D-Bus CreateInterface() parameters Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index a61211fe1..62be04ceb 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -2030,7 +2030,8 @@ def _test_dbus_interface(dev, apdev): (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) wpas = dbus.Interface(wpas_obj, WPAS_DBUS_SERVICE) - params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none'}, + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none', 'Type': 'sta', + 'Address': '02:03:11:22:33:44'}, signature='sv') path = wpas.CreateInterface(params) logger.debug("New interface path: " + str(path)) @@ -2083,6 +2084,38 @@ def _test_dbus_interface(dev, apdev): if "InterfaceUnknown" not in str(e): raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e)) + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none', + 'Type': 'foo'}, signature='sv') + try: + wpas.CreateInterface(params) + raise Exception("Invalid CreateInterface() accepted") + except dbus.exceptions.DBusException as e: + if "InvalidArgs" not in str(e): + raise Exception("Unexpected error message for invalid CreateInterface: " + str(e)) + + try: + wpas.GetInterface("lo") + raise Exception("Invalid GetInterface() accepted") + except dbus.exceptions.DBusException as e: + if "InterfaceUnknown" not in str(e): + raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e)) + + params = dbus.Dictionary({'Ifname': 'lo', 'Driver': 'none', + 'Address': 'foo'}, signature='sv') + try: + wpas.CreateInterface(params) + raise Exception("Invalid CreateInterface() accepted") + except dbus.exceptions.DBusException as e: + if "InvalidArgs" not in str(e): + raise Exception("Unexpected error message for invalid CreateInterface: " + str(e)) + + try: + wpas.GetInterface("lo") + raise Exception("Invalid GetInterface() accepted") + except dbus.exceptions.DBusException as e: + if "InterfaceUnknown" not in str(e): + raise Exception("Unexpected error message for invalid RemoveInterface: " + str(e)) + def test_dbus_interface_oom(dev, apdev): """D-Bus CreateInterface/GetInterface/RemoveInterface OOM error cases""" (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])