当前位置: 首页>>代码示例>>Python>>正文


Python utils.alloc_fail函数代码示例

本文整理汇总了Python中utils.alloc_fail函数的典型用法代码示例。如果您正苦于以下问题:Python alloc_fail函数的具体用法?Python alloc_fail怎么用?Python alloc_fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了alloc_fail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ap_ft_oom

def test_ap_ft_oom(dev, apdev):
    """WPA2-PSK-FT and OOM"""
    skip_with_fips(dev[0])
    ssid = "test-ft"
    passphrase="12345678"

    params = ft_params1(ssid=ssid, passphrase=passphrase)
    hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
    params = ft_params2(ssid=ssid, passphrase=passphrase)
    hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)

    dev[0].connect(ssid, psk=passphrase, key_mgmt="FT-PSK", proto="WPA2",
                   scan_freq="2412")
    if dev[0].get_status_field('bssid') == apdev[0]['bssid']:
        dst = apdev[1]['bssid']
    else:
        dst = apdev[0]['bssid']

    dev[0].scan_for_bss(dst, freq="2412")
    with alloc_fail(dev[0], 1, "wpa_ft_gen_req_ies"):
        dev[0].roam(dst)
    with alloc_fail(dev[0], 1, "wpa_ft_mic"):
        dev[0].roam(dst, fail_test=True)
    with fail_test(dev[0], 1, "os_get_random;wpa_ft_prepare_auth_request"):
        dev[0].roam(dst, fail_test=True)
开发者ID:msolters,项目名称:rpi-softap,代码行数:25,代码来源:test_ap_ft.py

示例2: test_wpas_ap_oom

def test_wpas_ap_oom(dev):
    """wpa_supplicant AP mode - OOM"""
    id = dev[0].add_network()
    dev[0].set_network(id, "mode", "2")
    dev[0].set_network_quoted(id, "ssid", "wpas-ap")
    dev[0].set_network_quoted(id, "psk", "1234567890")
    dev[0].set_network(id, "frequency", "2412")
    dev[0].set_network(id, "scan_freq", "2412")
    with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):
        dev[0].select_network(id)
        dev[0].wait_disconnected()
    dev[0].request("REMOVE_NETWORK all")

    id = dev[0].add_network()
    dev[0].set_network(id, "mode", "2")
    dev[0].set_network_quoted(id, "ssid", "wpas-ap")
    dev[0].set_network(id, "psk", "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
    dev[0].set_network(id, "frequency", "2412")
    dev[0].set_network(id, "scan_freq", "2412")
    with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):
        dev[0].select_network(id)
        dev[0].wait_disconnected()
    dev[0].request("REMOVE_NETWORK all")

    id = dev[0].add_network()
    dev[0].set_network(id, "mode", "2")
    dev[0].set_network_quoted(id, "ssid", "wpas-ap")
    dev[0].set_network(id, "key_mgmt", "NONE")
    dev[0].set_network_quoted(id, "wep_key0", "hello")
    dev[0].set_network(id, "frequency", "2412")
    dev[0].set_network(id, "scan_freq", "2412")
    with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):
        dev[0].select_network(id)
        dev[0].wait_disconnected()
    dev[0].request("REMOVE_NETWORK all")

    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
    wpas.interface_add("wlan5")
    wpas.request("SET manufacturer test")
    wpas.request("SET model_name test")
    wpas.request("SET model_number test")
    wpas.request("SET serial_number test")
    wpas.request("SET serial_number test")
    wpas.request("SET serial_number test")
    wpas.request("SET ap_vendor_elements dd0411223301")
    id = wpas.add_network()
    wpas.set_network(id, "mode", "2")
    wpas.set_network_quoted(id, "ssid", "wpas-ap")
    wpas.set_network(id, "key_mgmt", "NONE")
    wpas.set_network(id, "frequency", "2412")
    wpas.set_network(id, "scan_freq", "2412")

    for i in range(5):
        with alloc_fail(wpas, i, "=wpa_supplicant_conf_ap"):
            wpas.select_network(id)
            ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED",
                                     "CTRL-EVENT-DISCONNECTED" ], timeout=1)
        wpas.request("DISCONNECT")
        wpas.wait_disconnected()
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:59,代码来源:test_wpas_ap.py

示例3: test_hapd_ctrl_ext_io_errors

def test_hapd_ctrl_ext_io_errors(dev, apdev):
    """hostapd and external I/O errors"""
    ssid = "hapd-ctrl"
    params = {"ssid": ssid}
    hapd = hostapd.add_ap(apdev[0], params)
    tests = ["MGMT_TX 1",
             "MGMT_TX 1q",
             "MGMT_RX_PROCESS freq=2412",
             "EAPOL_RX foo",
             "EAPOL_RX 00:11:22:33:44:55 1",
             "EAPOL_RX 00:11:22:33:44:55 1q"]
    for t in tests:
        if "FAIL" not in hapd.request(t):
            raise Exception("Invalid command accepted: " + t)
    with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_mgmt_tx"):
        if "FAIL" not in hapd.request("MGMT_TX 12"):
            raise Exception("MGMT_TX accepted during OOM")
    with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_eapol_rx"):
        if "FAIL" not in hapd.request("EAPOL_RX 00:11:22:33:44:55 11"):
            raise Exception("EAPOL_RX accepted during OOM")

    hapd.set("ext_mgmt_frame_handling", "1")
    tests = ["MGMT_RX_PROCESS freq=2412",
             "MGMT_RX_PROCESS freq=2412 ssi_signal=0",
             "MGMT_RX_PROCESS freq=2412 frame=1",
             "MGMT_RX_PROCESS freq=2412 frame=1q"]
    for t in tests:
        if "FAIL" not in hapd.request(t):
            raise Exception("Invalid command accepted: " + t)
    with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_mgmt_rx_process"):
        if "FAIL" not in hapd.request("MGMT_RX_PROCESS freq=2412 frame=11"):
            raise Exception("MGMT_RX_PROCESS accepted during OOM")
    hapd.set("ext_mgmt_frame_handling", "0")

    if "OK" not in hapd.request("DATA_TEST_CONFIG 1"):
        raise Exception("Failed to enable l2_test")
    if "OK" not in hapd.request("DATA_TEST_CONFIG 1"):
        raise Exception("Failed to enable l2_test(2)")
    tests = ["DATA_TEST_TX foo",
             "DATA_TEST_TX 00:11:22:33:44:55 foo",
             "DATA_TEST_TX 00:11:22:33:44:55 00:11:22:33:44:55 -1",
             "DATA_TEST_TX 00:11:22:33:44:55 00:11:22:33:44:55 256"]
    for t in tests:
        if "FAIL" not in hapd.request(t):
            raise Exception("Invalid command accepted: " + t)
    if "OK" not in hapd.request("DATA_TEST_CONFIG 0"):
        raise Exception("Failed to disable l2_test")
    tests = ["DATA_TEST_TX 00:11:22:33:44:55 00:11:22:33:44:55 0",
             "DATA_TEST_FRAME ifname=foo",
             "DATA_TEST_FRAME 1",
             "DATA_TEST_FRAME 11",
             "DATA_TEST_FRAME 112233445566778899aabbccddeefq"]
    for t in tests:
        if "FAIL" not in hapd.request(t):
            raise Exception("Invalid command accepted: " + t)
    with alloc_fail(hapd, 1, "=hostapd_ctrl_iface_data_test_frame"):
        if "FAIL" not in hapd.request("DATA_TEST_FRAME 112233445566778899aabbccddeeff"):
            raise Exception("DATA_TEST_FRAME accepted during OOM")
开发者ID:greearb,项目名称:hostap-ct,代码行数:58,代码来源:test_hapd_ctrl.py

示例4: test_erp_home_realm_oom

def test_erp_home_realm_oom(dev, apdev):
    """ERP and home realm OOM"""
    check_erp_capa(dev[0])
    params = int_eap_server_params()
    params['erp_send_reauth_start'] = '1'
    params['erp_domain'] = 'example.com'
    params['eap_server_erp'] = '1'
    params['disable_pmksa_caching'] = '1'
    hapd = hostapd.add_ap(apdev[0]['ifname'], params)

    for count in range(1, 3):
        with alloc_fail(dev[0], count, "eap_home_realm"):
            dev[0].request("ERP_FLUSH")
            dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
                           identity="[email protected]",
                           anonymous_identity="[email protected]",
                           password="password",
                           ca_cert="auth_serv/ca.pem", phase2="auth=PAP",
                           erp="1", scan_freq="2412", wait_connect=False)
            dev[0].wait_connected(timeout=10)
            wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
            dev[0].request("REMOVE_NETWORK all")
            dev[0].wait_disconnected()

    for count in range(1, 3):
        with alloc_fail(dev[0], count, "eap_home_realm"):
            dev[0].request("ERP_FLUSH")
            dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
                           identity="erp-ttls",
                           anonymous_identity="[email protected]",
                           password="password",
                           ca_cert="auth_serv/ca.pem", phase2="auth=PAP",
                           erp="1", scan_freq="2412", wait_connect=False)
            dev[0].wait_connected(timeout=10)
            wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
            dev[0].request("REMOVE_NETWORK all")
            dev[0].wait_disconnected()

    for count in range(1, 3):
        dev[0].request("ERP_FLUSH")
        dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
                       identity="[email protected]",
                       anonymous_identity="[email protected]",
                       password="password",
                       ca_cert="auth_serv/ca.pem", phase2="auth=PAP",
                       erp="1", scan_freq="2412", wait_connect=False)
        dev[0].wait_connected(timeout=10)
        if range > 1:
            continue
        with alloc_fail(dev[0], count, "eap_home_realm"):
            dev[0].request("DISCONNECT")
            dev[0].wait_disconnected(timeout=15)
            dev[0].request("RECONNECT")
            wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
            dev[0].request("REMOVE_NETWORK all")
            dev[0].wait_disconnected()
开发者ID:islipfd19,项目名称:hostap,代码行数:56,代码来源:test_erp.py

示例5: test_rsn_preauth_local_errors

def test_rsn_preauth_local_errors(dev, apdev):
    """RSN pre-authentication and local errors on AP"""
    params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
    params['rsn_preauth'] = '1'
    params['rsn_preauth_interfaces'] = "lo"
    hapd = hostapd.add_ap(apdev[0], params)
    bssid = hapd.own_addr()
    _bssid = binascii.unhexlify(bssid.replace(':', ''))

    sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW,
                         socket.htons(0x88c7))
    sock.bind(("lo", socket.htons(0x88c7)))

    foreign = b"\x02\x03\x04\x05\x06\x07"
    foreign2 = b"\x02\x03\x04\x05\x06\x08"
    proto = b"\x88\xc7"

    with alloc_fail(hapd, 1, "ap_sta_add;rsn_preauth_receive"):
        sock.send(_bssid + foreign + proto + struct.pack('>BBH', 2, 1, 0))
        wait_fail_trigger(hapd, "GET_ALLOC_FAIL")

    with alloc_fail(hapd, 1, "eapol_auth_alloc;rsn_preauth_receive"):
        sock.send(_bssid + foreign + proto + struct.pack('>BBH', 2, 1, 0))
        wait_fail_trigger(hapd, "GET_ALLOC_FAIL")
    sock.send(_bssid + foreign + proto + struct.pack('>BBH', 2, 1, 0))

    with alloc_fail(hapd, 1, "eap_server_sm_init;ieee802_1x_new_station;rsn_preauth_receive"):
        sock.send(_bssid + foreign2 + proto + struct.pack('>BBH', 2, 1, 0))
        wait_fail_trigger(hapd, "GET_ALLOC_FAIL")
    sock.send(_bssid + foreign2 + proto + struct.pack('>BBH', 2, 1, 0))

    hapd.request("DISABLE")
    tests = [(1, "=rsn_preauth_iface_add"),
             (2, "=rsn_preauth_iface_add"),
             (1, "l2_packet_init;rsn_preauth_iface_add"),
             (1, "rsn_preauth_iface_init"),
             (1, "rsn_preauth_iface_init")]
    for count, func in tests:
        with alloc_fail(hapd, count, func):
            if "FAIL" not in hapd.request("ENABLE"):
                raise Exception("ENABLE succeeded unexpectedly")

    hapd.set("rsn_preauth_interfaces", "lo  lo lo does-not-exist lo ")
    if "FAIL" not in hapd.request("ENABLE"):
        raise Exception("ENABLE succeeded unexpectedly")
    hapd.set("rsn_preauth_interfaces", " lo  lo ")
    if "OK" not in hapd.request("ENABLE"):
        raise Exception("ENABLE failed")
    sock.send(_bssid + foreign + proto + struct.pack('>BBH', 2, 1, 0))
    sock.send(_bssid + foreign2 + proto + struct.pack('>BBH', 2, 1, 0))
开发者ID:greearb,项目名称:hostap-ct,代码行数:50,代码来源:test_pmksa_cache.py

示例6: test_gas_anqp_oom_hapd

def test_gas_anqp_oom_hapd(dev, apdev):
    """GAS/ANQP query and OOM in hostapd"""
    hapd = start_ap(apdev[0])
    bssid = apdev[0]['bssid']

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

    with alloc_fail(hapd, 1, "gas_build_resp"):
        # This query will time out due to the AP not sending a response (OOM).
        if "OK" not in dev[0].request("ANQP_GET " + bssid + " 258"):
            raise Exception("ANQP_GET command failed")

        ev = dev[0].wait_event(["GAS-QUERY-START"], timeout=5)
        if ev is None:
            raise Exception("GAS query start timed out")

        ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10)
        if ev is None:
            raise Exception("GAS query timed out")
        if "result=TIMEOUT" not in ev:
            raise Exception("Unexpected result: " + ev)

        ev = dev[0].wait_event(["ANQP-QUERY-DONE"], timeout=10)
        if ev is None:
            raise Exception("ANQP-QUERY-DONE event not seen")
        if "result=FAILURE" not in ev:
            raise Exception("Unexpected result: " + ev)

    with alloc_fail(hapd, 1, "gas_anqp_build_comeback_resp"):
        hapd.set("gas_frag_limit", "50")

        # The first attempt of this query will time out due to the AP not
        # sending a response (OOM), but the retry succeeds.
        dev[0].request("FETCH_ANQP")
        ev = dev[0].wait_event(["GAS-QUERY-START"], timeout=5)
        if ev is None:
            raise Exception("GAS query start timed out")

        ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10)
        if ev is None:
            raise Exception("GAS query timed out")
        if "result=SUCCESS" not in ev:
            raise Exception("Unexpected result: " + ev)

        ev = dev[0].wait_event(["ANQP-QUERY-DONE"], timeout=10)
        if ev is None:
            raise Exception("ANQP-QUERY-DONE event not seen")
        if "result=SUCCESS" not in ev:
            raise Exception("Unexpected result: " + ev)
开发者ID:AstroProfundis,项目名称:hostap,代码行数:49,代码来源:test_gas.py

示例7: test_nfc_wps_handover_errors

def test_nfc_wps_handover_errors(dev, apdev):
    """WPS AP NFC handover report error cases"""
    ssid = "test-wps-nfc-handover"
    hapd = hostapd.add_ap(apdev[0],
                          { "ssid": ssid, "eap_server": "1", "wps_state": "1" })
    sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip()
    if "FAIL" in sel:
        raise Exception("Failed to generate NFC connection handover select")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER "):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 001122"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 001122 00"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 0 00"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 001122 0"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 00q122 001122"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 001122 001q22"):
        raise Exception("Unexpected handover report success")
    if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP FOO 001122 00"):
        raise Exception("Unexpected handover report success")
    for i in range(1, 3):
        with alloc_fail(hapd, i,
                        "wpabuf_alloc;hostapd_ctrl_iface_nfc_report_handover"):
            if "FAIL" not in hapd.request("NFC_REPORT_HANDOVER RESP WPS 001122 001122"):
                raise Exception("NFC_REPORT_HANDOVER RESP succeeded during OOM")
开发者ID:gxk,项目名称:hostap,代码行数:33,代码来源:test_nfc_wps.py

示例8: test_ap_qosmap_invalid

def test_ap_qosmap_invalid(dev, apdev):
    """QoS mapping ctrl_iface error handling"""
    ssid = "test-qosmap"
    params = { "ssid": ssid }
    hapd = hostapd.add_ap(apdev[0], params)
    if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"):
        raise Exception("Unexpected SEND_QOS_MAP_CONF success")
    if "FAIL" not in hapd.request("SET_QOS_MAP_SET "):
        raise Exception("Unexpected SET_QOS_MAP_SET success")
    if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3"):
        raise Exception("Unexpected SET_QOS_MAP_SET success")
    if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,-2,3"):
        raise Exception("Unexpected SET_QOS_MAP_SET success")
    if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59"):
        raise Exception("Unexpected SET_QOS_MAP_SET success")
    if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21"):
        raise Exception("Unexpected SET_QOS_MAP_SET success")

    if "FAIL" in hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55"):
        raise Exception("Unexpected SET_QOS_MAP_SET failure")
    if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"):
        raise Exception("Unexpected SEND_QOS_MAP_CONF success")
    if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44"):
        raise Exception("Unexpected SEND_QOS_MAP_CONF success")

    with fail_test(hapd, 1, "hostapd_ctrl_iface_set_qos_map_set"):
        if "FAIL" not in hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55"):
            raise Exception("SET_QOS_MAP_SET accepted during forced driver failure")

    dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
    with alloc_fail(hapd, 1,
                    "wpabuf_alloc;hostapd_ctrl_iface_send_qos_map_conf"):
        if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF " + dev[0].own_addr()):
            raise Exception("SEND_QOS_MAP_CONF accepted during OOM")
开发者ID:gxk,项目名称:hostap,代码行数:34,代码来源:test_ap_qosmap.py

示例9: _test_nfc_wps_handover_init

def _test_nfc_wps_handover_init(dev, apdev):
    dev[0].request("SET ignore_old_scan_res 1")
    ssid = "test-wps-nfc-handover-init"
    hapd = hostapd.add_ap(apdev[0],
                          { "ssid": ssid, "eap_server": "1", "wps_state": "1" })
    logger.info("NFC connection handover")
    req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip()
    if "FAIL" in req:
        raise Exception("Failed to generate NFC connection handover request")
    sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip()
    if "FAIL" in sel:
        raise Exception("Failed to generate NFC connection handover select")
    res = hapd.request("NFC_REPORT_HANDOVER RESP WPS " + req + " " + sel)
    if "FAIL" in res:
        raise Exception("Failed to report NFC connection handover to to hostapd")
    dev[0].dump_monitor()
    res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
    if "FAIL" in res:
        raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
    dev[0].wait_connected(timeout=15)
    check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)

    with alloc_fail(hapd, 1, "wps_build_nfc_handover_sel"):
        if "FAIL" not in hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR"):
            raise Exception("Unexpected NFC_GET_HANDOVER_SEL success during OOM")
开发者ID:AstroProfundis,项目名称:hostap,代码行数:25,代码来源:test_nfc_wps.py

示例10: test_tnc_peap_soh_errors

def test_tnc_peap_soh_errors(dev, apdev):
    """TNC PEAP-SoH local error cases"""
    params = int_eap_server_params()
    params["tnc"] = "1"
    hostapd.add_ap(apdev[0], params)

    tests = [ (1, "tncc_build_soh"),
              (1, "eap_msg_alloc;=eap_peap_phase2_request") ]
    for count, func in tests:
        with alloc_fail(dev[0], count, func):
            dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
                           eap="PEAP", identity="user", password="password",
                           ca_cert="auth_serv/ca.pem",
                           phase1="peapver=0 tnc=soh cryptobinding=0",
                           phase2="auth=MSCHAPV2",
                           scan_freq="2412", wait_connect=False)
            wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
            dev[0].request("REMOVE_NETWORK all")
            dev[0].wait_disconnected()

    with fail_test(dev[0], 1, "os_get_random;tncc_build_soh"):
        dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
                       eap="PEAP", identity="user", password="password",
                       ca_cert="auth_serv/ca.pem",
                       phase1="peapver=0 tnc=soh cryptobinding=0",
                       phase2="auth=MSCHAPV2",
                       scan_freq="2412", wait_connect=False)
        wait_fail_trigger(dev[0], "GET_FAIL")
        dev[0].request("REMOVE_NETWORK all")
        dev[0].wait_disconnected()
开发者ID:9A9A,项目名称:wpa_supplicant-fork,代码行数:30,代码来源:test_tnc.py

示例11: test_ap_acs_errors

def test_ap_acs_errors(dev, apdev):
    """Automatic channel selection failures"""
    clear_scan_cache(apdev[0])
    force_prev_ap_on_24g(apdev[0])
    params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678")
    params['channel'] = '0'
    params['acs_num_scans'] = '2'
    params['chanlist'] = '1'
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)

    with alloc_fail(hapd, 1, "acs_request_scan"):
        if "FAIL" not in hapd.request("ENABLE"):
            raise Exception("Unexpected success for ENABLE")

    hapd.dump_monitor()
    with fail_test(hapd, 1, "acs_request_scan"):
        if "FAIL" not in hapd.request("ENABLE"):
            raise Exception("Unexpected success for ENABLE")

    hapd.dump_monitor()
    with fail_test(hapd, 1, "acs_scan_complete"):
        hapd.enable()
        ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=10)
        if not ev:
            raise Exception("ACS start timed out")

    hapd.dump_monitor()
    with fail_test(hapd, 1, "acs_request_scan;acs_scan_complete"):
        hapd.enable()
        ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=10)
        if not ev:
            raise Exception("ACS start timed out")
开发者ID:gxk,项目名称:hostap,代码行数:32,代码来源:test_ap_acs.py

示例12: test_nfc_wps_password_token_sta

def test_nfc_wps_password_token_sta(dev, apdev):
    """NFC tag with password token on the station/Enrollee"""
    ssid = "test-wps-nfc-pw-token-conf"
    params = ap_wps_params(ssid)
    hapd = hostapd.add_ap(apdev[0], params)
    logger.info("WPS provisioning step using password token from station")
    wps = dev[0].request("WPS_NFC_TOKEN WPS").rstrip()
    if "FAIL" in wps:
        raise Exception("Failed to generate password token (WPS only)")
    pw = dev[0].request("WPS_NFC_TOKEN NDEF").rstrip()
    if "FAIL" in pw:
        raise Exception("Failed to generate password token")
    res = hapd.request("WPS_NFC_TAG_READ " + pw)
    if "FAIL" in res:
        raise Exception("Failed to provide NFC tag contents to hostapd")
    dev[0].dump_monitor()
    res = dev[0].request("WPS_NFC")
    if "FAIL" in res:
        raise Exception("Failed to start Enrollee using NFC password token")
    dev[0].wait_connected(timeout=30)
    check_wpa2_connection(dev[0], apdev[0], hapd, ssid)

    if "FAIL" not in hapd.request("WPS_NFC_TAG_READ 0"):
        raise Exception("Invalid WPS_NFC_TAG_READ accepted")
    if "FAIL" not in hapd.request("WPS_NFC_TAG_READ 0q"):
        raise Exception("Invalid WPS_NFC_TAG_READ accepted")
    with alloc_fail(hapd, 1,
                    "wpabuf_alloc;hostapd_ctrl_iface_wps_nfc_tag_read"):
        if "FAIL" not in hapd.request("WPS_NFC_TAG_READ 00"):
            raise Exception("WPS_NFC_TAG_READ accepted during OOM")
开发者ID:gxk,项目名称:hostap,代码行数:30,代码来源:test_nfc_wps.py

示例13: test_nfc_wps_config_token

def test_nfc_wps_config_token(dev, apdev):
    """NFC tag with configuration token from AP"""
    ssid = "test-wps-nfc-conf-token"
    params = ap_wps_params(ssid)
    hapd = hostapd.add_ap(apdev[0], params)
    logger.info("NFC configuration token from AP to station")
    conf = hapd.request("WPS_NFC_CONFIG_TOKEN NDEF").rstrip()
    if "FAIL" in conf:
        raise Exception("Failed to generate configuration token")
    ndef_conf = conf
    dev[0].dump_monitor()
    res = dev[0].request("WPS_NFC_TAG_READ " + conf)
    if "FAIL" in res:
        raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
    dev[0].wait_connected(timeout=15)
    check_wpa2_connection(dev[0], apdev[0], hapd, ssid)

    with alloc_fail(hapd, 1, "wps_get_oob_cred"):
        conf = hapd.request("WPS_NFC_CONFIG_TOKEN NDEF").rstrip()
        if "FAIL" not in conf:
            raise Exception("Unexpected configuration token received during OOM")

    wps_conf = hapd.request("WPS_NFC_CONFIG_TOKEN WPS").rstrip()
    if "FAIL" in wps_conf:
        raise Exception("Failed to generate configuration token (WPS)")
    if wps_conf not in ndef_conf:
        raise Exception("WPS config token not within NDEF encapsulated one")

    conf = hapd.request("WPS_NFC_CONFIG_TOKEN FOO").rstrip()
    if "FAIL" not in conf:
        raise Exception("Invalid WPS_NFC_CONFIG_TOKEN accepted")
开发者ID:gxk,项目名称:hostap,代码行数:31,代码来源:test_nfc_wps.py

示例14: test_bgscan_learn_oom

def test_bgscan_learn_oom(dev, apdev):
    """bgscan_learn OOM"""
    hapd = hostapd.add_ap(apdev[0], {"ssid": "bgscan"})

    with alloc_fail(dev[0], 1, "bgscan_learn_init"):
        dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
                       bgscan="learn:1:-20:2")
开发者ID:greearb,项目名称:hostap-ct,代码行数:7,代码来源:test_bgscan.py

示例15: test_ibss_rsn_oom

def test_ibss_rsn_oom(dev):
    """IBSS RSN OOM during wpa_init"""
    with alloc_fail(dev[0], 1, "wpa_init"):
        ssid="ibss-rsn"
        id = add_ibss_rsn(dev[0], ssid)
        connect_ibss_cmd(dev[0], id)
        bssid0 = wait_ibss_connection(dev[0])
开发者ID:9A9A,项目名称:wpa_supplicant-fork,代码行数:7,代码来源:test_ibss.py


注:本文中的utils.alloc_fail函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。