示例#1
0
def _test_dbus_old_wps_reg(dev, apdev):
    (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])

    hapd = start_ap(apdev[0])
    bssid = apdev[0]['bssid']
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].request("SET wps_cred_processing 2")

    for arg in [(123, "12345670"), ("123", "12345670")]:
        try:
            if_obj.wpsReg(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE)
            raise Exception("Invalid wpsReg arguments accepted: " + str(arg))
        except dbus.exceptions.DBusException as e:
            if not str(e).startswith(
                    "fi.epitest.hostap.WPASupplicant.InvalidOptions"):
                raise Exception(
                    "Unexpected error message for invalid wpsPbc: " + str(e))

    class TestDbusWps(TestDbusOldWps):
        def run_wps(self, *args):
            logger.debug("run_wps")
            if_obj.wpsReg(bssid,
                          "12345670",
                          dbus_interface=WPAS_DBUS_OLD_IFACE)
            return False

    with TestDbusWps(bus) as t:
        if not t.success():
            raise Exception("Expected signals not seen")

    dev[0].wait_connected(timeout=10)
示例#2
0
def _test_dbus_old_wps_pin(dev, apdev):
    (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])

    hapd = start_ap(apdev[0])
    hapd.request("WPS_PIN any 12345670")
    bssid = apdev[0]['bssid']
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].request("SET wps_cred_processing 2")

    for arg in [(123, "12345670"), ("123", "12345670")]:
        try:
            if_obj.wpsPin(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE)
            raise Exception("Invalid wpsPin arguments accepted: " + str(arg))
        except dbus.exceptions.DBusException as e:
            if not str(e).startswith(
                    "fi.epitest.hostap.WPASupplicant.InvalidOptions"):
                raise Exception(
                    "Unexpected error message for invalid wpsPbc: " + str(e))

    class TestDbusWps(TestDbusOldWps):
        def __init__(self, bus, bssid, pin):
            TestDbusOldWps.__init__(self, bus)
            self.bssid = bssid
            self.pin = pin

        def run_wps(self, *args):
            logger.debug("run_wps %s %s" % (self.bssid, self.pin))
            pin = if_obj.wpsPin(self.bssid,
                                self.pin,
                                dbus_interface=WPAS_DBUS_OLD_IFACE)
            if len(self.pin) == 0:
                h = hostapd.Hostapd(apdev[0]['ifname'])
                h.request("WPS_PIN any " + pin)
            return False

    with TestDbusWps(bus, bssid, "12345670") as t:
        if not t.success():
            raise Exception("Expected signals not seen")

    dev[0].wait_connected(timeout=10)
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected(timeout=10)
    dev[0].request("FLUSH")

    dev[0].scan_for_bss(bssid, freq="2412")

    with TestDbusWps(bus, "any", "") as t:
        if not t.success():
            raise Exception("Expected signals not seen")
示例#3
0
def _test_dbus_old_wps_reg(dev, apdev):
    (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])

    hapd = start_ap(apdev[0])
    bssid = apdev[0]["bssid"]
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].request("SET wps_cred_processing 2")

    for arg in [(123, "12345670"), ("123", "12345670")]:
        try:
            if_obj.wpsReg(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE)
            raise Exception("Invalid wpsReg arguments accepted: " + str(arg))
        except dbus.exceptions.DBusException, e:
            if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
                raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))
示例#4
0
def _test_dbus_old_wps_reg(dev, apdev):
    (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])

    hapd = start_ap(apdev[0])
    bssid = apdev[0]['bssid']
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].request("SET wps_cred_processing 2")

    for arg in [ (123, "12345670"),
                 ("123", "12345670") ]:
        try:
            if_obj.wpsReg(arg[0], arg[1], dbus_interface=WPAS_DBUS_OLD_IFACE)
            raise Exception("Invalid wpsReg arguments accepted: " + str(arg))
        except dbus.exceptions.DBusException, e:
            if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
                raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))
示例#5
0
def _test_dbus_old_wps_pbc(dev, apdev):
    (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])

    dev[0].flush_scan_cache()
    hapd = start_ap(apdev[0])
    hapd.request("WPS_PBC")
    bssid = apdev[0]['bssid']
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].request("SET wps_cred_processing 2")

    for arg in [ 123, "123" ]:
        try:
            if_obj.wpsPbc(arg, dbus_interface=WPAS_DBUS_OLD_IFACE)
            raise Exception("Invalid wpsPbc arguments accepted: " + str(arg))
        except dbus.exceptions.DBusException, e:
            if not str(e).startswith("fi.epitest.hostap.WPASupplicant.InvalidOptions"):
                raise Exception("Unexpected error message for invalid wpsPbc: " + str(e))
示例#6
0
def _test_dbus_old_wps_pbc(dev, apdev):
    (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])

    dev[0].flush_scan_cache()
    hapd = start_ap(apdev[0])
    hapd.request("WPS_PBC")
    bssid = apdev[0]['bssid']
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].request("SET wps_cred_processing 2")

    for arg in [123, "123"]:
        try:
            if_obj.wpsPbc(arg, dbus_interface=WPAS_DBUS_OLD_IFACE)
            raise Exception("Invalid wpsPbc arguments accepted: " + str(arg))
        except dbus.exceptions.DBusException as e:
            if not str(e).startswith(
                    "fi.epitest.hostap.WPASupplicant.InvalidOptions"):
                raise Exception(
                    "Unexpected error message for invalid wpsPbc: " + str(e))

    class TestDbusWps(TestDbusOldWps):
        def __init__(self, bus, pbc_param):
            TestDbusOldWps.__init__(self, bus)
            self.pbc_param = pbc_param

        def run_wps(self, *args):
            logger.debug("run_wps: pbc_param=" + self.pbc_param)
            if_obj.wpsPbc(self.pbc_param, dbus_interface=WPAS_DBUS_OLD_IFACE)
            return False

    with TestDbusWps(bus, "any") as t:
        if not t.success():
            raise Exception("Expected signals not seen")

    res = if_obj.scanResults(dbus_interface=WPAS_DBUS_OLD_IFACE)
    if len(res) != 1:
        raise Exception("Unexpected number of scan results: " + str(res))
    for i in range(1):
        logger.debug("Scan result BSS path: " + res[i])
        bss_obj = bus.get_object(WPAS_DBUS_OLD_SERVICE, res[i])
        bss = bss_obj.properties(dbus_interface=WPAS_DBUS_OLD_BSSID,
                                 byte_arrays=True)
        logger.debug("BSS: " + str(bss))

    dev[0].wait_connected(timeout=10)
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected(timeout=10)
    dev[0].request("FLUSH")

    hapd.request("WPS_PBC")
    dev[0].scan_for_bss(bssid, freq="2412")

    with TestDbusWps(bus, bssid) as t:
        if not t.success():
            raise Exception("Expected signals not seen")

    dev[0].wait_connected(timeout=10)
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected(timeout=10)

    hapd.disable()
    dev[0].flush_scan_cache()