tests: More coverage for D-Bus CreateInterface() parameters

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2022-12-17 11:35:58 +02:00
parent f9804e3067
commit c58178b922

View file

@ -2030,7 +2030,8 @@ def _test_dbus_interface(dev, apdev):
(bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])
wpas = dbus.Interface(wpas_obj, WPAS_DBUS_SERVICE) 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') signature='sv')
path = wpas.CreateInterface(params) path = wpas.CreateInterface(params)
logger.debug("New interface path: " + str(path)) logger.debug("New interface path: " + str(path))
@ -2083,6 +2084,38 @@ def _test_dbus_interface(dev, apdev):
if "InterfaceUnknown" not in str(e): if "InterfaceUnknown" not in str(e):
raise Exception("Unexpected error message for invalid RemoveInterface: " + 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): def test_dbus_interface_oom(dev, apdev):
"""D-Bus CreateInterface/GetInterface/RemoveInterface OOM error cases""" """D-Bus CreateInterface/GetInterface/RemoveInterface OOM error cases"""
(bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])