1#
2#   Copyright 2021 - The Android Open Source Project
3#
4#   Licensed under the Apache License, Version 2.0 (the "License");
5#   you may not use this file except in compliance with the License.
6#   You may obtain a copy of the License at
7#
8#   http://www.apache.org/licenses/LICENSE-2.0
9#
10#   Unless required by applicable law or agreed to in writing, software
11#   distributed under the License is distributed on an "AS IS" BASIS,
12#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13#   See the License for the specific language governing permissions and
14#   limitations under the License.
15
16from acts_contrib.test_utils.wifi import wifi_test_utils as wutils
17from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
18from WifiEnterpriseTest import WifiEnterpriseTest
19
20WifiEnums = wutils.WifiEnums
21# EAP Macros
22EAP = WifiEnums.Eap
23EapPhase2 = WifiEnums.EapPhase2
24Ent = WifiEnums.Enterprise
25
26
27class WifiEnterprise11axTest(WifiEnterpriseTest):
28  """Tests for WPA2 Enterprise 11ax.
29
30  Test Bed Requirement:
31    One Android device, 1 Asus AXE11000 Access Point and Radius server
32  """
33
34  def __init__(self, configs):
35    super().__init__(configs)
36    self.tests = (
37        "test_eap_connect_with_config_tls",
38        "test_eap_connect_with_config_sim",
39        "test_eap_connect_with_config_aka",
40        "test_eap_connect_with_config_aka_prime",
41        "test_eap_connect_with_config_ttls_none",
42        "test_eap_connect_with_config_ttls_pap",
43        "test_eap_connect_with_config_ttls_mschap",
44        "test_eap_connect_with_config_ttls_mschapv2",
45        "test_eap_connect_with_config_ttls_gtc",
46        "test_eap_connect_with_config_peap0_mschapv2",
47        "test_eap_connect_with_config_peap0_gtc",
48        "test_eap_connect_with_config_peap1_mschapv2",
49        "test_eap_connect_with_config_peap1_gtc",
50        "test_eap_connect_config_store_with_config_tls",
51        "test_eap_connect_config_store_with_config_sim",
52        "test_eap_connect_config_store_with_config_aka",
53        "test_eap_connect_config_store_with_config_aka_prime",
54        "test_eap_connect_config_store_with_config_ttls_none",
55        "test_eap_connect_config_store_with_config_ttls_pap",
56        "test_eap_connect_config_store_with_config_ttls_mschap",
57        "test_eap_connect_config_store_with_config_ttls_mschapv2",
58        "test_eap_connect_config_store_with_config_ttls_gtc",
59        "test_eap_connect_config_store_with_config_peap0_mschapv2",
60        "test_eap_connect_config_store_with_config_peap0_gtc",
61        "test_eap_connect_config_store_with_config_peap1_mschapv2",
62        "test_eap_connect_config_store_with_config_peap1_gtc",
63    )
64
65  def setup_class(self):
66    WifiBaseTest.setup_class(self)
67    self.dut = self.android_devices[0]
68    required_userparam_names = [
69        "ca_cert", "client_cert", "client_key", "eap_identity", "eap_password",
70        "device_password", "radius_conf_2g", "radius_conf_5g", "wifi6_models"
71    ]
72    self.unpack_userparams(required_userparam_names, ocsp=0)
73    self.ap = self.access_points[0]
74    self.ap.configure_ap({
75        "2g": {
76            "security": "wpa2",
77            "radius_server_ip": self.radius_conf_2g["radius_server_ip"],
78            "radius_server_port": self.radius_conf_2g["radius_server_port"],
79            "radius_server_secret": self.radius_conf_2g["radius_server_secret"],
80        },
81        "5g": {
82            "security": "wpa2",
83            "radius_server_ip": self.radius_conf_5g["radius_server_ip"],
84            "radius_server_port": self.radius_conf_5g["radius_server_port"],
85            "radius_server_secret": self.radius_conf_5g["radius_server_secret"],
86        }
87    })
88    self.ent_network_2g = self.ap.get_wifi_network("2g")
89    self.ent_network_5g = self.ap.get_wifi_network("5g")
90
91    # Default configs for EAP networks.
92    self.config_peap0 = {
93        Ent.EAP: int(EAP.PEAP),
94        Ent.CA_CERT: self.ca_cert,
95        Ent.IDENTITY: self.eap_identity,
96        Ent.PASSWORD: self.eap_password,
97        Ent.PHASE2: int(EapPhase2.MSCHAPV2),
98        WifiEnums.SSID_KEY: self.ent_network_5g[WifiEnums.SSID_KEY],
99        Ent.OCSP: self.ocsp,
100    }
101    self.config_peap1 = dict(self.config_peap0)
102    self.config_peap1[WifiEnums.SSID_KEY] = self.ent_network_2g[
103        WifiEnums.SSID_KEY]
104    self.config_tls = {
105        Ent.EAP: int(EAP.TLS),
106        Ent.CA_CERT: self.ca_cert,
107        WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
108        Ent.CLIENT_CERT: self.client_cert,
109        Ent.PRIVATE_KEY_ID: self.client_key,
110        Ent.IDENTITY: self.eap_identity,
111        Ent.OCSP: self.ocsp,
112    }
113    self.config_ttls = {
114        Ent.EAP: int(EAP.TTLS),
115        Ent.CA_CERT: self.ca_cert,
116        Ent.IDENTITY: self.eap_identity,
117        Ent.PASSWORD: self.eap_password,
118        Ent.PHASE2: int(EapPhase2.MSCHAPV2),
119        WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
120        Ent.OCSP: self.ocsp,
121    }
122    self.config_sim = {
123        Ent.EAP: int(EAP.SIM),
124        WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
125    }
126    self.config_aka = {
127        Ent.EAP: int(EAP.AKA),
128        WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
129    }
130    self.config_aka_prime = {
131        Ent.EAP: int(EAP.AKA_PRIME),
132        WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
133    }
134
135    # Set screen lock password so ConfigStore is unlocked.
136    self.dut.droid.setDevicePassword(self.device_password)
137