From c58178b922a3207d749a225447f3c8b7df86f825 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 17 Dec 2022 11:35:58 +0200 Subject: [PATCH] tests: More coverage for D-Bus CreateInterface() parameters Signed-off-by: Jouni Malinen --- tests/hwsim/test_dbus.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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]) -- 2.47.3