def config_wifi_connected(self, state, toggle_off = True): print "====================== config_wifi_connected ======================" # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial = self.wifi_trafic_serial)() if toggle_off: wifi_generic_steps.set_wifi(state="OFF",serial = serial)() wifi_generic_steps.set_wifi(state="OFF",serial = serial2)() wifi_generic_steps.set_wifi(state="ON",serial = serial)() wifi_generic_steps.set_wifi(state="ON",serial = serial2)() if interface5ghz == "1": ap_steps.setup(mode="n", security = "wpa2", wifi_password= attrs["passphrase"], new_ssid= attrs["ap_name"] if str(attrs["new_ssid"]).lower() == "none" else attrs["new_ssid"], interface5ghz=interface5ghz, encryption="aes", channel_no=channel_no)() if state: # add the Wi-Fi network wifi_generic_steps.add_network(ssid = attrs["ap_name"] if str(attrs["new_ssid"]).lower() == "none" else attrs["new_ssid"], security = attrs["dut_security"], password = attrs["passphrase"], identity = attrs["radius_identity"], EAP_method = attrs["EAP_method"], phase_2_auth = attrs["phase_2_auth"], user_certificate = attrs["user_certificate"], serial = self.wifi_trafic_serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial = self.wifi_trafic_serial)()
def connect_to_ap(serial, condition, mode='bg', security='none', dut_security=None, ddwrt_ap_name='ddwrt', ddwrt_ap_pass='******', encryption=None, iteration=1, q=None): for _ in range(0, iteration): # configure ap ap_steps.setup(mode, security, encryption=encryption, wifi_password=ddwrt_ap_pass, new_ssid=ddwrt_ap_name, serial=serial)() # turn display on, if turned off ui_steps.wake_up_device(serial=serial)() # ensure the device is unlocked ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial=serial)() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=serial)() # add the Wi-Fi network wifi_generic_steps.add_network(ssid=ddwrt_ap_name, security=dut_security, password=ddwrt_ap_pass, serial=serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=serial)() # check we are connected to the correct network. wifi_generic_steps.check_connection_info(serial=serial, SSID=ddwrt_ap_name, state='CONNECTED/CONNECTED')() # check connection obj = wifi_generic_steps.ping_gateway(serial=serial) obj() if 'passed' in obj.resolution.lower(): return True if q is None else q.put(['Pass']) else: return False if q is None else q.put(['Success'])
# ensure the device is unlocked ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial=serial)() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=serial)() # add the Wi-Fi network wifi_generic_steps.add_network( ssid=ddwrt_ap_name if str(new_ssid).lower() == "none" else new_ssid, security=dut_security, password=ddwrt_ap_pass, identity=radius_identity, EAP_method=EAP_method, phase_2_auth=phase_2_auth, user_certificate=user_certificate, ca_certificate=ca_certificates, serial=serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=serial)() # check we are connected to the correct network. wifi_generic_steps.check_connection_info( serial=serial, SSID=ddwrt_ap_name if str(new_ssid).lower() == "none" else new_ssid, state='CONNECTED/CONNECTED')() # check connection
# ensure the device is unlocked ui_steps.unlock_device(serial = serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial = serial)() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial = serial)() if test_type == "auto_roam": # add the physical wifi network wifi_generic_steps.add_network(ssid = ddwrt_ap_name+"_virt", security = dut_security, password = ddwrt_ap_pass, identity = radius_identity, EAP_method = EAP_method, phase_2_auth = phase_2_auth, user_certificate = user_certificate, serial = serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial = serial)() # clear logcat adb_steps.command("logcat -c", serial = serial)() # add the Wi-Fi network wifi_generic_steps.add_network(ssid = ddwrt_ap_name, security = "WPA2",
# turn display on, if turned off ui_steps.wake_up_device(serial=serial)() # ensure the device is unlocked ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial=serial)() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=serial)() # add a network wifi_generic_steps.add_network(ssid=ddwrt_ap_name, security=dut_security, password=ddwrt_ap_pass, serial=serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=serial)() # check we are connected to the correct network. wifi_generic_steps.check_connection_info(serial=serial, SSID=ddwrt_ap_name, state='CONNECTED/CONNECTED')() #verify in logcat for the message wifi_generic_steps.check_lease_time(serial=serial, dhcp_lease_time=dhcp_lease_time)() #ping the gateway
# turn display on, if turned off ui_steps.wake_up_device(serial = serial)() # ensure the device is unlocked ui_steps.unlock_device(serial = serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial = serial)() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial = serial)() # add 1st Wi-Fi network wifi_generic_steps.add_network(ssid = ref_ap_name, security = ref_ap_security, password = ref_ap_pw, serial = serial)() for x in range(0, 11): # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=serial)() finish = time.time() + int(duration) print "Runnign stability test for " + duration + " seconds" while finish > time.time(): # check we are connected to the correct network. wifi_generic_steps.check_connection_info(serial=serial, SSID=ref_ap_name, state='CONNECTED/CONNECTED')() wifi_generic_steps.ping_gateway(serial=serial, trycount="30")()
wifi_generic_steps.clear_saved_networks(serial = serial)() # AM off wifi_generic_steps.set_airplane_mode(state = "OFF", serial = serial)() # config AP2 virt disabled ap_steps.setup_virtual_interface(enable=False, interface5ghz = interface5ghz_ap2, virt_if_idx = virt_if_idx, serial = serial)() # add the Wi-Fi network wifi_generic_steps.add_network(ssid = ap_name_virt, security = dut_security, password = ap_pass, identity = radius_identity, EAP_method = EAP_method, phase_2_auth = phase_2_auth, user_certificate = user_certificate, serial = serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial = serial)() # check we are connected to the correct network. wifi_generic_steps.check_connection_info(serial = serial, SSID = ap_name_virt, state='CONNECTED/CONNECTED')() count = 0 while count < int(iterations): if int(iterations) > 1:
content = wifi_utils.get_connection_content(serial = serial) connection_info = wifi_utils.get_connection_info(content) net_mask = connection_info["net_mask"] gateway= connection_info["Gateway"] # find a free IP address static_ip = wifi_generic_steps.find_available_ip(serial = serial,ip_range=static_ip_range)() # clear all saved networks wifi_generic_steps.clear_saved_networks(serial = serial)() # add the Wi-Fi network with static IP wifi_generic_steps.add_network(serial = serial, ssid = ddwrt_ap_name, security = dut_security, password = ddwrt_ap_pass, ip_settings = "Static", ip_address = static_ip, gateway = gateway, network_prefix_length = net_mask)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial = serial)() # check we are connected to the correct network wifi_generic_steps.check_connection_info(serial = serial, SSID = ddwrt_ap_name, state='CONNECTED/CONNECTED')() wifi_generic_steps.ping_gateway(serial = serial)() # forget the SSID wifi_generic_steps.remove_network(ap_name = ddwrt_ap_name,
# ensure the device is unlocked ui_steps.unlock_device(serial = serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial = serial)() ##### for static IP TCs find the network mask, gateway and static IP address if ip_settings: # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial = serial)() # connect to the AP via DHCP wifi_generic_steps.add_network(ssid = ddwrt_ap_name, security = dut_security, password = ddwrt_ap_pass, identity = radius_identity, EAP_method = EAP_method, phase_2_auth = phase_2_auth, ca_certificate = ca_certificates, serial = serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial = serial)() # check we are connected to the correct network wifi_generic_steps.check_connection_info(serial = serial, SSID = ddwrt_ap_name, state='CONNECTED/CONNECTED')() wifi_generic_steps.ping_gateway(serial = serial)() # get connection info from current DHCP connection content = wifi_utils.get_connection_content(serial = serial)
##### test start ##### adb_steps.connect_device(serial = serial, port = adb_server_port)() # turn display on, if turned off ui_steps.wake_up_device(serial = serial)() # ensure the device is unlocked ui_steps.unlock_device(serial = serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial = serial)() # add dummy Wi-Fi network wifi_generic_steps.add_network(ssid = dummy_SSID, security = "WPA", password = "******", serial = serial)() # check the networks are scanned for ap_name in aps: wifi_generic_steps.scan_and_check_ap(serial = serial, ap=ap_name)() # remove all networks wifi_generic_steps.clear_saved_networks(serial = serial)() # check the networks are scanned for ap_name in aps: wifi_generic_steps.scan_and_check_ap(serial = serial, ap=ap_name)()
ui_steps.wake_up_device(serial=args["serial"])() # ensure the device is unlocked ui_steps.unlock_device(serial=args["serial"], pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial=args["serial"])() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=args["serial"])() if script_params["execute_add_network_and_test_ping"] == "True": # add the Wi-Fi network wifi_generic_steps.add_network(ssid=script_params["ap_name"], security=script_params["dut_security"], password=script_params["passphrase"], serial=args["serial"])() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=args["serial"])() # check we are connected to the correct network. wifi_generic_steps.check_connection_info(serial=args["serial"], SSID=script_params["ap_name"], state='CONNECTED/CONNECTED')() # check connection wifi_generic_steps.ping_gateway(trycount=5, serial=args["serial"])() if script_params["iterate_connect_disconnect"] == "True": for x in xrange(int(script_params["iterations"])):
# turn display on, if turned off ui_steps.wake_up_device(serial=serial)() # ensure the device is unlocked ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=serial)() # go to home screen ui_steps.press_home(serial=serial)() # add a network wifi_generic_steps.add_network(ssid=net_ap_ssid, security=net_ap_security, password=net_ap_password, serial=serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=serial)() # open the chrome and connect to a ssl site browser_steps.open_chrome_first_time( serial=serial, intent=True, url_to_open="https://www.google.ro/?gws_rd=ssl")() # verify that ssl button appears ui_steps.wait_for_view( serial=serial, view_to_find={"resourceId": "com.android.chrome:id/security_button"},
encryption = encryption, wifi_password = "******", radius_ip = radius_ip, radius_secret = radius_secret, channel_bw = channel_bw, serial = serial)() ''' # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=serial)() # add the Wi-Fi network wifi_generic_steps.add_network( ssid="SSG_LAB_VAL_S3", security="WPA2", password="******", #identity = radius_identity, #EAP_method = EAP_method, #phase_2_auth = phase_2_auth, #user_certificate = user_certificate, serial=serial)() # wait until the device connects to a wifi network wifi_generic_steps.wait_until_connected(serial=serial)() # check we are connected to the correct network wifi_generic_steps.check_connection_info(serial=serial, SSID="SSG_LAB_VAL_S3", state='CONNECTED/CONNECTED', Security="WPA_PSK")() #pairwise_cipher=pairwise_cipher)()
ui_steps.wake_up_device(serial=serial)() # ensure the device is unlocked ui_steps.unlock_device(serial=serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial=serial)() # make sure the test SSID is not saved in the known list wifi_generic_steps.clear_saved_networks(serial=serial)() # try to connect to the AP with wrong password wifi_generic_steps.add_network(ssid=ddwrt_ap_name, security=dut_security, password=ddwrt_ap_pass + "_wrong", identity=radius_identity, EAP_method=EAP_method, phase_2_auth=phase_2_auth, serial=serial)() # verify in the GUI that DUT is not connected wifi_generic_steps.check_wifi_state_disconnected(ap_name=ddwrt_ap_name, security=dut_security, encryption=encryption, wrong_password=True, serial=serial)() # check that the SSID is "remembered" on DUT wifi_generic_steps.scan_and_check_ap(ap=ddwrt_ap_name, serial=serial)() #wifi_generic_steps.wifi_check_SSID_known(ap_name = ddwrt_ap_name, # serial = serial)()
hotSpot_band=hotSpot_band, hotSpot_pass=hotSpot_pass)() # turn on the HotSpot wifi_generic_steps.set_hotSpot(serial=serial, hotSpot_state="ON")() # turn display on, if turned off on reference device ui_steps.wake_up_device(serial=serial2)() # ensure the device is unlocked ui_steps.unlock_device(serial=serial2, pin=wifi_defaults.wifi['pin'])() # make sure there are no saved networks wifi_generic_steps.clear_saved_networks(serial=serial2)() # connect to the HotSpot with reference device wifi_generic_steps.add_network(serial=serial2, ssid=hotSpot_name, security=hotSpot_security, password=hotSpot_pass)() # wait until the reference device is connected wifi_generic_steps.wait_until_connected(serial=serial2)() # verify that reference device is connected wifi_generic_steps.ping_gateway(serial=serial2)() # turn off the HotSpot wifi_generic_steps.set_hotSpot(serial=serial, hotSpot_state="OFF")()