blob: b28ca669ee8354a2eaa732e4ac849102e36d54b5 [file] [log] [blame]
tturney1bdf77d2015-12-28 17:46:13 -08001#!/usr/bin/env python3.4
Ang Li73697b32015-12-03 00:41:53 +00002#
tturney1bdf77d2015-12-28 17:46:13 -08003# Copyright 2016 - The Android Open Source Project
Ang Li73697b32015-12-03 00:41:53 +00004#
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
17import pprint
Ang Li8e767182015-12-09 17:29:24 -080018import random
Ang Li73697b32015-12-03 00:41:53 +000019import time
20
Ang Lic2d45212016-03-10 18:38:53 -080021from acts import asserts
Ang Li82522812016-06-02 13:57:21 -070022from acts import base_test
23from acts import signals
Girish Moturu03a2e4d2017-06-12 10:46:51 +053024from acts.test_decorators import test_tracker_info
Ang Li82522812016-06-02 13:57:21 -070025from acts.test_utils.wifi import wifi_test_utils as wutils
Ang Lic2d45212016-03-10 18:38:53 -080026
Ang Lie8ed2b32015-12-11 12:30:20 -080027WifiEnums = wutils.WifiEnums
Ang Li73697b32015-12-03 00:41:53 +000028
29# EAP Macros
30EAP = WifiEnums.Eap
31EapPhase2 = WifiEnums.EapPhase2
Ang Li73697b32015-12-03 00:41:53 +000032# Enterprise Config Macros
33Ent = WifiEnums.Enterprise
Ang Li73697b32015-12-03 00:41:53 +000034
Ang Li73697b32015-12-03 00:41:53 +000035
Ang Li81549052016-06-09 18:51:14 -070036class WifiEnterpriseTest(base_test.BaseTestClass):
Ang Li73697b32015-12-03 00:41:53 +000037 def __init__(self, controllers):
Ang Li82522812016-06-02 13:57:21 -070038 base_test.BaseTestClass.__init__(self, controllers)
Roshan Pius58916a32016-06-16 16:26:44 -070039 self.tests = ("test_eap_connect", "test_eap_connect_negative",
40 "test_eap_connect_config_store", )
Ang Li73697b32015-12-03 00:41:53 +000041
42 def setup_class(self):
43 self.dut = self.android_devices[0]
Ang Li8e767182015-12-09 17:29:24 -080044 wutils.wifi_test_device_init(self.dut)
Ang Li81549052016-06-09 18:51:14 -070045 # 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 Li73697b32015-12-03 00:41:53 +000050 required_userparam_names = (
Ang Li81549052016-06-09 18:51:14 -070051 "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 Li5cd6d3c2016-02-01 11:29:14 -080058 self.unpack_userparams(required_userparam_names,
Ang Li82522812016-06-02 13:57:21 -070059 roaming_consortium_ids=None,
60 plmn=None)
Ang Li73697b32015-12-03 00:41:53 +000061 # Default configs for EAP networks.
Ang Li82522812016-06-02 13:57:21 -070062 self.config_peap0 = {
Girish Moturu150d32f2017-02-14 12:27:07 -080063 Ent.EAP: int(EAP.PEAP),
Ang Li73697b32015-12-03 00:41:53 +000064 Ent.CA_CERT: self.ca_cert,
65 Ent.IDENTITY: self.eap_identity,
66 Ent.PASSWORD: self.eap_password,
Girish Moturu150d32f2017-02-14 12:27:07 -080067 Ent.PHASE2: int(EapPhase2.MSCHAPV2),
Ang Li82522812016-06-02 13:57:21 -070068 WifiEnums.SSID_KEY: self.ssid_peap0
Ang Li73697b32015-12-03 00:41:53 +000069 }
Ang Li82522812016-06-02 13:57:21 -070070 self.config_peap1 = dict(self.config_peap0)
71 self.config_peap1[WifiEnums.SSID_KEY] = self.ssid_peap1
Ang Li73697b32015-12-03 00:41:53 +000072 self.config_tls = {
Girish Moturu150d32f2017-02-14 12:27:07 -080073 Ent.EAP: int(EAP.TLS),
Ang Li73697b32015-12-03 00:41:53 +000074 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 Moturu150d32f2017-02-14 12:27:07 -080081 Ent.EAP: int(EAP.TTLS),
Ang Li73697b32015-12-03 00:41:53 +000082 Ent.CA_CERT: self.ca_cert,
83 Ent.IDENTITY: self.eap_identity,
84 Ent.PASSWORD: self.eap_password,
Girish Moturu150d32f2017-02-14 12:27:07 -080085 Ent.PHASE2: int(EapPhase2.MSCHAPV2),
Ang Li73697b32015-12-03 00:41:53 +000086 WifiEnums.SSID_KEY: self.ssid_ttls
87 }
Ang Li82522812016-06-02 13:57:21 -070088 self.config_pwd = {
Girish Moturu150d32f2017-02-14 12:27:07 -080089 Ent.EAP: int(EAP.PWD),
Ang Li82522812016-06-02 13:57:21 -070090 Ent.IDENTITY: self.eap_identity,
91 Ent.PASSWORD: self.eap_password,
92 WifiEnums.SSID_KEY: self.ssid_pwd
93 }
Ang Li73697b32015-12-03 00:41:53 +000094 self.config_sim = {
Girish Moturu150d32f2017-02-14 12:27:07 -080095 Ent.EAP: int(EAP.SIM),
Ang Li73697b32015-12-03 00:41:53 +000096 WifiEnums.SSID_KEY: self.ssid_sim,
97 }
Ang Li82522812016-06-02 13:57:21 -070098 self.config_aka = {
Girish Moturu150d32f2017-02-14 12:27:07 -080099 Ent.EAP: int(EAP.AKA),
Ang Li82522812016-06-02 13:57:21 -0700100 WifiEnums.SSID_KEY: self.ssid_aka,
101 }
102 self.config_aka_prime = {
Girish Moturu150d32f2017-02-14 12:27:07 -0800103 Ent.EAP: int(EAP.AKA_PRIME),
Ang Li82522812016-06-02 13:57:21 -0700104 WifiEnums.SSID_KEY: self.ssid_aka_prime,
105 }
Ang Li73697b32015-12-03 00:41:53 +0000106
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 Li82522812016-06-02 13:57:21 -0700114 if self.plmn:
Ang Li73697b32015-12-03 00:41:53 +0000115 self.config_passpoint[Ent.PLMN] = self.plmn
Ang Li82522812016-06-02 13:57:21 -0700116 if self.roaming_consortium_ids:
Ang Li81549052016-06-09 18:51:14 -0700117 self.config_passpoint[
118 Ent.ROAMING_IDS] = self.roaming_consortium_ids
Ang Li73697b32015-12-03 00:41:53 +0000119
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 Li81549052016-06-09 18:51:14 -0700124 self.config_passpoint_tls[
125 Ent.PRIVATE_KEY_ID] = self.passpoint_client_key
Ang Li73697b32015-12-03 00:41:53 +0000126 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 Lia9d188f2016-02-17 18:03:01 -0800131 self.dut.droid.setDevicePassword(self.device_password)
Ang Li73697b32015-12-03 00:41:53 +0000132
133 def teardown_class(self):
Ang Li8e767182015-12-09 17:29:24 -0800134 wutils.reset_wifi(self.dut)
Ang Lia9d188f2016-02-17 18:03:01 -0800135 self.dut.droid.disableDevicePassword()
136 self.dut.ed.clear_all_events()
Ang Li73697b32015-12-03 00:41:53 +0000137
138 def setup_test(self):
Ang Lia9d188f2016-02-17 18:03:01 -0800139 self.dut.droid.wifiStartTrackingStateChange()
140 self.dut.droid.wakeLockAcquireBright()
141 self.dut.droid.wakeUpNow()
Ang Li8e767182015-12-09 17:29:24 -0800142 wutils.reset_wifi(self.dut)
Ang Lia9d188f2016-02-17 18:03:01 -0800143 self.dut.ed.clear_all_events()
Ang Li73697b32015-12-03 00:41:53 +0000144
145 def teardown_test(self):
Ang Lia9d188f2016-02-17 18:03:01 -0800146 self.dut.droid.wakeLockRelease()
147 self.dut.droid.goToSleepNow()
148 self.dut.droid.wifiStopTrackingStateChange()
Ang Li73697b32015-12-03 00:41:53 +0000149
Ang Li20377aa2016-02-26 13:19:51 -0800150 def on_fail(self, test_name, begin_time):
151 self.dut.cat_adb_log(test_name, begin_time)
152
Ang Li73697b32015-12-03 00:41:53 +0000153 """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 Li82522812016-06-02 13:57:21 -0700165 with asserts.assert_raises(signals.TestFailure, extras=config):
Bindu Mahadev50374df2017-01-04 11:03:32 -0800166 verdict = wutils.wifi_connect(ad, config)
Ang Li82522812016-06-02 13:57:21 -0700167 asserts.explicit_pass("Connection failed as expected.")
Ang Li73697b32015-12-03 00:41:53 +0000168
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 Moturu150d32f2017-02-14 12:27:07 -0800185 c[Ent.PHASE2] = phase2_type.value
Ang Li73697b32015-12-03 00:41:53 +0000186 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 Li81549052016-06-09 18:51:14 -0700195 configs = [self.config_tls, self.config_pwd, self.config_sim,
196 self.config_aka, self.config_aka_prime]
Ang Li8e767182015-12-09 17:29:24 -0800197 configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls)
Ang Li82522812016-06-02 13:57:21 -0700198 configs += wutils.expand_enterprise_config_by_phase2(self.config_peap0)
199 configs += wutils.expand_enterprise_config_by_phase2(self.config_peap1)
Ang Li73697b32015-12-03 00:41:53 +0000200 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 Li81549052016-06-09 18:51:14 -0700211 configs += wutils.expand_enterprise_config_by_phase2(
212 self.config_passpoint_ttls)
Ang Li73697b32015-12-03 00:41:53 +0000213 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 Pius58916a32016-06-16 16:26:44 -0700288 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 Moturu150d32f2017-02-14 12:27:07 -0800301 return wutils.generate_eap_test_name(config) + "-config_store"
Roshan Pius58916a32016-06-16 16:26:44 -0700302
Ang Li73697b32015-12-03 00:41:53 +0000303 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 Moturu150d32f2017-02-14 12:27:07 -0800316 name = wutils.generate_eap_test_name(config)
Ang Li73697b32015-12-03 00:41:53 +0000317 name = name.replace("connect", "passpoint_connect")
318 return name
319
Roshan Pius58916a32016-06-16 16:26:44 -0700320 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 Pius58916a32016-06-16 16:26:44 -0700351 ad = args[0]
Bindu Mahadev50374df2017-01-04 11:03:32 -0800352 wutils.wifi_connect(ad, config)
353 wutils.toggle_wifi_and_wait_for_reconnection(ad, config, num_of_tries=5)
Roshan Pius58916a32016-06-16 16:26:44 -0700354
Ang Li73697b32015-12-03 00:41:53 +0000355 """Tests"""
Ang Li81549052016-06-09 18:51:14 -0700356
Girish Moturu03a2e4d2017-06-12 10:46:51 +0530357 @test_tracker_info(uuid="d1e897d4-9813-4b49-93e5-eb3970113be8")
Ang Li82522812016-06-02 13:57:21 -0700358 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000359 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 Li81549052016-06-09 18:51:14 -0700378 self.log.info("Testing %d different configs.", len(eap_configs))
Ang Li8e767182015-12-09 17:29:24 -0800379 random.shuffle(eap_configs)
Bindu Mahadev50374df2017-01-04 11:03:32 -0800380 failed = self.run_generated_testcases(wutils.wifi_connect,
Ang Li81549052016-06-09 18:51:14 -0700381 eap_configs,
382 args=(self.dut, ),
Girish Moturu150d32f2017-02-14 12:27:07 -0800383 name_func=wutils.generate_eap_test_name,
Bindu Mahadev50374df2017-01-04 11:03:32 -0800384 format_args=True)
Ang Li81549052016-06-09 18:51:14 -0700385 asserts.assert_equal(
386 len(failed), 0, "The following configs failed EAP connect test: %s"
387 % pprint.pformat(failed))
Ang Li73697b32015-12-03 00:41:53 +0000388
Girish Moturu03a2e4d2017-06-12 10:46:51 +0530389 @test_tracker_info(uuid="10d78928-e6bf-4c75-a5d3-aae05f0d6a04")
Ang Li82522812016-06-02 13:57:21 -0700390 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000391 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 Li81549052016-06-09 18:51:14 -0700402 self.log.info("Testing %d different configs.", len(neg_eap_configs))
Ang Li8e767182015-12-09 17:29:24 -0800403 random.shuffle(neg_eap_configs)
Ang Li81549052016-06-09 18:51:14 -0700404
Ang Li73697b32015-12-03 00:41:53 +0000405 def name_gen(config, ad):
Girish Moturu150d32f2017-02-14 12:27:07 -0800406 name = wutils.generate_eap_test_name(config)
Ang Li73697b32015-12-03 00:41:53 +0000407 name += "-with_wrong-{}".format(config["invalid_field"])
408 return name
Ang Li81549052016-06-09 18:51:14 -0700409
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 Li73697b32015-12-03 00:41:53 +0000414 msg = ("The following configs failed negative EAP connect test: %s" %
415 pprint.pformat(failed))
Ang Li82522812016-06-02 13:57:21 -0700416 asserts.assert_equal(len(failed), 0, msg)
Ang Li73697b32015-12-03 00:41:53 +0000417
Girish Moturu03a2e4d2017-06-12 10:46:51 +0530418 @test_tracker_info(uuid="f79e6063-5615-4399-b618-86968d5445c8")
Ang Li82522812016-06-02 13:57:21 -0700419 @signals.generated_test
Roshan Pius58916a32016-06-16 16:26:44 -0700420 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 Moturu150d32f2017-02-14 12:27:07 -0800447 name_func=wutils.generate_eap_test_name)
Roshan Pius58916a32016-06-16 16:26:44 -0700448 asserts.assert_equal(
449 len(failed), 0, "The following configs failed EAP connect test: %s"
450 % pprint.pformat(failed))
451
Girish Moturu03a2e4d2017-06-12 10:46:51 +0530452 @test_tracker_info(uuid="85b7950f-c36e-44b1-939b-509550db5918")
Roshan Pius58916a32016-06-16 16:26:44 -0700453 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000454 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 Lic2d45212016-03-10 18:38:53 -0800471 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
Ang Li81549052016-06-09 18:51:14 -0700472 "Passpoint is not supported on device %s" %
473 self.dut.model)
Ang Li73697b32015-12-03 00:41:53 +0000474 passpoint_configs = self.gen_passpoint_configs()
Ang Li81549052016-06-09 18:51:14 -0700475 self.log.info("Testing %d different configs.", len(passpoint_configs))
Ang Li8e767182015-12-09 17:29:24 -0800476 random.shuffle(passpoint_configs)
Ang Li73697b32015-12-03 00:41:53 +0000477 failed = self.run_generated_testcases(
Bindu Mahadev50374df2017-01-04 11:03:32 -0800478 wutils.wifi_connect,
479 passpoint_configs,
480 args=(self.dut, ),
481 name_func=self.gen_passpoint_test_name,
482 format_args=True)
Ang Li81549052016-06-09 18:51:14 -0700483 asserts.assert_equal(
484 len(failed), 0,
485 "The following configs failed passpoint connect test: %s" %
486 pprint.pformat(failed))
Ang Li73697b32015-12-03 00:41:53 +0000487
Girish Moturu03a2e4d2017-06-12 10:46:51 +0530488 @test_tracker_info(uuid="0e068a2f-cc7b-4c11-ada1-d0d1b0f4163b")
Ang Li82522812016-06-02 13:57:21 -0700489 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000490 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 Lic2d45212016-03-10 18:38:53 -0800500 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
Ang Li81549052016-06-09 18:51:14 -0700501 "Passpoint is not supported on device %s" %
502 self.dut.model)
Ang Li73697b32015-12-03 00:41:53 +0000503 neg_passpoint_configs = self.gen_negative_passpoint_configs()
Ang Li81549052016-06-09 18:51:14 -0700504 self.log.info("Testing %d different configs.",
505 len(neg_passpoint_configs))
Ang Li8e767182015-12-09 17:29:24 -0800506 random.shuffle(neg_passpoint_configs)
Ang Li81549052016-06-09 18:51:14 -0700507
Ang Li73697b32015-12-03 00:41:53 +0000508 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 Li81549052016-06-09 18:51:14 -0700512
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 Pius58916a32016-06-16 16:26:44 -0700521
Girish Moturu03a2e4d2017-06-12 10:46:51 +0530522 @test_tracker_info(uuid="a17347e0-4b0e-49ae-8bd2-60ba185e1c35")
Roshan Pius58916a32016-06-16 16:26:44 -0700523 @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))