def run_once(self): """Test body.""" logging.info("- Set up AP, connect.") self.context.configure(hostap_config.HostapConfig( frequency=network_WiFi_RoamSuspend.FREQUENCY_1, mode=hostap_config.HostapConfig.MODE_11B, bssid=network_WiFi_RoamSuspend.BSSID_1)) router_ssid = self.context.router.get_ssid() self.context.assert_connect_wifi(xmlrpc_datatypes.AssociationParameters( ssid=router_ssid)) # For this short of a duration, the DUT should still consider itself # connected to the AP and simply resume without re-associating or # reconnect quickly enough without intervention from the connection # manager that it appears to remain connected. logging.info("- Short suspend, verify we're still connected.") self.context.client.do_suspend(10) self.context.assert_ping_from_dut() logging.info("- Reconfigure the AP during longer suspend.") self.context.client.do_suspend_bg(20) # Locally, let's wait 15 seconds to make sure the DUT is really asleep # before we proceed. time.sleep(15) self.context.configure(hostap_config.HostapConfig( ssid=router_ssid, frequency=network_WiFi_RoamSuspend.FREQUENCY_2, mode=hostap_config.HostapConfig.MODE_11A, bssid=network_WiFi_RoamSuspend.BSSID_2)) logging.info("- Verify that we roam to same network w/new parameters.") self.context.wait_for_connection(router_ssid, network_WiFi_RoamSuspend.FREQUENCY_2) self.context.router.deconfig()
def run_once(self): """Test body.""" ap_configs = [ hostap_config.HostapConfig( ssid='a visible network', frequency=2437, mode=hostap_config.HostapConfig.MODE_11G), hostap_config.HostapConfig( hide_ssid=True, ssid='a hidden network', frequency=2437, mode=hostap_config.HostapConfig.MODE_11G) ] for ap_config in ap_configs: self.context.configure(ap_config) client_config = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid(), is_hidden=ap_config.hide_ssid) self.context.assert_connect_wifi(client_config) self.context.assert_ping_from_dut() # Check that shill's opinion of our hidden-ness is correct. self.check_hidden(self.context.router.get_ssid(), ap_config.hide_ssid is True) self.context.client.shill.disconnect( self.context.router.get_ssid())
def run_once(self): """Test body.""" wpa_config = xmlrpc_security_types.WPAConfig( psk='chromeos', wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA, wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP, xmlrpc_security_types.WPAConfig.CIPHER_CCMP], wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP]) ap_config = hostap_config.HostapConfig( ssid=self.TEST_SSID, frequency=2412, mode=hostap_config.HostapConfig.MODE_11B, security_config=wpa_config) self.context.configure(ap_config) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid(), security_config=wpa_config) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() self.context.client.shill.disconnect(assoc_params.ssid) # This deconfig erases the state stored in the router around WPA. self.context.router.deconfig() # Now we change the same SSID to be an open network. ap_config = hostap_config.HostapConfig( ssid=self.TEST_SSID, frequency=2412, mode=hostap_config.HostapConfig.MODE_11B) self.context.configure(ap_config) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid()) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() self.context.client.shill.disconnect(assoc_params.ssid) self.context.router.deconfig()
def run_once(self): """Test body.""" wpa_config = xmlrpc_security_types.WPAConfig( psk='chromeos', wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA, wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP]) ap_config0 = hostap_config.HostapConfig( ssid=self.TEST_SSID, frequency=2412, mode=hostap_config.HostapConfig.MODE_11G, scenario_name='open_network') client_config0 = xmlrpc_datatypes.AssociationParameters( ssid=self.TEST_SSID) ap_config1 = hostap_config.HostapConfig( ssid=self.TEST_SSID, frequency=2412, mode=hostap_config.HostapConfig.MODE_11G, security_config=wpa_config, scenario_name='wpa_network') client_config1 = xmlrpc_datatypes.AssociationParameters( ssid=self.TEST_SSID, security_config=wpa_config) self.context.configure(ap_config0) self.context.configure(ap_config1, multi_interface=True) self.context.assert_connect_wifi(client_config0) self.context.assert_ping_from_dut(ap_num=0) self.context.assert_connect_wifi(client_config1) self.context.assert_ping_from_dut(ap_num=1)
def run_once(self): """Asserts that WiFi bitrates remain low during the association process. Low bitrates mean that data transfer is slow, but reliable. This is important since association usually includes some very time dependent configuration state machines and no user expectation of high bandwidth. """ caps = [ hostap_config.HostapConfig.N_CAPABILITY_GREENFIELD, hostap_config.HostapConfig.N_CAPABILITY_HT40 ] g_config = hostap_config.HostapConfig( channel=6, mode=hostap_config.HostapConfig.MODE_11G) n_config = hostap_config.HostapConfig( channel=44, mode=hostap_config.HostapConfig.MODE_11N_PURE, n_capabilities=caps) for ap_config in (g_config, n_config): self.context.configure(ap_config) self.context.capture_host.start_capture( ap_config.frequency, ht_type=ap_config.ht_packet_capture_mode) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid()) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() results = self.context.capture_host.stop_capture() if len(results) != 1: raise error.TestError('Expected to generate one packet ' 'capture but got %d captures instead.' % len(results)) self.check_bitrates_in_capture(results[0]) self.context.client.shill.disconnect(assoc_params.ssid) self.context.router.deconfig()
def run_once(self): """Body of the test.""" self.context.client.require_capabilities( [site_linux_system.LinuxSystem.CAPABILITY_IBSS]) self.context.router.require_capabilities( [site_linux_system.LinuxSystem.CAPABILITY_IBSS]) # In the past, we have seen a bug where a previous association on a # channel where IBSS was disallowed would prohibit wpa_supplicant # from setting the interface to adhoc mode (since the kernel refuses # to allow adhoc mode on the previous channel). configuration = hostap_config.HostapConfig( channel=52, mode=hostap_config.HostapConfig.MODE_11A) self.context.configure(configuration) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid()) self.context.assert_connect_wifi(assoc_params) self.context.client.shill.disconnect(assoc_params.ssid) configuration = hostap_config.HostapConfig( frequency=2412, mode=hostap_config.HostapConfig.MODE_11B) self.context.configure(configuration, is_ibss=True) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid(), discovery_timeout=30, association_timeout=30, configuration_timeout=30, station_type=xmlrpc_datatypes.AssociationParameters. STATION_TYPE_IBSS) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() self.context.client.shill.disconnect(assoc_params.ssid) self.context.router.deconfig_aps()
def run_once(self): """Test body.""" freq = network_WiFi_ChannelHop.ORIGINAL_FREQUENCY ap_config = hostap_config.HostapConfig( ssid=network_WiFi_ChannelHop.TEST_SSID, frequency=freq, mode=hostap_config.HostapConfig.MODE_11B, bssid=network_WiFi_ChannelHop.ORIGINAL_BSSID) self.context.configure(ap_config) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid()) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() self.context.client.check_iw_link_value( iw_runner.IW_LINK_KEY_FREQUENCY, freq) self.context.router.deconfig() # This checks both channel jumping on the same BSSID and channel # jumping between BSSIDs, all inside the same SSID. for freq, bssid in ((2437, network_WiFi_ChannelHop.ORIGINAL_BSSID), (2462, network_WiFi_ChannelHop.ORIGINAL_BSSID), (2422, "06:07:08:09:0a:0b"), (2447, "0c:0d:0e:0f:10:11")): # Wait for the disconnect to happen. success, state, elapsed_seconds = \ self.context.client.wait_for_service_states( network_WiFi_ChannelHop.TEST_SSID, ['idle'], 30) # Change channels on the AP. This happens in full view of the DUT # and the AP deauths everyone as it exits. ap_config = hostap_config.HostapConfig( ssid=network_WiFi_ChannelHop.TEST_SSID, frequency=freq, mode=hostap_config.HostapConfig.MODE_11B, bssid=bssid) self.context.configure(ap_config) # Wait for the DUT to scan and acquire the AP at the new # frequency. success, state, elapsed_seconds = \ self.context.client.wait_for_service_states( network_WiFi_ChannelHop.TEST_SSID, ['ready', 'portal', 'online'], 30) if not success: raise error.TestFail( 'Failed to connect to "%s" in %f seconds (state=%s)' % (network_WiFi_ChannelHop.TEST_SSID, elapsed_seconds, state)) # Verify that we're connected. self.context.assert_ping_from_dut() # Verify that the client switched to new frequency self.context.client.check_iw_link_value( iw_runner.IW_LINK_KEY_FREQUENCY, freq) self.context.router.deconfig()
def run_once(self): """Body of the test.""" mode_n = hostap_config.HostapConfig.MODE_11N_PURE eap_config = xmlrpc_security_types.WPAEAPConfig( server_ca_cert=site_eap_certs.ca_cert_1, server_cert=site_eap_certs.server_cert_1, server_key=site_eap_certs.server_private_key_1, client_ca_cert=site_eap_certs.ca_cert_1, client_cert=site_eap_certs.client_cert_1, client_key=site_eap_certs.client_private_key_1, # PMKSA caching is only defined for WPA2. wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA2) ap_config0 = hostap_config.HostapConfig(mode=mode_n, frequency=self.AP0_FREQUENCY, security_config=eap_config) self.context.configure(ap_config0) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid(), security_config=eap_config) self.context.assert_connect_wifi(assoc_params) # Add another AP with identical configuration except in 5 Ghz. ap_config1 = hostap_config.HostapConfig( mode=mode_n, ssid=self.context.router.get_ssid(), frequency=self.AP1_FREQUENCY, security_config=eap_config) self.context.configure(ap_config1, multi_interface=True) bssid0 = self.context.router.get_hostapd_mac(0) bssid1 = self.context.router.get_hostapd_mac(1) utils.poll_for_condition( condition=lambda: self.dut_sees_bss(bssid1), exception=error.TestFail( 'Timed out waiting for DUT to see second AP'), timeout=self.TIMEOUT_SECONDS, sleep_interval=1) self.context.client.request_roam(bssid1) if not self.context.client.wait_for_roam( bssid1, timeout_seconds=self.TIMEOUT_SECONDS): raise error.TestFail('Failed to roam to second BSS.') self.context.router.deconfig_aps(instance=1, silent=True) if not self.context.client.wait_for_roam( bssid0, timeout_seconds=self.TIMEOUT_SECONDS): raise error.TestFail('Failed to fall back to first BSS.') pinger = ping_runner.PingRunner(host=self.context.client.host) utils.poll_for_condition(condition=lambda: pinger.simple_ping( self.context.router.get_wifi_ip(0)), exception=error.TestFail( 'Timed out waiting for DUT to be able to' 'ping first BSS after fallback'), timeout=self.TIMEOUT_SECONDS, sleep_interval=1) self.context.router.confirm_pmksa_cache_use(instance=0)
def run_once(self, disconnect_trigger, req_caps=None): """Sets up a router, connects to it, pings it and disables it to trigger disconnect.""" configuration = hostap_config.HostapConfig( channel=self.INITIAL_CHANNEL, mode=hostap_config.HostapConfig.MODE_11A, spectrum_mgmt_required=True) if req_caps is None: req_caps = [] self.context.router.require_capabilities(req_caps) self.context.configure(configuration) if site_linux_system.LinuxSystem.CAPABILITY_MULTI_AP in req_caps: # prep alternate Access Point alt_ap_config = hostap_config.HostapConfig( channel=self.ALT_CHANNEL, mode=hostap_config.HostapConfig.MODE_11N_MIXED) self.context.configure(alt_ap_config, multi_interface=True) alt_assoc_params = xmlrpc_datatypes.AssociationParameters() alt_assoc_params.ssid = self.context.router.get_ssid(instance=1) assoc_params = xmlrpc_datatypes.AssociationParameters() assoc_params.ssid = self.context.router.get_ssid(instance=0) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() with self.context.client.assert_disconnect_event(): if disconnect_trigger == 'AP gone': self.context.router.deconfig() elif disconnect_trigger == 'deauth client': self.context.router.deauth_client(self.context.client.wifi_mac) elif disconnect_trigger == 'AP send channel switch': for _ in range(self.CHANNEL_SWITCH_ATTEMPTS): self.context.router.send_management_frame_on_ap( 'channel_switch', self.ALT_CHANNEL) time.sleep(self.CHANNEL_SWITCH_WAIT_TIME_SEC) elif disconnect_trigger == 'switch AP': self.context.assert_connect_wifi(alt_assoc_params) elif disconnect_trigger == 'disable client wifi': self.context.client.set_device_enabled( self.context.client.wifi_if, False) else: raise error.TestError('unknown test mode: %s' % disconnect_trigger) time.sleep(wifi_client.DISCONNECT_WAIT_TIME_SECONDS) disconnect_reasons = self.context.client.get_disconnect_reasons() if disconnect_reasons is None or len(disconnect_reasons) == 0: raise error.TestFail('supplicant DisconnectReason not logged') for entry in disconnect_reasons: logging.info("DisconnectReason: %s", entry)
def run_once(self): """Test body.""" self._router0_conf = hostap_config.HostapConfig(channel=1) self._router1_conf = hostap_config.HostapConfig( channel=48, mode=hostap_config.HostapConfig.MODE_11A) self._client_conf = xmlrpc_datatypes.AssociationParameters() # Configure the initial AP. self.context.configure(self._router0_conf) router_ssid = self.context.router.get_ssid() # Connect to the initial AP. self._client_conf.ssid = router_ssid self.context.assert_connect_wifi(self._client_conf) # Setup a second AP with the same SSID. self._router1_conf.ssid = router_ssid self.context.configure(self._router1_conf, multi_interface=True) # Get BSSIDs of the two APs bssid0 = self.context.router.get_hostapd_mac(0) bssid1 = self.context.router.get_hostapd_mac(1) # Wait for DUT to see the second AP utils.poll_for_condition(condition=lambda: self.dut_sees_bss(bssid1), exception=error.TestFail( 'Timed out waiting for DUT' 'to see second AP'), timeout=self.TIMEOUT_SECONDS, sleep_interval=1) # Check which AP we are currently connected. # This is to include the case that wpa_supplicant # automatically roam to AP2 during the scan. interface = self.context.client.wifi_if curr_bssid = self.context.client.iw_runner.get_current_bssid(interface) if curr_bssid == bssid0: roam_to_bssid = bssid1 else: roam_to_bssid = bssid0 # Send BSS Transition Management Request to client if not self.context.router.send_bss_tm_req( self.context.client.wifi_mac, [roam_to_bssid]): raise error.TestNAError('AP does not support BSS Transition ' 'Management') # Expect that the DUT will re-connect to the new AP if not self.context.client.wait_for_roam( roam_to_bssid, timeout_seconds=self.TIMEOUT_SECONDS): raise error.TestFail('Failed to roam.')
def run_once(self): """Body of the test.""" self.reset_driver = self.get_reset_driver() client = self.context.client ap_config = hostap_config.HostapConfig(channel=1) ssid = self.configure_and_connect_to_ap(ap_config) self.context.assert_ping_from_dut() router = self.context.router ssid = router.get_ssid() boot_id = client.host.get_boot_id() logging.info("Running %d suspends", self._NUM_SUSPENDS) for _ in range(self._NUM_SUSPENDS): logging.info("Running %d resets", self._NUM_RESETS) for __ in range(self._NUM_RESETS): self.reset_driver.do_reset() client.wait_for_connection(ssid) self.context.assert_ping_from_dut() client.do_suspend(self._SUSPEND_DELAY) client.host.test_wait_for_resume(boot_id) client.wait_for_connection(ssid)
def run_once(self): """Test body.""" wpa_config = xmlrpc_security_types.WPAConfig( psk='chromeos', wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA, wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP, xmlrpc_security_types.WPAConfig.CIPHER_CCMP], wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP], use_strict_rekey=True, wpa_gtk_rekey_period=self.GTK_REKEY_PERIOD, wpa_gmk_rekey_period=self.GMK_REKEY_PERIOD) ap_config = hostap_config.HostapConfig( frequency=2412, mode=hostap_config.HostapConfig.MODE_11G, security_config=wpa_config) client_conf = xmlrpc_datatypes.AssociationParameters( security_config=wpa_config) self.context.configure(ap_config) client_conf.ssid = self.context.router.get_ssid() self.context.assert_connect_wifi(client_conf) # Sanity check ourselves with some unicast pings. self.context.assert_ping_from_dut() # Now check that network traffic goes through. if (not self.check_client_can_recv_broadcast_traffic() or not self.check_client_can_send_broadcast_traffic()): raise error.TestFail('Not all arping passes were successful.') self.context.client.shill.disconnect(client_conf.ssid) self.context.router.deconfig()
def run_once(self): """Test body.""" # Configure the AP. frequency = 2412 self.context.configure(hostap_config.HostapConfig(frequency=frequency)) router_ssid = self.context.router.get_ssid() # Connect to the AP. self.context.assert_connect_wifi( xmlrpc_datatypes.AssociationParameters(ssid=router_ssid)) # Disable the interface only long enough that we're sure we have # disconnected. interface = self.context.client.wifi_if client = self.context.client with InterfaceDisableContext(client, interface): success, state, elapsed_seconds = client.wait_for_service_states( router_ssid, ('idle', ), 3) # We should either be in the 'idle' state or not even know about # this service state anymore. The latter is more likely since # the AP's service should lose visibility when the device is # disabled. if not success and state != 'unknown': raise error.TestFail( 'Failed to disconnect from "%s" after interface was ' 'disabled for %f seconds (state=%s)' % (router_ssid, elapsed_seconds, state)) # Expect that the DUT will re-connect to the AP. self.context.wait_for_connection(router_ssid, frequency) self.context.router.deconfig()
def test_connect(wifi_context, frequency, expect_connect, hide_ssid): """Verifies that a DUT does/does not connect on a particular frequency. @param wifi_context: A WiFiTestContextManager. @param frequency: int frequency to test. @param expect_connect: bool whether or not connection should succeed. @param hide_ssid: bool whether or not the AP should hide its SSID. @raise error.TestFail if behavior does not match expectation. """ try: router_ssid = None if hide_ssid: pcap_name = '%d_connect_hidden.pcap' % frequency test_description = 'hidden' else: pcap_name = '%d_connect_visible.pcap' % frequency test_description = 'visible' wifi_context.capture_host.start_capture(frequency, filename=pcap_name) wifi_context.router.hostap_configure( hostap_config.HostapConfig( frequency=frequency, hide_ssid=hide_ssid, mode=hostap_config.HostapConfig.MODE_11N_MIXED)) router_ssid = wifi_context.router.get_ssid() client_conf = xmlrpc_datatypes.AssociationParameters( ssid=router_ssid, is_hidden=hide_ssid, expect_failure=not expect_connect) wifi_context.assert_connect_wifi(client_conf, test_description) finally: if router_ssid: wifi_context.client.shill.delete_entries_for_ssid(router_ssid) wifi_context.capture_host.stop_capture()
def run_once(self): """Test body. Powersave mode takes advantage of DTIM intervals, and so the two are intimately tied. See network_WiFi_DTIMPeriod for a discussion of their interaction. """ dtim_val = 5 configuration = hostap_config.HostapConfig( frequency=2437, mode=hostap_config.HostapConfig.MODE_11G, dtim_period=dtim_val) self.context.configure(configuration) self.check_powersave(False) assoc_params = xmlrpc_datatypes.AssociationParameters() assoc_params.ssid = self.context.router.get_ssid() self.context.client.powersave_switch(True) self.check_powersave(True) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() self.context.assert_ping_from_server() self.context.client.shill.disconnect(assoc_params.ssid) self.context.client.powersave_switch(False) self.check_powersave(False) self.context.router.deconfig()
def run_once(self): """Test body.""" wpa_config = xmlrpc_security_types.WPAConfig( psk='chromeos', wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA, wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP, xmlrpc_security_types.WPAConfig.CIPHER_CCMP], wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP], wpa_ptk_rekey_period=self.REKEY_PERIOD) ap_config = hostap_config.HostapConfig( frequency=2412, mode=hostap_config.HostapConfig.MODE_11N_PURE, security_config=wpa_config) # TODO(wiley) This is just until we find the source of these # test failures. self.context.router.start_capture(ap_config.frequency) self.context.configure(ap_config) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid(), security_config=wpa_config) self.context.assert_connect_wifi(assoc_params) ping_config = ping_runner.PingConfig(self.context.get_wifi_addr(), count=self.PING_COUNT, interval=self.PING_INTERVAL) logging.info('Pinging DUT for %d seconds and rekeying ' 'every %d seconds.', self.PING_COUNT * self.PING_INTERVAL, self.REKEY_PERIOD) self.context.assert_ping_from_dut(ping_config=ping_config) self.context.client.shill.disconnect(assoc_params.ssid) self.context.router.deconfig()
def configure_connect_verify_deconfig_wait(self, ssid, freq, mode, bssid): """Configure an AP, connect to it, then tear it all down, again. This method does the following: configures the AP, connects to it and verifies the connection, deconfigures the AP and waits for the disconnect to complete. @param ssid string SSID for the new connection. @param freq int Frequency which the AP is to support. @param mode string AP mode from hostap_config.HostapConfig.MODE_*. @param bssid string BSSID for the new connection. """ # Change channels on the AP. This happens in full view of the DUT # and the AP deauths everyone as it exits. ap_config = hostap_config.HostapConfig(ssid=ssid, frequency=freq, mode=mode, bssid=bssid) self.context.configure(ap_config) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid()) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() # Verify that we're connected. self.context.client.check_iw_link_value( iw_runner.IW_LINK_KEY_FREQUENCY, freq) # Verify that the client switched to new frequency # Deconfig and wait for the DUT to disconnect and end up at 'idle'. self.context.router.deconfig() success, state, elapsed_seconds = \ self.context.client.wait_for_service_states( network_WiFi_SSIDSwitchBack.SSID_1, ['idle'], 30)
def run_once(self): """Body of the test.""" self.configure_and_connect_to_ap(hostap_config.HostapConfig(channel=1)) client = self.context.client router = self.context.router # Enable the dark connect feature in shill. with client.wake_on_wifi_features(wifi_client.WAKE_ON_WIFI_DARKCONNECT): logging.info('Set up WoWLAN') with self.dr_utils.suspend(): time.sleep(wifi_client.SUSPEND_WAIT_TIME_SECONDS) # Kick over the router to trigger wake on disconnect. router.deconfig_aps(silent=True) # Wait for the DUT to wake up in dark resume and suspend again. time.sleep(wifi_client.DARK_RESUME_WAIT_TIME_SECONDS) # Ensure that wake on packet did not trigger a full wake. if client.host.wait_up( timeout=wifi_client.WAIT_UP_TIMEOUT_SECONDS): raise error.TestFail('Client woke up fully.') if self.dr_utils.count_dark_resumes() < 1: raise error.TestFail('Client failed to wake up.') logging.info('Client woke up successfully.')
def run_once(self): """DTIM period test. DTIM stands for delivery traffic information message and refers to the number of beacons between DTIMS. For instance, a DTIM period of 1 would indicate that every beacon should have a DTIM element. The default DTIM period value is 2. This flag is used in combination with powersave mode as follows: 1) A client goes into powersave mode and notifies the router. 2) While in powersave mode, the client turns off as much as possible; the AP is supposed to buffer unicast traffic. 3) The client wakes up to receive beacons, which may include a DTIM notification. 4) On receiving such a notification, the client should stay up to recieve the pending frames. """ dtim_val = 5 configuration = hostap_config.HostapConfig( frequency=2437, mode=hostap_config.HostapConfig.MODE_11G, dtim_period=dtim_val) self.context.configure(configuration) assoc_params = xmlrpc_datatypes.AssociationParameters() assoc_params.ssid = self.context.router.get_ssid() self.context.client.powersave_switch(True) self.context.assert_connect_wifi(assoc_params) self.context.client.check_iw_link_value( iw_runner.IW_LINK_KEY_DTIM_PERIOD, dtim_val) self.context.assert_ping_from_dut() self.context.client.shill.disconnect(assoc_params.ssid) self.context.client.powersave_switch(False) self.context.router.deconfig()
def run_once(self): """Body of the test.""" if not self.mwifiex_reset_exists(): self._supports_reset = False raise error.TestNAError('DUT does not support device reset') else: self._supports_reset = True client = self.context.client ap_config = hostap_config.HostapConfig(channel=1) ssid = self.configure_and_connect_to_ap(ap_config) self.context.assert_ping_from_dut() router = self.context.router ssid = router.get_ssid() boot_id = client.host.get_boot_id() logging.info("Running %d suspends", self._NUM_SUSPENDS) for i in range(self._NUM_SUSPENDS): logging.info("Running %d resets", self._NUM_RESETS) for j in range(self._NUM_RESETS): if not self.mwifiex_reset(client): raise error.TestFail('Failed to reset device %s' % client.wifi_if) client.wait_for_connection(ssid) self.context.assert_ping_from_dut() client.do_suspend(self._SUSPEND_DELAY) client.host.test_wait_for_resume(boot_id) client.wait_for_connection(ssid)
def run_once(self): """Test body. When fragthreshold is set, packets larger than the threshold are broken up by the AP and sent in fragments. The DUT needs to reassemble these fragments to reconstruct the original packets before processing them. """ # Whirlwind routers don't support fragmentation, and older builds # (up to 7849.0.2016_01_20_2103) don't know that they don't, so check # here using board name. if self.context.router.board == "whirlwind": raise error.TestNAError( 'Whirlwind AP does not support frag threshold') configuration = hostap_config.HostapConfig( frequency=2437, mode=hostap_config.HostapConfig.MODE_11G, frag_threshold=256) self.context.configure(configuration) self.context.capture_host.start_capture(configuration.frequency) assoc_params = xmlrpc_datatypes.AssociationParameters() assoc_params.ssid = self.context.router.get_ssid() self.context.assert_connect_wifi(assoc_params) build_config = lambda size: ping_runner.PingConfig( self.context.client.wifi_ip, size=size) self.context.assert_ping_from_server(ping_config=build_config(256)) self.context.assert_ping_from_server(ping_config=build_config(512)) self.context.assert_ping_from_server(ping_config=build_config(1024)) self.context.assert_ping_from_server(ping_config=build_config(1500)) self.context.client.shill.disconnect(assoc_params.ssid) self.context.router.deconfig() self.context.capture_host.stop_capture()
def run_once(self): """Test body. Set up two APs on the same channel/bssid but with different SSIDs. Check that we can see both APs in scan results. """ freqs = [2412, 5180] configurations = [hostap_config.HostapConfig( frequency=freq, mode=hostap_config.HostapConfig.MODE_11N_MIXED, bssid=('00:11:22:33:44:55'), ssid=('CrOS_Masked%d' % i)) \ for i, freq in enumerate(freqs)] # Create an AP, manually specifying both the SSID and BSSID. self.context.configure(configurations[0]) # Create a second AP that responds to probe requests with the same BSSID # but an different SSID. These APs together are meant to emulate # situations that occur with some types of APs which broadcast or # respond with more than one (non-empty) SSID. self.context.configure(configurations[1], multi_interface=True) # We cannot connect to this AP, since there are two separate APs that # respond to the same BSSID, but we can test to make sure both SSIDs # appears in the scan. self.context.client.scan(freqs, [config.ssid for config in configurations]) self.context.router.deconfig()
def run_once(self): """Test body.""" ap_config = hostap_config.HostapConfig(channel=1) # Set up the router and associate the client with it. self.context.configure(ap_config) self.context.router.start_capture( ap_config.frequency, ht_type=ap_config.ht_packet_capture_mode, snaplen=packet_capturer.SNAPLEN_WIFI_PROBE_REQUEST) assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=self.context.router.get_ssid()) self.context.assert_connect_wifi(assoc_params) results = self.context.router.stop_capture() if len(results) != 1: raise error.TestError('Expected to generate one packet ' 'capture but got %d instead.' % len(results)) probe_ssids = tcpdump_analyzer.get_probe_ssids( results[0].local_pcap_path, probe_sender=self.context.client.wifi_mac) expected_ssids = frozenset([self.BROADCAST_SSID]) permitted_ssids = (expected_ssids | frozenset([self.context.router.get_ssid()])) # Verify expected ssids are contained in the probe result if expected_ssids - probe_ssids: raise error.TestError('Expected SSIDs %s, but got %s' % (expected_ssids, probe_ssids)) # Verify probe result does not contain any unpermitted ssids if probe_ssids - permitted_ssids: raise error.TestError('Permitted SSIDs %s, but got %s' % (permitted_ssids, probe_ssids))
def run_once(self): """Test body. When fragthreshold is set, packets larger than the threshold are broken up by the AP and sent in fragments. The DUT needs to reassemble these fragments to reconstruct the original packets before processing them. """ configuration = hostap_config.HostapConfig( frequency=2437, mode=hostap_config.HostapConfig.MODE_11G, frag_threshold=256) self.context.configure(configuration) self.context.router.start_capture(configuration.frequency) assoc_params = xmlrpc_datatypes.AssociationParameters() assoc_params.ssid = self.context.router.get_ssid() self.context.assert_connect_wifi(assoc_params) build_config = lambda size: ping_runner.PingConfig( self.context.client.wifi_ip, size=size) self.context.assert_ping_from_server(ping_config=build_config(256)) self.context.assert_ping_from_server(ping_config=build_config(512)) self.context.assert_ping_from_server(ping_config=build_config(1024)) self.context.assert_ping_from_server(ping_config=build_config(1500)) self.context.client.shill.disconnect(assoc_params.ssid) self.context.router.deconfig()
def get_positive_8021x_test_cases(outer_auth_type, inner_auth_type): """Return a test case asserting that outer/inner auth works. @param inner_auth_type one of xmlrpc_security_types.Tunneled1xConfig.LAYER1_TYPE* @param inner_auth_type one of xmlrpc_security_types.Tunneled1xConfig.LAYER2_TYPE* @return list of ap_config, association_params tuples for network_WiFi_SimpleConnect. """ eap_config = xmlrpc_security_types.Tunneled1xConfig( site_eap_certs.ca_cert_1, site_eap_certs.server_cert_1, site_eap_certs.server_private_key_1, site_eap_certs.ca_cert_1, 'testuser', 'password', inner_protocol=inner_auth_type, outer_protocol=outer_auth_type) ap_config = hostap_config.HostapConfig( frequency=2412, mode=hostap_config.HostapConfig.MODE_11G, security_config=eap_config) assoc_params = xmlrpc_datatypes.AssociationParameters( security_config=eap_config) return [(ap_config, assoc_params)]
def run_once(self): """Test body.""" ap_config = hostap_config.HostapConfig(channel=1, hide_ssid=True) # Set up the router and associate the client with it. self.context.configure(ap_config) self.context.capture_host.start_capture( ap_config.frequency, ht_type=ap_config.ht_packet_capture_mode, snaplen=packet_capturer.SNAPLEN_WIFI_PROBE_REQUEST) test_ssid = self.context.router.get_ssid() assoc_params = xmlrpc_datatypes.AssociationParameters(ssid=test_ssid, is_hidden=True) self.context.assert_connect_wifi(assoc_params) results = self.context.capture_host.stop_capture() if len(results) != 1: raise error.TestError('Expected to generate one packet ' 'capture but got %d instead.' % len(results)) probe_ssids = tcpdump_analyzer.get_probe_ssids( results[0].local_pcap_path, probe_sender=self.context.client.wifi_mac) if len(probe_ssids) != 2: raise error.TestError('Expected exactly two SSIDs, but got %s' % probe_ssids) if probe_ssids - {self.BROADCAST_SSID, test_ssid}: raise error.TestError('Unexpected probe SSIDs: %s' % probe_ssids)
def run_once(self): """Test body. Set up two APs on the same channel/bssid but with different SSIDs. Check that we can see both APs in scan results. """ self.context.router.require_capabilities( [site_linux_system.LinuxSystem.CAPABILITY_MULTI_AP_SAME_BAND]) frequency = 2412 configurations = [hostap_config.HostapConfig( frequency=frequency, mode=hostap_config.HostapConfig.MODE_11B, bssid='00:11:22:33:44:55', ssid=('CrOS_Masked%d' % i), min_streams=1) for i in range(2)] # Create an AP, manually specifying both the SSID and BSSID. self.context.configure(configurations[0]) # Create a second AP that responds to probe requests with the same BSSID # but an different SSID. These APs together are meant to emulate # situations that occur with some types of APs which broadcast or # respond with more than one (non-empty) SSID. self.context.configure(configurations[1], multi_interface=True) # We cannot connect to this AP, since there are two separate APs that # respond to the same BSSID, but we can test to make sure both SSIDs # appears in the scan. self.context.client.scan([frequency], [config.ssid for config in configurations]) self.context.router.deconfig()
def run_once(self): """Body of the test.""" ap_config = hostap_config.HostapConfig(channel=1) self.context.configure(ap_config) ssid = self.context.router.get_ssid() client_config = xmlrpc_datatypes.AssociationParameters(ssid=ssid) self.context.assert_connect_wifi(client_config) self.context.assert_ping_from_dut() # Take down the AP interface, which looks like the AP "disappeared" # from the DUT's point of view. This is also much faster than actually # tearing down the AP, which allows us to watch for the client reporting # itself as disconnected. self.context.router.set_ap_interface_down() self._assert_disconnect(ssid) self.context.router.deconfig_aps() logging.info('Repeating test with a client scan just before AP death.') self.context.configure(ap_config) ssid = self.context.router.get_ssid() client_config = xmlrpc_datatypes.AssociationParameters(ssid=ssid) self.context.assert_connect_wifi(client_config) self.context.assert_ping_from_dut() self.context.client.scan(frequencies=[], ssids=[]) self.context.router.set_ap_interface_down() self._assert_disconnect(ssid) self.context.router.deconfig_aps()
def run_once(self): """ Test that optional DHCP properties are used in DHCP Request packets. The test will temporarily set the DHCPProperty.VendorClass and DHCPProperty.Hostname DBus properties for the Manager. The test resets the properties to their original values before completion. During the test, the DUT should send packets with the optional DHCP property settings in DHCP Requests. If they are not in the packet, the test will fail. """ configuration = hostap_config.HostapConfig(frequency=self.FREQUENCY_MHZ) self.context.configure(configuration) # set hostname and vendorclass for this test client = self.context.client with client.set_dhcp_property(self.HOSTNAME_PROPERTY, self.HOSTNAME_VALUE): with client.set_dhcp_property(self.VENDORCLASS_PROPERTY, self.VENDORCLASS_VALUE): self.context.capture_host.start_capture( configuration.frequency, ht_type=configuration.ht_packet_capture_mode) assoc_params = xmlrpc_datatypes.AssociationParameters() assoc_params.ssid = self.context.router.get_ssid(instance=0) self.context.assert_connect_wifi(assoc_params) self.context.assert_ping_from_dut() results = self.context.capture_host.stop_capture() if len(results) != 1: raise error.TestError('Expected to generate one packet ' 'capture but got %d captures instead.' % len(results)) self.assert_hostname_and_vendorclass_are_present(results[0])
def run_once(self): """Test body.""" self.context.configure( hostap_config.HostapConfig(channel=1, hide_ssid=True)) router_ssid = self.context.router.get_ssid() assoc_params = xmlrpc_datatypes.AssociationParameters( ssid=router_ssid, is_hidden=True) self.context.assert_connect_wifi(assoc_params) self.context.router.deconfig() self.context.client.wait_for_ssid_vanish(router_ssid) # Don't let any of shill's short term actions affect our test. time.sleep(20) self.context.configure(hostap_config.HostapConfig( channel=11, ssid=router_ssid, hide_ssid=True)) # But shill should continue to probe around for the network. self.context.wait_for_connection(router_ssid)