• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 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
5import logging
6
7from autotest_lib.client.common_lib.cros.network import ping_runner
8from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
9from autotest_lib.client.common_lib.cros.network  import xmlrpc_security_types
10from autotest_lib.server.cros.network import hostap_config
11from autotest_lib.server.cros.network import wifi_cell_test_base
12
13
14class network_WiFi_PTK(wifi_cell_test_base.WiFiCellTestBase):
15    """Test that pairwise temporal key rotations work as expected."""
16    version = 1
17
18    # These settings combine to give us around 30 seconds of ping time,
19    # which should be around 6 rekeys.
20    PING_COUNT = 150
21    PING_INTERVAL = 0.2
22    REKEY_PERIOD = 5
23
24
25    def run_once(self):
26        """Test body."""
27        wpa_config = xmlrpc_security_types.WPAConfig(
28                psk='chromeos',
29                wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA,
30                wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP,
31                             xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
32                wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
33                wpa_ptk_rekey_period=self.REKEY_PERIOD)
34        ap_config = hostap_config.HostapConfig(
35                    frequency=2412,
36                    mode=hostap_config.HostapConfig.MODE_11N_PURE,
37                    security_config=wpa_config)
38        # TODO(wiley) This is just until we find the source of these
39        #             test failures.
40        self.context.router.start_capture(ap_config.frequency)
41        self.context.configure(ap_config)
42        assoc_params = xmlrpc_datatypes.AssociationParameters(
43                ssid=self.context.router.get_ssid(),
44                security_config=wpa_config)
45        self.context.assert_connect_wifi(assoc_params)
46        ping_config = ping_runner.PingConfig(self.context.get_wifi_addr(),
47                                             count=self.PING_COUNT,
48                                             interval=self.PING_INTERVAL)
49        logging.info('Pinging DUT for %d seconds and rekeying '
50                     'every %d seconds.',
51                     self.PING_COUNT * self.PING_INTERVAL,
52                     self.REKEY_PERIOD)
53        self.context.assert_ping_from_dut(ping_config=ping_config)
54        self.context.client.shill.disconnect(assoc_params.ssid)
55        self.context.router.deconfig()
56