How to use set_network method in tempest

Best Python code snippet using tempest_python

test_wpas_ap.py

Source:test_wpas_ap.py Github

copy

Full Screen

...23 raise Exception("Unexpected DISASSOCIATE accepted")24 if "FAIL" not in dev[0].request("CHAN_SWITCH 0 2432"):25 raise Exception("Unexpected CHAN_SWITCH accepted")26 id = dev[0].add_network()27 dev[0].set_network(id, "mode", "2")28 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")29 dev[0].set_network(id, "key_mgmt", "NONE")30 dev[0].set_network(id, "frequency", "2412")31 dev[0].set_network(id, "scan_freq", "2412")32 dev[0].select_network(id)33 wait_ap_ready(dev[0])34 if "FAIL" not in dev[0].request("DEAUTHENTICATE foo"):35 raise Exception("Invalid DEAUTHENTICATE accepted")36 if "FAIL" not in dev[0].request("DISASSOCIATE foo"):37 raise Exception("Invalid DISASSOCIATE accepted")38 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")39 dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")40 hwsim_utils.test_connectivity(dev[0], dev[1])41 hwsim_utils.test_connectivity(dev[1], dev[2])42 addr1 = dev[1].p2p_interface_addr()43 addr2 = dev[2].p2p_interface_addr()44 addrs = [addr1, addr2]45 sta = dev[0].get_sta(None)46 if sta['addr'] not in addrs:47 raise Exception("Unexpected STA address")48 sta1 = dev[0].get_sta(sta['addr'])49 if sta1['addr'] not in addrs:50 raise Exception("Unexpected STA address")51 sta2 = dev[0].get_sta(sta['addr'], next=True)52 if sta2['addr'] not in addrs:53 raise Exception("Unexpected STA2 address")54 sta3 = dev[0].get_sta(sta2['addr'], next=True)55 if len(sta3) != 0:56 raise Exception("Unexpected STA iteration result (did not stop)")57 status = dev[0].get_status()58 if status['mode'] != "AP":59 raise Exception("Unexpected status mode")60 dev[1].dump_monitor()61 dev[2].dump_monitor()62 dev[0].request("DEAUTHENTICATE " + addr1)63 dev[0].request("DISASSOCIATE " + addr2)64 dev[1].wait_disconnected(timeout=10)65 dev[2].wait_disconnected(timeout=10)66 dev[1].wait_connected(timeout=10, error="Reconnection timed out")67 dev[2].wait_connected(timeout=10, error="Reconnection timed out")68 dev[1].request("DISCONNECT")69 dev[2].request("DISCONNECT")70def test_wpas_ap_open_isolate(dev):71 """wpa_supplicant AP mode - open network with client isolation"""72 try:73 dev[0].set("ap_isolate", "1")74 id = dev[0].add_network()75 dev[0].set_network(id, "mode", "2")76 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")77 dev[0].set_network(id, "key_mgmt", "NONE")78 dev[0].set_network(id, "frequency", "2412")79 dev[0].set_network(id, "scan_freq", "2412")80 dev[0].select_network(id)81 wait_ap_ready(dev[0])82 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")83 dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")84 hwsim_utils.test_connectivity(dev[0], dev[1])85 hwsim_utils.test_connectivity(dev[0], dev[2])86 hwsim_utils.test_connectivity(dev[1], dev[2], success_expected=False,87 timeout=1)88 finally:89 dev[0].set("ap_isolate", "0")90@remote_compatible91def test_wpas_ap_wep(dev):92 """wpa_supplicant AP mode - WEP"""93 id = dev[0].add_network()94 dev[0].set_network(id, "mode", "2")95 dev[0].set_network_quoted(id, "ssid", "wpas-ap-wep")96 dev[0].set_network(id, "key_mgmt", "NONE")97 dev[0].set_network(id, "frequency", "2412")98 dev[0].set_network(id, "scan_freq", "2412")99 dev[0].set_network_quoted(id, "wep_key0", "hello")100 dev[0].select_network(id)101 wait_ap_ready(dev[0])102 dev[1].connect("wpas-ap-wep", key_mgmt="NONE", wep_key0='"hello"',103 scan_freq="2412")104 hwsim_utils.test_connectivity(dev[0], dev[1])105 dev[1].request("DISCONNECT")106@remote_compatible107def test_wpas_ap_no_ssid(dev):108 """wpa_supplicant AP mode - invalid network configuration"""109 id = dev[0].add_network()110 dev[0].set_network(id, "mode", "2")111 dev[0].set_network(id, "key_mgmt", "NONE")112 dev[0].set_network(id, "frequency", "2412")113 dev[0].set_network(id, "scan_freq", "2412")114 dev[0].select_network(id)115 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)116 if ev is not None:117 raise Exception("Unexpected AP start")118@remote_compatible119def test_wpas_ap_default_frequency(dev):120 """wpa_supplicant AP mode - default frequency"""121 id = dev[0].add_network()122 dev[0].set_network(id, "mode", "2")123 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")124 dev[0].set_network(id, "key_mgmt", "NONE")125 dev[0].set_network(id, "scan_freq", "2412")126 dev[0].select_network(id)127 wait_ap_ready(dev[0])128 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2462")129 dev[1].request("DISCONNECT")130@remote_compatible131def test_wpas_ap_invalid_frequency(dev):132 """wpa_supplicant AP mode - invalid frequency configuration"""133 id = dev[0].add_network()134 dev[0].set_network(id, "mode", "2")135 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")136 dev[0].set_network(id, "key_mgmt", "NONE")137 dev[0].set_network(id, "frequency", "2413")138 dev[0].set_network(id, "scan_freq", "2412")139 dev[0].select_network(id)140 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)141 if ev is not None:142 raise Exception("Unexpected AP start")143def test_wpas_ap_wps(dev):144 """wpa_supplicant AP mode - WPS operations"""145 id = dev[0].add_network()146 dev[0].set_network(id, "mode", "2")147 dev[0].set_network_quoted(id, "ssid", "wpas-ap-wps")148 dev[0].set_network_quoted(id, "psk", "1234567890")149 dev[0].set_network(id, "frequency", "2412")150 dev[0].set_network(id, "scan_freq", "2412")151 dev[0].select_network(id)152 wait_ap_ready(dev[0])153 bssid = dev[0].p2p_interface_addr()154 logger.info("Test PBC mode start/stop")155 if "FAIL" not in dev[0].request("WPS_CANCEL"):156 raise Exception("Unexpected WPS_CANCEL success")157 dev[0].request("WPS_PBC")158 ev = dev[0].wait_event(["WPS-PBC-ACTIVE"])159 if ev is None:160 raise Exception("PBC mode start timeout")161 if "OK" not in dev[0].request("WPS_CANCEL"):162 raise Exception("Unexpected WPS_CANCEL failure")163 ev = dev[0].wait_event(["WPS-TIMEOUT"])164 if ev is None:165 raise Exception("PBC mode disabling timeout")166 logger.info("Test PBC protocol run")167 dev[0].request("WPS_PBC")168 ev = dev[0].wait_event(["WPS-PBC-ACTIVE"])169 if ev is None:170 raise Exception("PBC mode start timeout")171 dev[1].request("WPS_PBC")172 dev[1].wait_connected(timeout=30, error="WPS PBC operation timed out")173 hwsim_utils.test_connectivity(dev[0], dev[1])174 logger.info("Test AP PIN to learn configuration")175 pin = dev[0].request("WPS_AP_PIN random")176 if "FAIL" in pin:177 raise Exception("Could not generate random AP PIN")178 if pin not in dev[0].request("WPS_AP_PIN get"):179 raise Exception("Could not fetch current AP PIN")180 dev[2].wps_reg(bssid, pin)181 hwsim_utils.test_connectivity(dev[1], dev[2])182 dev[1].request("REMOVE_NETWORK all")183 dev[2].request("REMOVE_NETWORK all")184 logger.info("Test AP PIN operations")185 dev[0].request("WPS_AP_PIN disable")186 dev[0].request("WPS_AP_PIN set " + pin + " 1")187 time.sleep(1.1)188 if "FAIL" not in dev[0].request("WPS_AP_PIN get"):189 raise Exception("AP PIN unexpectedly still enabled")190 pin = dev[1].wps_read_pin()191 dev[0].request("WPS_PIN any " + pin)192 dev[1].request("WPS_PIN any " + pin)193 dev[1].wait_connected(timeout=30)194 dev[1].request("REMOVE_NETWORK all")195 dev[1].dump_monitor()196 dev[0].request("WPS_PIN any " + pin + " 100")197 dev[1].request("WPS_PIN any " + pin)198 dev[1].wait_connected(timeout=30)199 dev[1].request("REMOVE_NETWORK all")200 dev[1].dump_monitor()201 dev[0].request("WPS_AP_PIN set 12345670")202 dev[0].dump_monitor()203 runs = ("88887777", "12340000", "00000000", "12345670")204 for pin in runs:205 logger.info("Try AP PIN " + pin)206 dev[2].dump_monitor()207 dev[2].request("WPS_REG " + bssid + " " + pin)208 ev = dev[2].wait_event(["WPS-SUCCESS", "WPS-FAIL msg"], timeout=15)209 if ev is None:210 raise Exception("WPS operation timed out")211 if "WPS-SUCCESS" in ev:212 raise Exception("WPS operation succeeded unexpectedly")213 dev[2].wait_disconnected(timeout=10)214 dev[2].request("WPS_CANCEL")215 dev[2].request("REMOVE_NETWORK all")216 ev = dev[0].wait_event(["WPS-AP-SETUP-LOCKED"])217 if ev is None:218 raise Exception("WPS AP PIN not locked")219 dev[0].dump_monitor()220 logger.info("Test random AP PIN timeout")221 pin = dev[0].request("WPS_AP_PIN random 1")222 if "FAIL" in pin:223 raise Exception("Could not generate random AP PIN")224 res = dev[0].request("WPS_AP_PIN get")225 if pin not in res:226 raise Exception("Could not fetch current AP PIN")227 for i in range(10):228 time.sleep(0.2)229 res = dev[0].request("WPS_AP_PIN get")230 if "FAIL" in res:231 break232 if "FAIL" not in res:233 raise Exception("WPS_AP_PIN random timeout did not work")234 if "FAIL" not in dev[0].request("WPS_AP_PIN foo"):235 raise Exception("Invalid WPS_AP_PIN command not rejected")236 if "FAIL" not in dev[0].request("WPS_AP_PIN set"):237 raise Exception("Invalid WPS_AP_PIN command not rejected")238def test_wpas_ap_wps_frag(dev):239 """wpa_supplicant AP mode - WPS operations with fragmentation"""240 id = dev[0].add_network()241 dev[0].set_network(id, "mode", "2")242 dev[0].set_network_quoted(id, "ssid", "wpas-ap-wps")243 dev[0].set_network_quoted(id, "psk", "1234567890")244 dev[0].set_network(id, "frequency", "2412")245 dev[0].set_network(id, "scan_freq", "2412")246 dev[0].set_network(id, "fragment_size", "300")247 dev[0].select_network(id)248 wait_ap_ready(dev[0])249 bssid = dev[0].own_addr()250 pin = dev[1].wps_read_pin()251 dev[0].request("WPS_PIN any " + pin)252 dev[1].scan_for_bss(bssid, freq="2412")253 dev[1].request("WPS_PIN " + bssid + " " + pin)254 dev[1].wait_connected(timeout=30)255def test_wpas_ap_wps_pbc_overlap(dev):256 """wpa_supplicant AP mode - WPS operations with PBC overlap"""257 id = dev[0].add_network()258 dev[0].set_network(id, "mode", "2")259 dev[0].set_network_quoted(id, "ssid", "wpas-ap-wps")260 dev[0].set_network_quoted(id, "psk", "1234567890")261 dev[0].set_network(id, "frequency", "2412")262 dev[0].set_network(id, "scan_freq", "2412")263 dev[0].select_network(id)264 wait_ap_ready(dev[0])265 bssid = dev[0].p2p_interface_addr()266 dev[1].scan_for_bss(bssid, freq="2412")267 dev[1].dump_monitor()268 dev[2].scan_for_bss(bssid, freq="2412")269 dev[2].dump_monitor()270 dev[0].request("WPS_PBC")271 dev[1].request("WPS_PBC " + bssid)272 dev[2].request("WPS_PBC " + bssid)273 ev = dev[1].wait_event(["WPS-M2D"], timeout=15)274 if ev is None:275 raise Exception("PBC session overlap not detected (dev1)")276 if "config_error=12" not in ev:277 raise Exception("PBC session overlap not correctly reported (dev1)")278 ev = dev[2].wait_event(["WPS-M2D"], timeout=15)279 if ev is None:280 raise Exception("PBC session overlap not detected (dev2)")281 if "config_error=12" not in ev:282 raise Exception("PBC session overlap not correctly reported (dev2)")283 if "FAIL-PBC-OVERLAP" not in dev[0].request("WPS_PBC"):284 raise Exception("WPS_PBC(AP) accepted during overlap")285 if "FAIL-PBC-OVERLAP" not in dev[0].request("WPS_PBC any"):286 raise Exception("WPS_PBC(AP) accepted during overlap")287 dev[0].request("WPS_CANCEL")288 dev[1].request("WPS_CANCEL")289 dev[2].request("WPS_CANCEL")290@remote_compatible291def test_wpas_ap_wps_disabled(dev):292 """wpa_supplicant AP mode - WPS disabled"""293 id = dev[0].add_network()294 dev[0].set_network(id, "mode", "2")295 dev[0].set_network_quoted(id, "ssid", "wpas-ap-no-wps")296 dev[0].set_network_quoted(id, "psk", "12345678")297 dev[0].set_network(id, "frequency", "2412")298 dev[0].set_network(id, "scan_freq", "2412")299 dev[0].set_network(id, "wps_disabled", "1")300 dev[0].select_network(id)301 wait_ap_ready(dev[0])302 dev[1].connect("wpas-ap-no-wps", psk="12345678", scan_freq="2412")303 dev[1].request("DISCONNECT")304 dev[1].wait_disconnected()305def test_wpas_ap_dfs(dev):306 """wpa_supplicant AP mode - DFS"""307 if dev[0].get_mcc() > 1:308 raise HwsimSkip("DFS is not supported with multi channel contexts")309 try:310 _test_wpas_ap_dfs(dev)311 finally:312 set_country("00")313 dev[0].request("SET country 00")314 dev[1].flush_scan_cache()315def _test_wpas_ap_dfs(dev):316 set_country("US")317 dev[0].request("SET country US")318 id = dev[0].add_network()319 dev[0].set_network(id, "mode", "2")320 dev[0].set_network_quoted(id, "ssid", "wpas-ap-dfs")321 dev[0].set_network(id, "key_mgmt", "NONE")322 dev[0].set_network(id, "frequency", "5260")323 dev[0].set_network(id, "scan_freq", "5260")324 dev[0].select_network(id)325 ev = dev[0].wait_event(["DFS-CAC-START"])326 if ev is None:327 # For now, assume DFS is not supported by all kernel builds.328 raise HwsimSkip("CAC did not start - assume not supported")329 ev = dev[0].wait_event(["DFS-CAC-COMPLETED"], timeout=70)330 if ev is None:331 raise Exception("CAC did not complete")332 if "success=1" not in ev:333 raise Exception("CAC failed")334 if "freq=5260" not in ev:335 raise Exception("Unexpected DFS freq result")336 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])337 if ev is None:338 raise Exception("AP failed to start")339 dev[1].connect("wpas-ap-dfs", key_mgmt="NONE")340 dev[1].wait_regdom(country_ie=True)341 dev[0].request("DISCONNECT")342 dev[1].request("DISCONNECT")343 dev[1].request("ABORT_SCAN")344 dev[1].wait_disconnected()345@remote_compatible346def test_wpas_ap_disable(dev):347 """wpa_supplicant AP mode - DISABLE_NETWORK"""348 id = dev[0].add_network()349 dev[0].set_network(id, "mode", "2")350 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")351 dev[0].set_network(id, "key_mgmt", "NONE")352 dev[0].set_network(id, "scan_freq", "2412")353 dev[0].select_network(id)354 ev = dev[0].wait_event(["AP-ENABLED"])355 if ev is None:356 raise Exception("AP-ENABLED event not seen")357 wait_ap_ready(dev[0])358 dev[0].request("DISABLE_NETWORK %d" % id)359 ev = dev[0].wait_event(["AP-DISABLED"])360 if ev is None:361 raise Exception("AP-DISABLED event not seen")362 dev[0].wait_disconnected()363def test_wpas_ap_acs(dev):364 """wpa_supplicant AP mode - ACS"""365 res = dev[0].get_capability("acs")366 if res is None or "ACS" not in res:367 raise HwsimSkip("ACS not supported")368 # For now, make sure the last operating channel was on 2.4 GHz band to get369 # sufficient survey data from mac80211_hwsim.370 id = dev[0].add_network()371 dev[0].set_network(id, "mode", "2")372 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")373 dev[0].set_network(id, "key_mgmt", "NONE")374 dev[0].set_network(id, "frequency", "2412")375 dev[0].set_network(id, "scan_freq", "2412")376 dev[0].select_network(id)377 wait_ap_ready(dev[0])378 dev[0].request("REMOVE_NETWORK all")379 dev[0].wait_disconnected()380 id = dev[0].add_network()381 dev[0].set_network(id, "mode", "2")382 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")383 dev[0].set_network(id, "key_mgmt", "NONE")384 dev[0].set_network(id, "frequency", "2417")385 dev[0].set_network(id, "scan_freq", "2417")386 dev[0].set_network(id, "acs", "1")387 dev[0].select_network(id)388 wait_ap_ready(dev[0])389 # ACS prefers channels 1, 6, 11390 freq = dev[0].get_status_field('freq')391 if freq == "2417":392 raise Exception("Unexpected operating channel selected")393 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq=freq)394@remote_compatible395def test_wpas_ap_and_assoc_req_p2p_ie(dev):396 """wpa_supplicant AP mode - unexpected P2P IE in Association Request"""397 try:398 _test_wpas_ap_and_assoc_req_p2p_ie(dev)399 finally:400 dev[1].request("VENDOR_ELEM_REMOVE 13 *")401 dev[0].request("P2P_SET disabled 0")402def _test_wpas_ap_and_assoc_req_p2p_ie(dev):403 dev[0].request("P2P_SET disabled 1")404 id = dev[0].add_network()405 dev[0].set_network(id, "mode", "2")406 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")407 dev[0].set_network(id, "key_mgmt", "NONE")408 dev[0].set_network(id, "frequency", "2412")409 dev[0].set_network(id, "scan_freq", "2412")410 dev[0].select_network(id)411 wait_ap_ready(dev[0])412 dev[1].request("VENDOR_ELEM_ADD 13 dd04506f9a09")413 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")414 dev[1].request("DISCONNECT")415 dev[1].wait_disconnected()416 dev[0].request("DISCONNECT")417 dev[0].wait_disconnected()418@remote_compatible419def test_wpas_ap_open_ht_disabled(dev):420 """wpa_supplicant AP mode - open network and HT disabled"""421 id = dev[0].add_network()422 dev[0].set_network(id, "mode", "2")423 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")424 dev[0].set_network(id, "key_mgmt", "NONE")425 dev[0].set_network(id, "frequency", "2412")426 dev[0].set_network(id, "scan_freq", "2412")427 dev[0].set_network(id, "disable_ht", "1")428 dev[0].select_network(id)429 wait_ap_ready(dev[0])430 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")431 hwsim_utils.test_connectivity(dev[0], dev[1])432def test_wpas_ap_failures(dev):433 """wpa_supplicant AP mode - failures"""434 # No SSID configured for AP mode435 id = dev[0].add_network()436 dev[0].set_network(id, "mode", "2")437 dev[0].set_network(id, "key_mgmt", "NONE")438 dev[0].set_network(id, "frequency", "2412")439 dev[0].set_network(id, "scan_freq", "2412")440 dev[0].select_network(id)441 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1)442 if ev is not None:443 raise Exception("Unexpected connection event")444 dev[0].request("REMOVE_NETWORK all")445 # Invalid pbss value(2) for AP mode446 dev[0].dump_monitor()447 id = dev[0].add_network()448 dev[0].set_network(id, "mode", "2")449 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")450 dev[0].set_network(id, "key_mgmt", "NONE")451 dev[0].set_network(id, "frequency", "2412")452 dev[0].set_network(id, "scan_freq", "2412")453 dev[0].set_network(id, "pbss", "2")454 dev[0].select_network(id)455 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",456 "CTRL-EVENT-DISCONNECTED"], timeout=0.1)457 if ev is not None and "CTRL-EVENT-CONNECTED" in ev:458 raise Exception("Unexpected connection event(2)")459 dev[0].request("REMOVE_NETWORK all")460def test_wpas_ap_oom(dev):461 """wpa_supplicant AP mode - OOM"""462 id = dev[0].add_network()463 dev[0].set_network(id, "mode", "2")464 dev[0].set_network_quoted(id, "ssid", "wpas-ap")465 dev[0].set_network_quoted(id, "psk", "1234567890")466 dev[0].set_network(id, "frequency", "2412")467 dev[0].set_network(id, "scan_freq", "2412")468 with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):469 dev[0].select_network(id)470 dev[0].wait_disconnected()471 dev[0].request("REMOVE_NETWORK all")472 id = dev[0].add_network()473 dev[0].set_network(id, "mode", "2")474 dev[0].set_network_quoted(id, "ssid", "wpas-ap")475 dev[0].set_network(id, "psk", "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")476 dev[0].set_network(id, "frequency", "2412")477 dev[0].set_network(id, "scan_freq", "2412")478 with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):479 dev[0].select_network(id)480 dev[0].wait_disconnected()481 dev[0].request("REMOVE_NETWORK all")482 id = dev[0].add_network()483 dev[0].set_network(id, "mode", "2")484 dev[0].set_network_quoted(id, "ssid", "wpas-ap")485 dev[0].set_network(id, "key_mgmt", "NONE")486 dev[0].set_network_quoted(id, "wep_key0", "hello")487 dev[0].set_network(id, "frequency", "2412")488 dev[0].set_network(id, "scan_freq", "2412")489 with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):490 dev[0].select_network(id)491 dev[0].wait_disconnected()492 dev[0].request("REMOVE_NETWORK all")493 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')494 wpas.interface_add("wlan5")495 wpas.request("SET manufacturer test")496 wpas.request("SET model_name test")497 wpas.request("SET model_number test")498 wpas.request("SET serial_number test")499 wpas.request("SET serial_number test")500 wpas.request("SET serial_number test")501 wpas.request("SET ap_vendor_elements dd0411223301")502 id = wpas.add_network()503 wpas.set_network(id, "mode", "2")504 wpas.set_network_quoted(id, "ssid", "wpas-ap")505 wpas.set_network(id, "key_mgmt", "NONE")506 wpas.set_network(id, "frequency", "2412")507 wpas.set_network(id, "scan_freq", "2412")508 for i in range(5):509 with alloc_fail(wpas, i, "=wpa_supplicant_conf_ap"):510 wpas.select_network(id)511 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",512 "CTRL-EVENT-DISCONNECTED"], timeout=1)513 wpas.request("DISCONNECT")514 wpas.wait_disconnected()515def test_wpas_ap_params(dev):516 """wpa_supplicant AP mode - parameters"""517 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')518 wpas.interface_add("wlan5")519 wpas.request("SET manufacturer test")520 wpas.request("SET model_name test")521 wpas.request("SET model_number test")522 wpas.request("SET serial_number test")523 wpas.request("SET serial_number test")524 wpas.request("SET serial_number test")525 wpas.request("SET ap_vendor_elements dd0411223301")526 id = wpas.add_network()527 wpas.set_network(id, "mode", "2")528 wpas.set_network_quoted(id, "ssid", "wpas-ap")529 wpas.set_network(id, "key_mgmt", "NONE")530 wpas.set_network(id, "frequency", "2412")531 wpas.set_network(id, "scan_freq", "2412")532 wpas.select_network(id)533 wpas.wait_connected()534 wpas.request("DISCONNECT")535 wpas.wait_disconnected()536 wpas.request("SET beacon_int 200 3")537 wpas.request("SET dtim_period 3")538 wpas.select_network(id)539 wpas.wait_connected()540 wpas.request("DISCONNECT")541 wpas.wait_disconnected()542 wpas.set_network(id, "beacon_int", "300")543 wpas.set_network(id, "dtim_period", "2")544 wpas.select_network(id)545 wpas.wait_connected()546 if "---- AP ----" not in wpas.request("PMKSA"):547 raise Exception("AP section missing from PMKSA output")548 if "OK" not in wpas.request("PMKSA_FLUSH"):549 raise Exception("PMKSA_FLUSH failed")550 wpas.request("DISCONNECT")551 wpas.wait_disconnected()552def test_wpas_ap_global_sta(dev):553 """wpa_supplicant AP mode - STA commands on global control interface"""554 id = dev[0].add_network()555 dev[0].set_network(id, "mode", "2")556 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")557 dev[0].set_network(id, "key_mgmt", "NONE")558 dev[0].set_network(id, "frequency", "2412")559 dev[0].set_network(id, "scan_freq", "2412")560 dev[0].select_network(id)561 wait_ap_ready(dev[0])562 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")563 addr1 = dev[1].own_addr()564 res = dev[0].global_request("STA " + addr1)565 if "UNKNOWN COMMAND" in res:566 raise Exception("STA command not known on global control interface")567 res = dev[0].global_request("STA-FIRST")568 if "UNKNOWN COMMAND" in res:569 raise Exception("STA-FIRST command not known on global control interface")570 res = dev[0].global_request("STA-NEXT " + addr1)571 if "UNKNOWN COMMAND" in res:572 raise Exception("STA-NEXT command not known on global control interface")573 dev[1].request("DISCONNECT")574 dev[1].wait_disconnected()575 dev[0].request("DISCONNECT")576 dev[0].wait_disconnected()577def test_wpas_ap_5ghz(dev):578 """wpa_supplicant AP mode - 5 GHz"""579 try:580 _test_wpas_ap_5ghz(dev)581 finally:582 set_country("00")583 dev[0].request("SET country 00")584 dev[1].flush_scan_cache()585def _test_wpas_ap_5ghz(dev):586 set_country("US")587 dev[0].request("SET country US")588 id = dev[0].add_network()589 dev[0].set_network(id, "mode", "2")590 dev[0].set_network_quoted(id, "ssid", "wpas-ap-5ghz")591 dev[0].set_network(id, "key_mgmt", "NONE")592 dev[0].set_network(id, "frequency", "5180")593 dev[0].set_network(id, "scan_freq", "5180")594 dev[0].select_network(id)595 wait_ap_ready(dev[0])596 dev[1].connect("wpas-ap-5ghz", key_mgmt="NONE", scan_freq="5180")597 dev[1].request("DISCONNECT")598 dev[1].wait_disconnected()599def test_wpas_ap_open_vht80(dev):600 """wpa_supplicant AP mode - VHT 80 MHz"""601 id = dev[0].add_network()602 dev[0].set("country", "FI")603 try:604 dev[0].set_network(id, "mode", "2")605 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")606 dev[0].set_network(id, "key_mgmt", "NONE")607 dev[0].set_network(id, "frequency", "5180")608 dev[0].set_network(id, "scan_freq", "5180")609 dev[0].set_network(id, "vht", "1")610 dev[0].set_network(id, "vht_center_freq1", "5210")611 dev[0].set_network(id, "max_oper_chwidth", "1")612 dev[0].set_network(id, "ht40", "1")613 dev[0].select_network(id)614 wait_ap_ready(dev[0])615 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="5180")616 sig = dev[1].request("SIGNAL_POLL").splitlines()617 hwsim_utils.test_connectivity(dev[0], dev[1])618 dev[1].request("DISCONNECT")619 dev[1].wait_disconnected()620 if "FREQUENCY=5180" not in sig:621 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))622 if "WIDTH=80 MHz" not in sig:623 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))624 finally:625 set_country("00")626 dev[0].set("country", "00")627 dev[1].flush_scan_cache()628def test_wpas_ap_no_ht(dev):629 """wpa_supplicant AP mode - HT disabled"""630 id = dev[0].add_network()631 dev[0].set_network(id, "mode", "2")632 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")633 dev[0].set_network(id, "key_mgmt", "NONE")634 dev[0].set_network(id, "frequency", "2412")635 dev[0].set_network(id, "scan_freq", "2412")636 dev[0].set_network(id, "ht", "0")637 dev[0].set_network(id, "wps_disabled", "1")638 dev[0].select_network(id)639 wait_ap_ready(dev[0])640 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")641 sig = dev[1].request("SIGNAL_POLL").splitlines()642 dev[1].request("DISCONNECT")643 dev[1].wait_disconnected()644 dev[0].request("REMOVE_NETWORK all")645 dev[0].wait_disconnected()646 id = dev[0].add_network()647 dev[0].set_network(id, "mode", "2")648 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")649 dev[0].set_network(id, "key_mgmt", "NONE")650 dev[0].set_network(id, "frequency", "2412")651 dev[0].set_network(id, "scan_freq", "2412")652 dev[0].set_network(id, "wps_disabled", "1")653 dev[0].select_network(id)654 wait_ap_ready(dev[0])655 dev[1].flush_scan_cache()656 dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")657 sig2 = dev[1].request("SIGNAL_POLL").splitlines()658 dev[1].request("DISCONNECT")659 dev[1].wait_disconnected()660 dev[0].request("REMOVE_NETWORK all")661 dev[0].wait_disconnected()662 if "WIDTH=20 MHz (no HT)" not in sig:663 raise Exception("HT was not disabled: " + str(sig))664 if "WIDTH=20 MHz" not in sig2:665 raise Exception("HT was not enabled: " + str(sig2))666def test_wpas_ap_async_fail(dev):667 """wpa_supplicant AP mode - Async failure"""668 id = dev[0].add_network()669 dev[0].set("country", "FI")670 try:671 dev[0].set_network(id, "mode", "2")672 dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")673 dev[0].set_network(id, "key_mgmt", "NONE")674 dev[0].set_network(id, "frequency", "5180")675 dev[0].set_network(id, "scan_freq", "5180")676 dev[0].set_network(id, "vht", "1")677 dev[0].set_network(id, "vht_center_freq1", "5210")678 dev[0].set_network(id, "max_oper_chwidth", "1")679 dev[0].set_network(id, "ht40", "1")680 with alloc_fail(dev[0], 1,681 "nl80211_get_scan_results;ieee80211n_check_scan"):682 dev[0].select_network(id)683 dev[0].wait_disconnected()684 finally:685 set_country("00")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful