tturney | 1bdf77d | 2015-12-28 17:46:13 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 2 | # |
tturney | 1bdf77d | 2015-12-28 17:46:13 -0800 | [diff] [blame] | 3 | # Copyright 2016 - The Android Open Source Project |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import pprint |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 18 | import random |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 19 | import time |
| 20 | |
Ang Li | c2d4521 | 2016-03-10 18:38:53 -0800 | [diff] [blame] | 21 | from acts import asserts |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 22 | from acts import base_test |
| 23 | from acts import signals |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 24 | from acts.test_decorators import test_tracker_info |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 25 | from acts.test_utils.wifi import wifi_test_utils as wutils |
Ang Li | c2d4521 | 2016-03-10 18:38:53 -0800 | [diff] [blame] | 26 | |
Ang Li | e8ed2b3 | 2015-12-11 12:30:20 -0800 | [diff] [blame] | 27 | WifiEnums = wutils.WifiEnums |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 28 | |
| 29 | # EAP Macros |
| 30 | EAP = WifiEnums.Eap |
| 31 | EapPhase2 = WifiEnums.EapPhase2 |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 32 | # Enterprise Config Macros |
| 33 | Ent = WifiEnums.Enterprise |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 34 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 35 | |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 36 | class WifiEnterpriseTest(base_test.BaseTestClass): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 37 | def __init__(self, controllers): |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 38 | base_test.BaseTestClass.__init__(self, controllers) |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 39 | self.tests = ("test_eap_connect", "test_eap_connect_negative", |
| 40 | "test_eap_connect_config_store", ) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 41 | |
| 42 | def setup_class(self): |
| 43 | self.dut = self.android_devices[0] |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 44 | wutils.wifi_test_device_init(self.dut) |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 45 | # If running in a setup with attenuators, set attenuation on all |
| 46 | # channels to zero. |
| 47 | if getattr(self, "attenuators", []): |
| 48 | for a in self.attenuators: |
| 49 | a.set_atten(0) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 50 | required_userparam_names = ( |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 51 | "ca_cert", "client_cert", "client_key", "passpoint_ca_cert", |
| 52 | "passpoint_client_cert", "passpoint_client_key", "eap_identity", |
| 53 | "eap_password", "invalid_ca_cert", "invalid_client_cert", |
| 54 | "invalid_client_key", "fqdn", "provider_friendly_name", "realm", |
| 55 | "ssid_peap0", "ssid_peap1", "ssid_tls", "ssid_ttls", "ssid_pwd", |
| 56 | "ssid_sim", "ssid_aka", "ssid_aka_prime", "ssid_passpoint", |
| 57 | "device_password", "ping_addr") |
Ang Li | 5cd6d3c | 2016-02-01 11:29:14 -0800 | [diff] [blame] | 58 | self.unpack_userparams(required_userparam_names, |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 59 | roaming_consortium_ids=None, |
| 60 | plmn=None) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 61 | # Default configs for EAP networks. |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 62 | self.config_peap0 = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 63 | Ent.EAP: int(EAP.PEAP), |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 64 | Ent.CA_CERT: self.ca_cert, |
| 65 | Ent.IDENTITY: self.eap_identity, |
| 66 | Ent.PASSWORD: self.eap_password, |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 67 | Ent.PHASE2: int(EapPhase2.MSCHAPV2), |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 68 | WifiEnums.SSID_KEY: self.ssid_peap0 |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 69 | } |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 70 | self.config_peap1 = dict(self.config_peap0) |
| 71 | self.config_peap1[WifiEnums.SSID_KEY] = self.ssid_peap1 |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 72 | self.config_tls = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 73 | Ent.EAP: int(EAP.TLS), |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 74 | Ent.CA_CERT: self.ca_cert, |
| 75 | WifiEnums.SSID_KEY: self.ssid_tls, |
| 76 | Ent.CLIENT_CERT: self.client_cert, |
| 77 | Ent.PRIVATE_KEY_ID: self.client_key, |
| 78 | Ent.IDENTITY: self.eap_identity, |
| 79 | } |
| 80 | self.config_ttls = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 81 | Ent.EAP: int(EAP.TTLS), |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 82 | Ent.CA_CERT: self.ca_cert, |
| 83 | Ent.IDENTITY: self.eap_identity, |
| 84 | Ent.PASSWORD: self.eap_password, |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 85 | Ent.PHASE2: int(EapPhase2.MSCHAPV2), |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 86 | WifiEnums.SSID_KEY: self.ssid_ttls |
| 87 | } |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 88 | self.config_pwd = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 89 | Ent.EAP: int(EAP.PWD), |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 90 | Ent.IDENTITY: self.eap_identity, |
| 91 | Ent.PASSWORD: self.eap_password, |
| 92 | WifiEnums.SSID_KEY: self.ssid_pwd |
| 93 | } |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 94 | self.config_sim = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 95 | Ent.EAP: int(EAP.SIM), |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 96 | WifiEnums.SSID_KEY: self.ssid_sim, |
| 97 | } |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 98 | self.config_aka = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 99 | Ent.EAP: int(EAP.AKA), |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 100 | WifiEnums.SSID_KEY: self.ssid_aka, |
| 101 | } |
| 102 | self.config_aka_prime = { |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 103 | Ent.EAP: int(EAP.AKA_PRIME), |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 104 | WifiEnums.SSID_KEY: self.ssid_aka_prime, |
| 105 | } |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 106 | |
| 107 | # Base config for passpoint networks. |
| 108 | self.config_passpoint = { |
| 109 | Ent.FQDN: self.fqdn, |
| 110 | Ent.FRIENDLY_NAME: self.provider_friendly_name, |
| 111 | Ent.REALM: self.realm, |
| 112 | Ent.CA_CERT: self.passpoint_ca_cert |
| 113 | } |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 114 | if self.plmn: |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 115 | self.config_passpoint[Ent.PLMN] = self.plmn |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 116 | if self.roaming_consortium_ids: |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 117 | self.config_passpoint[ |
| 118 | Ent.ROAMING_IDS] = self.roaming_consortium_ids |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 119 | |
| 120 | # Default configs for passpoint networks. |
| 121 | self.config_passpoint_tls = dict(self.config_tls) |
| 122 | self.config_passpoint_tls.update(self.config_passpoint) |
| 123 | self.config_passpoint_tls[Ent.CLIENT_CERT] = self.passpoint_client_cert |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 124 | self.config_passpoint_tls[ |
| 125 | Ent.PRIVATE_KEY_ID] = self.passpoint_client_key |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 126 | del self.config_passpoint_tls[WifiEnums.SSID_KEY] |
| 127 | self.config_passpoint_ttls = dict(self.config_ttls) |
| 128 | self.config_passpoint_ttls.update(self.config_passpoint) |
| 129 | del self.config_passpoint_ttls[WifiEnums.SSID_KEY] |
| 130 | # Set screen lock password so ConfigStore is unlocked. |
Ang Li | a9d188f | 2016-02-17 18:03:01 -0800 | [diff] [blame] | 131 | self.dut.droid.setDevicePassword(self.device_password) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 132 | |
| 133 | def teardown_class(self): |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 134 | wutils.reset_wifi(self.dut) |
Ang Li | a9d188f | 2016-02-17 18:03:01 -0800 | [diff] [blame] | 135 | self.dut.droid.disableDevicePassword() |
| 136 | self.dut.ed.clear_all_events() |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 137 | |
| 138 | def setup_test(self): |
Ang Li | a9d188f | 2016-02-17 18:03:01 -0800 | [diff] [blame] | 139 | self.dut.droid.wifiStartTrackingStateChange() |
| 140 | self.dut.droid.wakeLockAcquireBright() |
| 141 | self.dut.droid.wakeUpNow() |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 142 | wutils.reset_wifi(self.dut) |
Ang Li | a9d188f | 2016-02-17 18:03:01 -0800 | [diff] [blame] | 143 | self.dut.ed.clear_all_events() |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 144 | |
| 145 | def teardown_test(self): |
Ang Li | a9d188f | 2016-02-17 18:03:01 -0800 | [diff] [blame] | 146 | self.dut.droid.wakeLockRelease() |
| 147 | self.dut.droid.goToSleepNow() |
| 148 | self.dut.droid.wifiStopTrackingStateChange() |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 149 | |
Ang Li | 20377aa | 2016-02-26 13:19:51 -0800 | [diff] [blame] | 150 | def on_fail(self, test_name, begin_time): |
| 151 | self.dut.cat_adb_log(test_name, begin_time) |
| 152 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 153 | """Helper Functions""" |
| 154 | |
| 155 | def eap_negative_connect_logic(self, config, ad): |
| 156 | """Tries to connect to an enterprise network with invalid credentials |
| 157 | and expect a failure. |
| 158 | |
| 159 | Args: |
| 160 | config: A dict representing an invalid EAP credential. |
| 161 | |
| 162 | Returns: |
| 163 | True if connection failed as expected, False otherwise. |
| 164 | """ |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 165 | with asserts.assert_raises(signals.TestFailure, extras=config): |
Bindu Mahadev | 50374df | 2017-01-04 11:03:32 -0800 | [diff] [blame] | 166 | verdict = wutils.wifi_connect(ad, config) |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 167 | asserts.explicit_pass("Connection failed as expected.") |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 168 | |
| 169 | def expand_config_by_phase2(self, config): |
| 170 | """Take an enterprise config and generate a list of configs, each with |
| 171 | a different phase2 auth type. |
| 172 | |
| 173 | Args: |
| 174 | config: A dict representing enterprise config. |
| 175 | |
| 176 | Returns |
| 177 | A list of enterprise configs. |
| 178 | """ |
| 179 | results = [] |
| 180 | for phase2_type in EapPhase2: |
| 181 | # Skip a special case for passpoint TTLS. |
| 182 | if Ent.FQDN in config and phase2_type == EapPhase2.GTC: |
| 183 | continue |
| 184 | c = dict(config) |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 185 | c[Ent.PHASE2] = phase2_type.value |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 186 | results.append(c) |
| 187 | return results |
| 188 | |
| 189 | def gen_eap_configs(self): |
| 190 | """Generates configurations for different EAP authentication types. |
| 191 | |
| 192 | Returns: |
| 193 | A list of dicts each representing an EAP configuration. |
| 194 | """ |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 195 | configs = [self.config_tls, self.config_pwd, self.config_sim, |
| 196 | self.config_aka, self.config_aka_prime] |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 197 | configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls) |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 198 | configs += wutils.expand_enterprise_config_by_phase2(self.config_peap0) |
| 199 | configs += wutils.expand_enterprise_config_by_phase2(self.config_peap1) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 200 | return configs |
| 201 | |
| 202 | def gen_passpoint_configs(self): |
| 203 | """Generates passpoint configurations for different EAP authentication |
| 204 | types. |
| 205 | |
| 206 | Returns: |
| 207 | A list of dicts each representing an EAP configuration for |
| 208 | passpoint networks. |
| 209 | """ |
| 210 | configs = [self.config_passpoint_tls] |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 211 | configs += wutils.expand_enterprise_config_by_phase2( |
| 212 | self.config_passpoint_ttls) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 213 | return configs |
| 214 | |
| 215 | def gen_negative_configs(self, configs, neg_params): |
| 216 | """Generic function used to generate negative configs. |
| 217 | |
| 218 | For all the valid configurations, if a param in the neg_params also |
| 219 | exists in a config, a copy of the config is made with an invalid value |
| 220 | of the param. |
| 221 | |
| 222 | Args: |
| 223 | configs: A list of valid configurations. |
| 224 | neg_params: A dict that has all the invalid values. |
| 225 | |
| 226 | Returns: |
| 227 | A list of invalid configurations generated based on the valid |
| 228 | configurations. Each invalid configuration has a different invalid |
| 229 | field. |
| 230 | """ |
| 231 | results = [] |
| 232 | for c in configs: |
| 233 | for k, v in neg_params.items(): |
| 234 | # Skip negative test for TLS's identity field since it's not |
| 235 | # used for auth. |
| 236 | if c[Ent.EAP] == EAP.TLS and k == Ent.IDENTITY: |
| 237 | continue |
| 238 | if k in c: |
| 239 | nc = dict(c) |
| 240 | nc[k] = v |
| 241 | nc["invalid_field"] = k |
| 242 | results.append(nc) |
| 243 | return results |
| 244 | |
| 245 | def gen_negative_eap_configs(self): |
| 246 | """Generates invalid configurations for different EAP authentication |
| 247 | types. |
| 248 | |
| 249 | For all the valid EAP configurations, if a param that is part of the |
| 250 | authentication info exists in a config, a copy of the config is made |
| 251 | with an invalid value of the param. |
| 252 | |
| 253 | Returns: |
| 254 | A list of dicts each representing an invalid EAP configuration. |
| 255 | """ |
| 256 | neg_params = { |
| 257 | Ent.CLIENT_CERT: self.invalid_client_cert, |
| 258 | Ent.CA_CERT: self.invalid_ca_cert, |
| 259 | Ent.PRIVATE_KEY_ID: self.invalid_client_key, |
| 260 | Ent.IDENTITY: "fake_identity", |
| 261 | Ent.PASSWORD: "wrong_password" |
| 262 | } |
| 263 | configs = self.gen_eap_configs() |
| 264 | return self.gen_negative_configs(configs, neg_params) |
| 265 | |
| 266 | def gen_negative_passpoint_configs(self): |
| 267 | """Generates invalid configurations for different EAP authentication |
| 268 | types with passpoint support. |
| 269 | |
| 270 | Returns: |
| 271 | A list of dicts each representing an invalid EAP configuration |
| 272 | with passpoint fields. |
| 273 | """ |
| 274 | neg_params = { |
| 275 | Ent.CLIENT_CERT: self.invalid_client_cert, |
| 276 | Ent.CA_CERT: self.invalid_ca_cert, |
| 277 | Ent.PRIVATE_KEY_ID: self.invalid_client_key, |
| 278 | Ent.IDENTITY: "fake_identity", |
| 279 | Ent.PASSWORD: "wrong_password", |
| 280 | Ent.FQDN: "fake_fqdn", |
| 281 | Ent.REALM: "where_no_one_has_gone_before", |
| 282 | Ent.PLMN: "fake_plmn", |
| 283 | Ent.ROAMING_IDS: [1234567890, 9876543210] |
| 284 | } |
| 285 | configs = self.gen_passpoint_configs() |
| 286 | return self.gen_negative_configs(configs, neg_params) |
| 287 | |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 288 | def gen_eap_test_name_for_config_store(self, config, ad): |
| 289 | """Generates a test case name based on an EAP configuration for config |
| 290 | store tests. |
| 291 | |
| 292 | Args: |
| 293 | config: A dict representing an EAP credential. |
| 294 | ad: Discarded. This is here because name function signature needs |
| 295 | to be consistent with logic function signature for generated |
| 296 | test cases. |
| 297 | |
| 298 | Returns: |
| 299 | A string representing the name of a generated EAP test case. |
| 300 | """ |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 301 | return wutils.generate_eap_test_name(config) + "-config_store" |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 302 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 303 | def gen_passpoint_test_name(self, config, ad): |
| 304 | """Generates a test case name based on an EAP passpoint configuration. |
| 305 | |
| 306 | Args: |
| 307 | config: A dict representing an EAP passpoint credential. |
| 308 | ad: Discarded. This is here because name function signature needs |
| 309 | to be consistent with logic function signature for generated |
| 310 | test cases. |
| 311 | |
| 312 | Returns: |
| 313 | A string representing the name of a generated EAP passpoint connect |
| 314 | test case. |
| 315 | """ |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 316 | name = wutils.generate_eap_test_name(config) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 317 | name = name.replace("connect", "passpoint_connect") |
| 318 | return name |
| 319 | |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 320 | def gen_passpoint_test_name_for_config_store(self, config, ad): |
| 321 | """Generates a test case name based on an EAP passpoint configuration |
| 322 | for config store tests. |
| 323 | |
| 324 | Args: |
| 325 | config: A dict representing an EAP passpoint credential. |
| 326 | ad: Discarded. This is here because name function signature needs |
| 327 | to be consistent with logic function signature for generated |
| 328 | test cases. |
| 329 | |
| 330 | Returns: |
| 331 | A string representing the name of a generated EAP passpoint connect |
| 332 | test case. |
| 333 | """ |
| 334 | return self.gen_passpoint_test_name(config, ad) + "-config_store" |
| 335 | |
| 336 | def eap_connect_toggle_wifi(self, |
| 337 | config, |
| 338 | *args): |
| 339 | """Connects to an enterprise network, toggles wifi state and ensures |
| 340 | that the device reconnects. |
| 341 | |
| 342 | This logic expect the enterprise network to have Internet access. |
| 343 | |
| 344 | Args: |
| 345 | config: A dict representing a wifi enterprise configuration. |
| 346 | args: args to be passed to |wutils.eap_connect|. |
| 347 | |
| 348 | Returns: |
| 349 | True if the connection is successful and Internet access works. |
| 350 | """ |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 351 | ad = args[0] |
Bindu Mahadev | 50374df | 2017-01-04 11:03:32 -0800 | [diff] [blame] | 352 | wutils.wifi_connect(ad, config) |
| 353 | wutils.toggle_wifi_and_wait_for_reconnection(ad, config, num_of_tries=5) |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 354 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 355 | """Tests""" |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 356 | |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 357 | @test_tracker_info(uuid="d1e897d4-9813-4b49-93e5-eb3970113be8") |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 358 | @signals.generated_test |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 359 | def test_eap_connect(self): |
| 360 | """Test connecting to enterprise networks of different authentication |
| 361 | types. |
| 362 | |
| 363 | The authentication types tested are: |
| 364 | EAP-TLS |
| 365 | EAP-PEAP with different phase2 types. |
| 366 | EAP-TTLS with different phase2 types. |
| 367 | |
| 368 | Procedures: |
| 369 | For each enterprise wifi network |
| 370 | 1. Connect to the network. |
| 371 | 2. Send a GET request to a website and check response. |
| 372 | |
| 373 | Expect: |
| 374 | Successful connection and Internet access through the enterprise |
| 375 | networks. |
| 376 | """ |
| 377 | eap_configs = self.gen_eap_configs() |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 378 | self.log.info("Testing %d different configs.", len(eap_configs)) |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 379 | random.shuffle(eap_configs) |
Bindu Mahadev | 50374df | 2017-01-04 11:03:32 -0800 | [diff] [blame] | 380 | failed = self.run_generated_testcases(wutils.wifi_connect, |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 381 | eap_configs, |
| 382 | args=(self.dut, ), |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 383 | name_func=wutils.generate_eap_test_name, |
Bindu Mahadev | 50374df | 2017-01-04 11:03:32 -0800 | [diff] [blame] | 384 | format_args=True) |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 385 | asserts.assert_equal( |
| 386 | len(failed), 0, "The following configs failed EAP connect test: %s" |
| 387 | % pprint.pformat(failed)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 388 | |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 389 | @test_tracker_info(uuid="10d78928-e6bf-4c75-a5d3-aae05f0d6a04") |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 390 | @signals.generated_test |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 391 | def test_eap_connect_negative(self): |
| 392 | """Test connecting to enterprise networks. |
| 393 | |
| 394 | Procedures: |
| 395 | For each enterprise wifi network |
| 396 | 1. Connect to the network with invalid credentials. |
| 397 | |
| 398 | Expect: |
| 399 | Fail to establish connection. |
| 400 | """ |
| 401 | neg_eap_configs = self.gen_negative_eap_configs() |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 402 | self.log.info("Testing %d different configs.", len(neg_eap_configs)) |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 403 | random.shuffle(neg_eap_configs) |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 404 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 405 | def name_gen(config, ad): |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 406 | name = wutils.generate_eap_test_name(config) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 407 | name += "-with_wrong-{}".format(config["invalid_field"]) |
| 408 | return name |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 409 | |
| 410 | failed = self.run_generated_testcases(self.eap_negative_connect_logic, |
| 411 | neg_eap_configs, |
| 412 | args=(self.dut, ), |
| 413 | name_func=name_gen) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 414 | msg = ("The following configs failed negative EAP connect test: %s" % |
| 415 | pprint.pformat(failed)) |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 416 | asserts.assert_equal(len(failed), 0, msg) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 417 | |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 418 | @test_tracker_info(uuid="f79e6063-5615-4399-b618-86968d5445c8") |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 419 | @signals.generated_test |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 420 | def test_eap_connect_config_store(self): |
| 421 | """Test connecting to enterprise networks of different authentication |
| 422 | types after wifi toggle. |
| 423 | |
| 424 | The authentication types tested are: |
| 425 | EAP-TLS |
| 426 | EAP-PEAP with different phase2 types. |
| 427 | EAP-TTLS with different phase2 types. |
| 428 | |
| 429 | Procedures: |
| 430 | For each enterprise wifi network |
| 431 | 1. Connect to the network. |
| 432 | 2. Send a GET request to a website and check response. |
| 433 | 3. Toggle wifi. |
| 434 | 4. Ensure that the device reconnects to the same network. |
| 435 | |
| 436 | Expect: |
| 437 | Successful connection and Internet access through the enterprise |
| 438 | networks. |
| 439 | """ |
| 440 | eap_configs = self.gen_eap_configs() |
| 441 | self.log.info("Testing %d different configs.", len(eap_configs)) |
| 442 | random.shuffle(eap_configs) |
| 443 | failed = self.run_generated_testcases( |
| 444 | self.eap_connect_toggle_wifi, |
| 445 | eap_configs, |
| 446 | args=(self.dut, ), |
Girish Moturu | 150d32f | 2017-02-14 12:27:07 -0800 | [diff] [blame] | 447 | name_func=wutils.generate_eap_test_name) |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 448 | asserts.assert_equal( |
| 449 | len(failed), 0, "The following configs failed EAP connect test: %s" |
| 450 | % pprint.pformat(failed)) |
| 451 | |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 452 | @test_tracker_info(uuid="85b7950f-c36e-44b1-939b-509550db5918") |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 453 | @signals.generated_test |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 454 | def test_passpoint_connect(self): |
| 455 | """Test connecting to enterprise networks of different authentication |
| 456 | types with passpoint support. |
| 457 | |
| 458 | The authentication types tested are: |
| 459 | EAP-TLS |
| 460 | EAP-TTLS with MSCHAPV2 as phase2. |
| 461 | |
| 462 | Procedures: |
| 463 | For each enterprise wifi network |
| 464 | 1. Connect to the network. |
| 465 | 2. Send a GET request to a website and check response. |
| 466 | |
| 467 | Expect: |
| 468 | Successful connection and Internet access through the enterprise |
| 469 | networks with passpoint support. |
| 470 | """ |
Ang Li | c2d4521 | 2016-03-10 18:38:53 -0800 | [diff] [blame] | 471 | asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 472 | "Passpoint is not supported on device %s" % |
| 473 | self.dut.model) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 474 | passpoint_configs = self.gen_passpoint_configs() |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 475 | self.log.info("Testing %d different configs.", len(passpoint_configs)) |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 476 | random.shuffle(passpoint_configs) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 477 | failed = self.run_generated_testcases( |
Bindu Mahadev | 50374df | 2017-01-04 11:03:32 -0800 | [diff] [blame] | 478 | wutils.wifi_connect, |
| 479 | passpoint_configs, |
| 480 | args=(self.dut, ), |
| 481 | name_func=self.gen_passpoint_test_name, |
| 482 | format_args=True) |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 483 | asserts.assert_equal( |
| 484 | len(failed), 0, |
| 485 | "The following configs failed passpoint connect test: %s" % |
| 486 | pprint.pformat(failed)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 487 | |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 488 | @test_tracker_info(uuid="0e068a2f-cc7b-4c11-ada1-d0d1b0f4163b") |
Ang Li | 8252281 | 2016-06-02 13:57:21 -0700 | [diff] [blame] | 489 | @signals.generated_test |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 490 | def test_passpoint_connect_negative(self): |
| 491 | """Test connecting to enterprise networks. |
| 492 | |
| 493 | Procedures: |
| 494 | For each enterprise wifi network |
| 495 | 1. Connect to the network with invalid credentials. |
| 496 | |
| 497 | Expect: |
| 498 | Fail to establish connection. |
| 499 | """ |
Ang Li | c2d4521 | 2016-03-10 18:38:53 -0800 | [diff] [blame] | 500 | asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 501 | "Passpoint is not supported on device %s" % |
| 502 | self.dut.model) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 503 | neg_passpoint_configs = self.gen_negative_passpoint_configs() |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 504 | self.log.info("Testing %d different configs.", |
| 505 | len(neg_passpoint_configs)) |
Ang Li | 8e76718 | 2015-12-09 17:29:24 -0800 | [diff] [blame] | 506 | random.shuffle(neg_passpoint_configs) |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 507 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 508 | def name_gen(config, ad): |
| 509 | name = self.gen_passpoint_test_name(config, ad) |
| 510 | name += "-with_wrong-{}".format(config["invalid_field"]) |
| 511 | return name |
Ang Li | 8154905 | 2016-06-09 18:51:14 -0700 | [diff] [blame] | 512 | |
| 513 | failed = self.run_generated_testcases(self.eap_negative_connect_logic, |
| 514 | neg_passpoint_configs, |
| 515 | args=(self.dut, ), |
| 516 | name_func=name_gen) |
| 517 | asserts.assert_equal( |
| 518 | len(failed), 0, |
| 519 | "The following configs failed negative passpoint connect test: %s" |
| 520 | % pprint.pformat(failed)) |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 521 | |
Girish Moturu | 03a2e4d | 2017-06-12 10:46:51 +0530 | [diff] [blame^] | 522 | @test_tracker_info(uuid="a17347e0-4b0e-49ae-8bd2-60ba185e1c35") |
Roshan Pius | 58916a3 | 2016-06-16 16:26:44 -0700 | [diff] [blame] | 523 | @signals.generated_test |
| 524 | def test_passpoint_connect_config_store(self): |
| 525 | """Test connecting to enterprise networks of different authentication |
| 526 | types with passpoint support after wifi toggle. |
| 527 | |
| 528 | The authentication types tested are: |
| 529 | EAP-TLS |
| 530 | EAP-TTLS with MSCHAPV2 as phase2. |
| 531 | |
| 532 | Procedures: |
| 533 | For each enterprise wifi network |
| 534 | 1. Connect to the network. |
| 535 | 2. Send a GET request to a website and check response. |
| 536 | 3. Toggle wifi. |
| 537 | 4. Ensure that the device reconnects to the same network. |
| 538 | |
| 539 | Expect: |
| 540 | Successful connection and Internet access through the enterprise |
| 541 | networks with passpoint support. |
| 542 | """ |
| 543 | asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), |
| 544 | "Passpoint is not supported on device %s" % |
| 545 | self.dut.model) |
| 546 | passpoint_configs = self.gen_passpoint_configs() |
| 547 | self.log.info("Testing %d different configs.", len(passpoint_configs)) |
| 548 | random.shuffle(passpoint_configs) |
| 549 | failed = self.run_generated_testcases( |
| 550 | self.eap_connect_toggle_wifi, |
| 551 | passpoint_configs, |
| 552 | args=(self.dut, ), |
| 553 | name_func=self.gen_passpoint_test_name_for_config_store) |
| 554 | asserts.assert_equal( |
| 555 | len(failed), 0, |
| 556 | "The following configs failed passpoint connect test: %s" % |
| 557 | pprint.pformat(failed)) |