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
5AUTHOR = 'wiley, pstew, quiche'
6NAME = 'network_WiFi_SimpleConnect.wifi_checkHiddenWPA'
7TIME = 'SHORT'
8TEST_TYPE = 'Server'
9ATTRIBUTES = ('suite:wifi_correctness_cros_core, suite:wifi_matfunc, '
10              'suite:wifi_matfunc_bcm4371, suite:wifi_release, subsystem:wifi,'
11              'suite:android_wifi_connect')
12DEPENDENCIES = 'wificell'
13
14DOC = """
15This test verifies that we can connect to hidden WPA networks.  It checks
16several common configurations of hidden networks such as pure WPA/WPA2 and
17mixed WPA/WPA2 networks.
18"""
19
20from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
21from autotest_lib.client.common_lib.cros.network import xmlrpc_security_types
22from autotest_lib.server.cros.network import hostap_config
23
24
25def get_configurations():
26    wpa_configs = [
27            xmlrpc_security_types.WPAConfig(
28                    psk='chromeos',
29                    wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA,
30                    wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP]),
31            xmlrpc_security_types.WPAConfig(
32                    psk='chromeos',
33                    wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA,
34                    wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP,
35                                 xmlrpc_security_types.WPAConfig.CIPHER_CCMP]),
36            xmlrpc_security_types.WPAConfig(
37                    psk='chromeos',
38                    wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA2,
39                    wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP]),
40            xmlrpc_security_types.WPAConfig(
41                    psk='chromeos',
42                    wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA,
43                    wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP,
44                                 xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
45                    wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP]),
46    ]
47    for wpa_config in wpa_configs:
48        ap_config = hostap_config.HostapConfig(
49                hide_ssid=True,
50                frequency=2412,
51                mode=hostap_config.HostapConfig.MODE_11G,
52                security_config=wpa_config)
53        assoc_params = xmlrpc_datatypes.AssociationParameters(
54                is_hidden=True,
55                security_config=wpa_config)
56        configurations = [(ap_config, assoc_params)]
57    return configurations
58
59
60def run(machine):
61    host = hosts.create_host(machine)
62    job.run_test('network_WiFi_SimpleConnect',
63                 tag=NAME.split('.')[1],
64                 host=host,
65                 raw_cmdline_args=args,
66                 additional_params=get_configurations())
67
68
69parallel_simple(run, machines)
70