]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Additional D-Bus WPS Get/Set properties
authorJouni Malinen <j@w1.fi>
Fri, 23 Dec 2016 11:11:29 +0000 (13:11 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 23 Dec 2016 19:28:43 +0000 (21:28 +0200)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_dbus.py

index 25332ed7b52e95dec160f8dab9b86123da366078..e95fb9421b33d02e9d1f76722021f08635837499 100644 (file)
@@ -367,6 +367,12 @@ def test_dbus_get_set_wps(dev, apdev):
     finally:
         dev[0].request("SET wps_cred_processing 0")
         dev[0].request("SET config_methods display keypad virtual_display nfc_interface p2ps")
+        dev[0].set("device_name", "Device A")
+        dev[0].set("manufacturer", "")
+        dev[0].set("model_name", "")
+        dev[0].set("model_number", "")
+        dev[0].set("serial_number", "")
+        dev[0].set("device_type", "0-00000000-0")
 
 def _test_dbus_get_set_wps(dev, apdev):
     (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
@@ -400,6 +406,48 @@ def _test_dbus_get_set_wps(dev, apdev):
         if val != expected_val:
             raise Exception("Unexpected Get(ProcessCredentials) result({}): {}".format(i, val))
 
+    tests = [ ("device_name", "DeviceName"),
+              ("manufacturer", "Manufacturer"),
+              ("model_name", "ModelName"),
+              ("model_number", "ModelNumber"),
+              ("serial_number", "SerialNumber") ]
+
+    for f1,f2 in tests:
+        val2 = "test-value-test"
+        dev[0].set(f1, val2)
+        val = if_obj.Get(WPAS_DBUS_IFACE_WPS, f2,
+                         dbus_interface=dbus.PROPERTIES_IFACE)
+        if val != val2:
+            raise Exception("Get(%s) returned unexpected value" % f2)
+        val2 = "TEST-value"
+        if_obj.Set(WPAS_DBUS_IFACE_WPS, f2, val2,
+                   dbus_interface=dbus.PROPERTIES_IFACE)
+        val = if_obj.Get(WPAS_DBUS_IFACE_WPS, f2,
+                         dbus_interface=dbus.PROPERTIES_IFACE)
+        if val != val2:
+            raise Exception("Get(%s) returned unexpected value after Set" % f2)
+
+    dev[0].set("device_type", "5-0050F204-1")
+    val = if_obj.Get(WPAS_DBUS_IFACE_WPS, "DeviceType",
+                     dbus_interface=dbus.PROPERTIES_IFACE)
+    if val[0] != 0x00 or val[1] != 0x05 != val[2] != 0x00 or val[3] != 0x50 or val[4] != 0xf2 or val[5] != 0x04 or val[6] != 0x00 or val[7] != 0x01:
+        raise Exception("DeviceType mismatch")
+    if_obj.Set(WPAS_DBUS_IFACE_WPS, "DeviceType", val,
+               dbus_interface=dbus.PROPERTIES_IFACE)
+    val = if_obj.Get(WPAS_DBUS_IFACE_WPS, "DeviceType",
+                     dbus_interface=dbus.PROPERTIES_IFACE)
+    if val[0] != 0x00 or val[1] != 0x05 != val[2] != 0x00 or val[3] != 0x50 or val[4] != 0xf2 or val[5] != 0x04 or val[6] != 0x00 or val[7] != 0x01:
+        raise Exception("DeviceType mismatch after Set")
+
+    val2 = '\x01\x02\x03\x04\x05\x06\x07\x08'
+    if_obj.Set(WPAS_DBUS_IFACE_WPS, "DeviceType", dbus.ByteArray(val2),
+               dbus_interface=dbus.PROPERTIES_IFACE)
+    val = if_obj.Get(WPAS_DBUS_IFACE_WPS, "DeviceType",
+                     dbus_interface=dbus.PROPERTIES_IFACE,
+                     byte_arrays=True)
+    if val != val2:
+        raise Exception("DeviceType mismatch after Set (2)")
+
     class TestDbusGetSet(TestDbus):
         def __init__(self, bus):
             TestDbus.__init__(self, bus)