blob: 257c7a09973e8e047c51aee9aecaae7b7e7cd2e2 [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
24from acts.test_utils.wifi import wifi_test_utils as wutils
Ang Lic2d45212016-03-10 18:38:53 -080025
Ang Lie8ed2b32015-12-11 12:30:20 -080026WifiEnums = wutils.WifiEnums
Ang Li73697b32015-12-03 00:41:53 +000027
28# EAP Macros
29EAP = WifiEnums.Eap
30EapPhase2 = WifiEnums.EapPhase2
Ang Li73697b32015-12-03 00:41:53 +000031# Enterprise Config Macros
32Ent = WifiEnums.Enterprise
Ang Li73697b32015-12-03 00:41:53 +000033
Ang Li73697b32015-12-03 00:41:53 +000034
Ang Li81549052016-06-09 18:51:14 -070035class WifiEnterpriseTest(base_test.BaseTestClass):
Ang Li73697b32015-12-03 00:41:53 +000036 def __init__(self, controllers):
Ang Li82522812016-06-02 13:57:21 -070037 base_test.BaseTestClass.__init__(self, controllers)
Roshan Pius58916a32016-06-16 16:26:44 -070038 self.tests = ("test_eap_connect", "test_eap_connect_negative",
39 "test_eap_connect_config_store", )
Ang Li73697b32015-12-03 00:41:53 +000040
41 def setup_class(self):
42 self.dut = self.android_devices[0]
Ang Li8e767182015-12-09 17:29:24 -080043 wutils.wifi_test_device_init(self.dut)
Ang Li81549052016-06-09 18:51:14 -070044 # If running in a setup with attenuators, set attenuation on all
45 # channels to zero.
46 if getattr(self, "attenuators", []):
47 for a in self.attenuators:
48 a.set_atten(0)
Ang Li73697b32015-12-03 00:41:53 +000049 required_userparam_names = (
Ang Li81549052016-06-09 18:51:14 -070050 "ca_cert", "client_cert", "client_key", "passpoint_ca_cert",
51 "passpoint_client_cert", "passpoint_client_key", "eap_identity",
52 "eap_password", "invalid_ca_cert", "invalid_client_cert",
53 "invalid_client_key", "fqdn", "provider_friendly_name", "realm",
54 "ssid_peap0", "ssid_peap1", "ssid_tls", "ssid_ttls", "ssid_pwd",
55 "ssid_sim", "ssid_aka", "ssid_aka_prime", "ssid_passpoint",
56 "device_password", "ping_addr")
Ang Li5cd6d3c2016-02-01 11:29:14 -080057 self.unpack_userparams(required_userparam_names,
Ang Li82522812016-06-02 13:57:21 -070058 roaming_consortium_ids=None,
59 plmn=None)
Ang Li73697b32015-12-03 00:41:53 +000060 # Default configs for EAP networks.
Ang Li82522812016-06-02 13:57:21 -070061 self.config_peap0 = {
Ang Li73697b32015-12-03 00:41:53 +000062 Ent.EAP: EAP.PEAP,
63 Ent.CA_CERT: self.ca_cert,
64 Ent.IDENTITY: self.eap_identity,
65 Ent.PASSWORD: self.eap_password,
66 Ent.PHASE2: EapPhase2.MSCHAPV2,
Ang Li82522812016-06-02 13:57:21 -070067 WifiEnums.SSID_KEY: self.ssid_peap0
Ang Li73697b32015-12-03 00:41:53 +000068 }
Ang Li82522812016-06-02 13:57:21 -070069 self.config_peap1 = dict(self.config_peap0)
70 self.config_peap1[WifiEnums.SSID_KEY] = self.ssid_peap1
Ang Li73697b32015-12-03 00:41:53 +000071 self.config_tls = {
72 Ent.EAP: EAP.TLS,
73 Ent.CA_CERT: self.ca_cert,
74 WifiEnums.SSID_KEY: self.ssid_tls,
75 Ent.CLIENT_CERT: self.client_cert,
76 Ent.PRIVATE_KEY_ID: self.client_key,
77 Ent.IDENTITY: self.eap_identity,
78 }
79 self.config_ttls = {
80 Ent.EAP: EAP.TTLS,
81 Ent.CA_CERT: self.ca_cert,
82 Ent.IDENTITY: self.eap_identity,
83 Ent.PASSWORD: self.eap_password,
84 Ent.PHASE2: EapPhase2.MSCHAPV2,
85 WifiEnums.SSID_KEY: self.ssid_ttls
86 }
Ang Li82522812016-06-02 13:57:21 -070087 self.config_pwd = {
88 Ent.EAP: EAP.PWD,
89 Ent.IDENTITY: self.eap_identity,
90 Ent.PASSWORD: self.eap_password,
91 WifiEnums.SSID_KEY: self.ssid_pwd
92 }
Ang Li73697b32015-12-03 00:41:53 +000093 self.config_sim = {
94 Ent.EAP: EAP.SIM,
95 WifiEnums.SSID_KEY: self.ssid_sim,
96 }
Ang Li82522812016-06-02 13:57:21 -070097 self.config_aka = {
98 Ent.EAP: EAP.AKA,
99 WifiEnums.SSID_KEY: self.ssid_aka,
100 }
101 self.config_aka_prime = {
102 Ent.EAP: EAP.AKA_PRIME,
103 WifiEnums.SSID_KEY: self.ssid_aka_prime,
104 }
Ang Li73697b32015-12-03 00:41:53 +0000105
106 # Base config for passpoint networks.
107 self.config_passpoint = {
108 Ent.FQDN: self.fqdn,
109 Ent.FRIENDLY_NAME: self.provider_friendly_name,
110 Ent.REALM: self.realm,
111 Ent.CA_CERT: self.passpoint_ca_cert
112 }
Ang Li82522812016-06-02 13:57:21 -0700113 if self.plmn:
Ang Li73697b32015-12-03 00:41:53 +0000114 self.config_passpoint[Ent.PLMN] = self.plmn
Ang Li82522812016-06-02 13:57:21 -0700115 if self.roaming_consortium_ids:
Ang Li81549052016-06-09 18:51:14 -0700116 self.config_passpoint[
117 Ent.ROAMING_IDS] = self.roaming_consortium_ids
Ang Li73697b32015-12-03 00:41:53 +0000118
119 # Default configs for passpoint networks.
120 self.config_passpoint_tls = dict(self.config_tls)
121 self.config_passpoint_tls.update(self.config_passpoint)
122 self.config_passpoint_tls[Ent.CLIENT_CERT] = self.passpoint_client_cert
Ang Li81549052016-06-09 18:51:14 -0700123 self.config_passpoint_tls[
124 Ent.PRIVATE_KEY_ID] = self.passpoint_client_key
Ang Li73697b32015-12-03 00:41:53 +0000125 del self.config_passpoint_tls[WifiEnums.SSID_KEY]
126 self.config_passpoint_ttls = dict(self.config_ttls)
127 self.config_passpoint_ttls.update(self.config_passpoint)
128 del self.config_passpoint_ttls[WifiEnums.SSID_KEY]
129 # Set screen lock password so ConfigStore is unlocked.
Ang Lia9d188f2016-02-17 18:03:01 -0800130 self.dut.droid.setDevicePassword(self.device_password)
Ang Li73697b32015-12-03 00:41:53 +0000131
132 def teardown_class(self):
Ang Li8e767182015-12-09 17:29:24 -0800133 wutils.reset_wifi(self.dut)
Ang Lia9d188f2016-02-17 18:03:01 -0800134 self.dut.droid.disableDevicePassword()
135 self.dut.ed.clear_all_events()
Ang Li73697b32015-12-03 00:41:53 +0000136
137 def setup_test(self):
Ang Lia9d188f2016-02-17 18:03:01 -0800138 self.dut.droid.wifiStartTrackingStateChange()
139 self.dut.droid.wakeLockAcquireBright()
140 self.dut.droid.wakeUpNow()
Ang Li8e767182015-12-09 17:29:24 -0800141 wutils.reset_wifi(self.dut)
Ang Lia9d188f2016-02-17 18:03:01 -0800142 self.dut.ed.clear_all_events()
Ang Li73697b32015-12-03 00:41:53 +0000143
144 def teardown_test(self):
Ang Lia9d188f2016-02-17 18:03:01 -0800145 self.dut.droid.wakeLockRelease()
146 self.dut.droid.goToSleepNow()
147 self.dut.droid.wifiStopTrackingStateChange()
Ang Li73697b32015-12-03 00:41:53 +0000148
Ang Li20377aa2016-02-26 13:19:51 -0800149 def on_fail(self, test_name, begin_time):
150 self.dut.cat_adb_log(test_name, begin_time)
151
Ang Li73697b32015-12-03 00:41:53 +0000152 """Helper Functions"""
153
154 def eap_negative_connect_logic(self, config, ad):
155 """Tries to connect to an enterprise network with invalid credentials
156 and expect a failure.
157
158 Args:
159 config: A dict representing an invalid EAP credential.
160
161 Returns:
162 True if connection failed as expected, False otherwise.
163 """
Ang Li82522812016-06-02 13:57:21 -0700164 with asserts.assert_raises(signals.TestFailure, extras=config):
Bindu Mahadev50374df2017-01-04 11:03:32 -0800165 verdict = wutils.wifi_connect(ad, config)
Ang Li82522812016-06-02 13:57:21 -0700166 asserts.explicit_pass("Connection failed as expected.")
Ang Li73697b32015-12-03 00:41:53 +0000167
168 def expand_config_by_phase2(self, config):
169 """Take an enterprise config and generate a list of configs, each with
170 a different phase2 auth type.
171
172 Args:
173 config: A dict representing enterprise config.
174
175 Returns
176 A list of enterprise configs.
177 """
178 results = []
179 for phase2_type in EapPhase2:
180 # Skip a special case for passpoint TTLS.
181 if Ent.FQDN in config and phase2_type == EapPhase2.GTC:
182 continue
183 c = dict(config)
184 c[Ent.PHASE2] = phase2_type
185 results.append(c)
186 return results
187
188 def gen_eap_configs(self):
189 """Generates configurations for different EAP authentication types.
190
191 Returns:
192 A list of dicts each representing an EAP configuration.
193 """
Ang Li81549052016-06-09 18:51:14 -0700194 configs = [self.config_tls, self.config_pwd, self.config_sim,
195 self.config_aka, self.config_aka_prime]
Ang Li8e767182015-12-09 17:29:24 -0800196 configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls)
Ang Li82522812016-06-02 13:57:21 -0700197 configs += wutils.expand_enterprise_config_by_phase2(self.config_peap0)
198 configs += wutils.expand_enterprise_config_by_phase2(self.config_peap1)
Ang Li73697b32015-12-03 00:41:53 +0000199 return configs
200
201 def gen_passpoint_configs(self):
202 """Generates passpoint configurations for different EAP authentication
203 types.
204
205 Returns:
206 A list of dicts each representing an EAP configuration for
207 passpoint networks.
208 """
209 configs = [self.config_passpoint_tls]
Ang Li81549052016-06-09 18:51:14 -0700210 configs += wutils.expand_enterprise_config_by_phase2(
211 self.config_passpoint_ttls)
Ang Li73697b32015-12-03 00:41:53 +0000212 return configs
213
214 def gen_negative_configs(self, configs, neg_params):
215 """Generic function used to generate negative configs.
216
217 For all the valid configurations, if a param in the neg_params also
218 exists in a config, a copy of the config is made with an invalid value
219 of the param.
220
221 Args:
222 configs: A list of valid configurations.
223 neg_params: A dict that has all the invalid values.
224
225 Returns:
226 A list of invalid configurations generated based on the valid
227 configurations. Each invalid configuration has a different invalid
228 field.
229 """
230 results = []
231 for c in configs:
232 for k, v in neg_params.items():
233 # Skip negative test for TLS's identity field since it's not
234 # used for auth.
235 if c[Ent.EAP] == EAP.TLS and k == Ent.IDENTITY:
236 continue
237 if k in c:
238 nc = dict(c)
239 nc[k] = v
240 nc["invalid_field"] = k
241 results.append(nc)
242 return results
243
244 def gen_negative_eap_configs(self):
245 """Generates invalid configurations for different EAP authentication
246 types.
247
248 For all the valid EAP configurations, if a param that is part of the
249 authentication info exists in a config, a copy of the config is made
250 with an invalid value of the param.
251
252 Returns:
253 A list of dicts each representing an invalid EAP configuration.
254 """
255 neg_params = {
256 Ent.CLIENT_CERT: self.invalid_client_cert,
257 Ent.CA_CERT: self.invalid_ca_cert,
258 Ent.PRIVATE_KEY_ID: self.invalid_client_key,
259 Ent.IDENTITY: "fake_identity",
260 Ent.PASSWORD: "wrong_password"
261 }
262 configs = self.gen_eap_configs()
263 return self.gen_negative_configs(configs, neg_params)
264
265 def gen_negative_passpoint_configs(self):
266 """Generates invalid configurations for different EAP authentication
267 types with passpoint support.
268
269 Returns:
270 A list of dicts each representing an invalid EAP configuration
271 with passpoint fields.
272 """
273 neg_params = {
274 Ent.CLIENT_CERT: self.invalid_client_cert,
275 Ent.CA_CERT: self.invalid_ca_cert,
276 Ent.PRIVATE_KEY_ID: self.invalid_client_key,
277 Ent.IDENTITY: "fake_identity",
278 Ent.PASSWORD: "wrong_password",
279 Ent.FQDN: "fake_fqdn",
280 Ent.REALM: "where_no_one_has_gone_before",
281 Ent.PLMN: "fake_plmn",
282 Ent.ROAMING_IDS: [1234567890, 9876543210]
283 }
284 configs = self.gen_passpoint_configs()
285 return self.gen_negative_configs(configs, neg_params)
286
287 def gen_eap_test_name(self, config, ad):
288 """Generates a test case name based on an EAP configuration.
289
290 Args:
291 config: A dict representing an EAP credential.
292 ad: Discarded. This is here because name function signature needs
293 to be consistent with logic function signature for generated
294 test cases.
295
296 Returns:
297 A string representing the name of a generated EAP test case.
298 """
Ang Li82522812016-06-02 13:57:21 -0700299 eap_name = config[Ent.EAP].name
300 if "peap0" in config[WifiEnums.SSID_KEY].lower():
301 eap_name = "PEAP0"
302 if "peap1" in config[WifiEnums.SSID_KEY].lower():
303 eap_name = "PEAP1"
304 name = "test_connect-%s" % eap_name
Ang Li73697b32015-12-03 00:41:53 +0000305 if Ent.PHASE2 in config:
306 name += "-{}".format(config[Ent.PHASE2].name)
307 return name
308
Roshan Pius58916a32016-06-16 16:26:44 -0700309 def gen_eap_test_name_for_config_store(self, config, ad):
310 """Generates a test case name based on an EAP configuration for config
311 store tests.
312
313 Args:
314 config: A dict representing an EAP credential.
315 ad: Discarded. This is here because name function signature needs
316 to be consistent with logic function signature for generated
317 test cases.
318
319 Returns:
320 A string representing the name of a generated EAP test case.
321 """
322 return self.gen_eap_test_name(config, ad) + "-config_store"
323
Ang Li73697b32015-12-03 00:41:53 +0000324 def gen_passpoint_test_name(self, config, ad):
325 """Generates a test case name based on an EAP passpoint configuration.
326
327 Args:
328 config: A dict representing an EAP passpoint credential.
329 ad: Discarded. This is here because name function signature needs
330 to be consistent with logic function signature for generated
331 test cases.
332
333 Returns:
334 A string representing the name of a generated EAP passpoint connect
335 test case.
336 """
337 name = self.gen_eap_test_name(config, ad)
338 name = name.replace("connect", "passpoint_connect")
339 return name
340
Roshan Pius58916a32016-06-16 16:26:44 -0700341 def gen_passpoint_test_name_for_config_store(self, config, ad):
342 """Generates a test case name based on an EAP passpoint configuration
343 for config store tests.
344
345 Args:
346 config: A dict representing an EAP passpoint credential.
347 ad: Discarded. This is here because name function signature needs
348 to be consistent with logic function signature for generated
349 test cases.
350
351 Returns:
352 A string representing the name of a generated EAP passpoint connect
353 test case.
354 """
355 return self.gen_passpoint_test_name(config, ad) + "-config_store"
356
357 def eap_connect_toggle_wifi(self,
358 config,
359 *args):
360 """Connects to an enterprise network, toggles wifi state and ensures
361 that the device reconnects.
362
363 This logic expect the enterprise network to have Internet access.
364
365 Args:
366 config: A dict representing a wifi enterprise configuration.
367 args: args to be passed to |wutils.eap_connect|.
368
369 Returns:
370 True if the connection is successful and Internet access works.
371 """
Roshan Pius58916a32016-06-16 16:26:44 -0700372 ad = args[0]
Bindu Mahadev50374df2017-01-04 11:03:32 -0800373 wutils.wifi_connect(ad, config)
374 wutils.toggle_wifi_and_wait_for_reconnection(ad, config, num_of_tries=5)
Roshan Pius58916a32016-06-16 16:26:44 -0700375
Ang Li73697b32015-12-03 00:41:53 +0000376 """Tests"""
Ang Li81549052016-06-09 18:51:14 -0700377
Ang Li82522812016-06-02 13:57:21 -0700378 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000379 def test_eap_connect(self):
380 """Test connecting to enterprise networks of different authentication
381 types.
382
383 The authentication types tested are:
384 EAP-TLS
385 EAP-PEAP with different phase2 types.
386 EAP-TTLS with different phase2 types.
387
388 Procedures:
389 For each enterprise wifi network
390 1. Connect to the network.
391 2. Send a GET request to a website and check response.
392
393 Expect:
394 Successful connection and Internet access through the enterprise
395 networks.
396 """
397 eap_configs = self.gen_eap_configs()
Ang Li81549052016-06-09 18:51:14 -0700398 self.log.info("Testing %d different configs.", len(eap_configs))
Ang Li8e767182015-12-09 17:29:24 -0800399 random.shuffle(eap_configs)
Bindu Mahadev50374df2017-01-04 11:03:32 -0800400 failed = self.run_generated_testcases(wutils.wifi_connect,
Ang Li81549052016-06-09 18:51:14 -0700401 eap_configs,
402 args=(self.dut, ),
Bindu Mahadev50374df2017-01-04 11:03:32 -0800403 name_func=self.gen_eap_test_name,
404 format_args=True)
Ang Li81549052016-06-09 18:51:14 -0700405 asserts.assert_equal(
406 len(failed), 0, "The following configs failed EAP connect test: %s"
407 % pprint.pformat(failed))
Ang Li73697b32015-12-03 00:41:53 +0000408
Ang Li82522812016-06-02 13:57:21 -0700409 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000410 def test_eap_connect_negative(self):
411 """Test connecting to enterprise networks.
412
413 Procedures:
414 For each enterprise wifi network
415 1. Connect to the network with invalid credentials.
416
417 Expect:
418 Fail to establish connection.
419 """
420 neg_eap_configs = self.gen_negative_eap_configs()
Ang Li81549052016-06-09 18:51:14 -0700421 self.log.info("Testing %d different configs.", len(neg_eap_configs))
Ang Li8e767182015-12-09 17:29:24 -0800422 random.shuffle(neg_eap_configs)
Ang Li81549052016-06-09 18:51:14 -0700423
Ang Li73697b32015-12-03 00:41:53 +0000424 def name_gen(config, ad):
425 name = self.gen_eap_test_name(config, ad)
426 name += "-with_wrong-{}".format(config["invalid_field"])
427 return name
Ang Li81549052016-06-09 18:51:14 -0700428
429 failed = self.run_generated_testcases(self.eap_negative_connect_logic,
430 neg_eap_configs,
431 args=(self.dut, ),
432 name_func=name_gen)
Ang Li73697b32015-12-03 00:41:53 +0000433 msg = ("The following configs failed negative EAP connect test: %s" %
434 pprint.pformat(failed))
Ang Li82522812016-06-02 13:57:21 -0700435 asserts.assert_equal(len(failed), 0, msg)
Ang Li73697b32015-12-03 00:41:53 +0000436
Ang Li82522812016-06-02 13:57:21 -0700437 @signals.generated_test
Roshan Pius58916a32016-06-16 16:26:44 -0700438 def test_eap_connect_config_store(self):
439 """Test connecting to enterprise networks of different authentication
440 types after wifi toggle.
441
442 The authentication types tested are:
443 EAP-TLS
444 EAP-PEAP with different phase2 types.
445 EAP-TTLS with different phase2 types.
446
447 Procedures:
448 For each enterprise wifi network
449 1. Connect to the network.
450 2. Send a GET request to a website and check response.
451 3. Toggle wifi.
452 4. Ensure that the device reconnects to the same network.
453
454 Expect:
455 Successful connection and Internet access through the enterprise
456 networks.
457 """
458 eap_configs = self.gen_eap_configs()
459 self.log.info("Testing %d different configs.", len(eap_configs))
460 random.shuffle(eap_configs)
461 failed = self.run_generated_testcases(
462 self.eap_connect_toggle_wifi,
463 eap_configs,
464 args=(self.dut, ),
465 name_func=self.gen_eap_test_name_for_config_store)
466 asserts.assert_equal(
467 len(failed), 0, "The following configs failed EAP connect test: %s"
468 % pprint.pformat(failed))
469
470 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000471 def test_passpoint_connect(self):
472 """Test connecting to enterprise networks of different authentication
473 types with passpoint support.
474
475 The authentication types tested are:
476 EAP-TLS
477 EAP-TTLS with MSCHAPV2 as phase2.
478
479 Procedures:
480 For each enterprise wifi network
481 1. Connect to the network.
482 2. Send a GET request to a website and check response.
483
484 Expect:
485 Successful connection and Internet access through the enterprise
486 networks with passpoint support.
487 """
Ang Lic2d45212016-03-10 18:38:53 -0800488 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
Ang Li81549052016-06-09 18:51:14 -0700489 "Passpoint is not supported on device %s" %
490 self.dut.model)
Ang Li73697b32015-12-03 00:41:53 +0000491 passpoint_configs = self.gen_passpoint_configs()
Ang Li81549052016-06-09 18:51:14 -0700492 self.log.info("Testing %d different configs.", len(passpoint_configs))
Ang Li8e767182015-12-09 17:29:24 -0800493 random.shuffle(passpoint_configs)
Ang Li73697b32015-12-03 00:41:53 +0000494 failed = self.run_generated_testcases(
Bindu Mahadev50374df2017-01-04 11:03:32 -0800495 wutils.wifi_connect,
496 passpoint_configs,
497 args=(self.dut, ),
498 name_func=self.gen_passpoint_test_name,
499 format_args=True)
Ang Li81549052016-06-09 18:51:14 -0700500 asserts.assert_equal(
501 len(failed), 0,
502 "The following configs failed passpoint connect test: %s" %
503 pprint.pformat(failed))
Ang Li73697b32015-12-03 00:41:53 +0000504
Ang Li82522812016-06-02 13:57:21 -0700505 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000506 def test_passpoint_connect_negative(self):
507 """Test connecting to enterprise networks.
508
509 Procedures:
510 For each enterprise wifi network
511 1. Connect to the network with invalid credentials.
512
513 Expect:
514 Fail to establish connection.
515 """
Ang Lic2d45212016-03-10 18:38:53 -0800516 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
Ang Li81549052016-06-09 18:51:14 -0700517 "Passpoint is not supported on device %s" %
518 self.dut.model)
Ang Li73697b32015-12-03 00:41:53 +0000519 neg_passpoint_configs = self.gen_negative_passpoint_configs()
Ang Li81549052016-06-09 18:51:14 -0700520 self.log.info("Testing %d different configs.",
521 len(neg_passpoint_configs))
Ang Li8e767182015-12-09 17:29:24 -0800522 random.shuffle(neg_passpoint_configs)
Ang Li81549052016-06-09 18:51:14 -0700523
Ang Li73697b32015-12-03 00:41:53 +0000524 def name_gen(config, ad):
525 name = self.gen_passpoint_test_name(config, ad)
526 name += "-with_wrong-{}".format(config["invalid_field"])
527 return name
Ang Li81549052016-06-09 18:51:14 -0700528
529 failed = self.run_generated_testcases(self.eap_negative_connect_logic,
530 neg_passpoint_configs,
531 args=(self.dut, ),
532 name_func=name_gen)
533 asserts.assert_equal(
534 len(failed), 0,
535 "The following configs failed negative passpoint connect test: %s"
536 % pprint.pformat(failed))
Roshan Pius58916a32016-06-16 16:26:44 -0700537
538 @signals.generated_test
539 def test_passpoint_connect_config_store(self):
540 """Test connecting to enterprise networks of different authentication
541 types with passpoint support after wifi toggle.
542
543 The authentication types tested are:
544 EAP-TLS
545 EAP-TTLS with MSCHAPV2 as phase2.
546
547 Procedures:
548 For each enterprise wifi network
549 1. Connect to the network.
550 2. Send a GET request to a website and check response.
551 3. Toggle wifi.
552 4. Ensure that the device reconnects to the same network.
553
554 Expect:
555 Successful connection and Internet access through the enterprise
556 networks with passpoint support.
557 """
558 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
559 "Passpoint is not supported on device %s" %
560 self.dut.model)
561 passpoint_configs = self.gen_passpoint_configs()
562 self.log.info("Testing %d different configs.", len(passpoint_configs))
563 random.shuffle(passpoint_configs)
564 failed = self.run_generated_testcases(
565 self.eap_connect_toggle_wifi,
566 passpoint_configs,
567 args=(self.dut, ),
568 name_func=self.gen_passpoint_test_name_for_config_store)
569 asserts.assert_equal(
570 len(failed), 0,
571 "The following configs failed passpoint connect test: %s" %
572 pprint.pformat(failed))