Home | History | Annotate | Download | only in network_WiFi_HiddenScan
      1 # Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 from autotest_lib.client.common_lib import error
      6 from autotest_lib.client.common_lib.cros.network import tcpdump_analyzer
      7 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
      8 from autotest_lib.server.cros.network import hostap_config
      9 from autotest_lib.server.cros.network import packet_capturer
     10 from autotest_lib.server.cros.network import wifi_cell_test_base
     11 
     12 
     13 class network_WiFi_HiddenScan(wifi_cell_test_base.WiFiCellTestBase):
     14     """Test scanning behavior when a hidden SSID is configured."""
     15 
     16     version = 1
     17 
     18     BROADCAST_SSID = ''
     19 
     20     def run_once(self):
     21         """Test body."""
     22         ap_config = hostap_config.HostapConfig(channel=1, hide_ssid=True)
     23 
     24         # Start capture before starting anything else.
     25         self.context.capture_host.start_capture(
     26                 ap_config.frequency,
     27                 ht_type=ap_config.ht_packet_capture_mode,
     28                 snaplen=packet_capturer.SNAPLEN_WIFI_PROBE_REQUEST)
     29 
     30         # We're looking for the MAC address, so disable randomization.
     31         with self.context.client.mac_address_randomization(False):
     32             # Set up the router and associate the client with it.
     33             self.context.configure(ap_config)
     34             test_ssid = self.context.router.get_ssid()
     35             assoc_params = xmlrpc_datatypes.AssociationParameters(
     36                     ssid=test_ssid, is_hidden=True)
     37 
     38             self.context.assert_connect_wifi(assoc_params)
     39             results = self.context.capture_host.stop_capture()
     40 
     41         if len(results) != 1:
     42             raise error.TestError('Expected to generate one packet '
     43                                   'capture but got %d instead.' %
     44                                   len(results))
     45         probe_ssids = tcpdump_analyzer.get_probe_ssids(
     46                 results[0].local_pcap_path,
     47                 probe_sender=self.context.client.wifi_mac)
     48         if len(probe_ssids) != 2:
     49             raise error.TestError('Expected exactly two SSIDs, but got %s' %
     50                                   probe_ssids)
     51         if probe_ssids - {self.BROADCAST_SSID, test_ssid}:
     52             raise error.TestError('Unexpected probe SSIDs: %s' % probe_ssids)
     53