blob: 98caaf236df0f7989b668dcc8953517aa1508425 [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 = {
Girish Moturu150d32f2017-02-14 12:27:07 -080062 Ent.EAP: int(EAP.PEAP),
Ang Li73697b32015-12-03 00:41:53 +000063 Ent.CA_CERT: self.ca_cert,
64 Ent.IDENTITY: self.eap_identity,
65 Ent.PASSWORD: self.eap_password,
Girish Moturu150d32f2017-02-14 12:27:07 -080066 Ent.PHASE2: int(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 = {
Girish Moturu150d32f2017-02-14 12:27:07 -080072 Ent.EAP: int(EAP.TLS),
Ang Li73697b32015-12-03 00:41:53 +000073 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 = {
Girish Moturu150d32f2017-02-14 12:27:07 -080080 Ent.EAP: int(EAP.TTLS),
Ang Li73697b32015-12-03 00:41:53 +000081 Ent.CA_CERT: self.ca_cert,
82 Ent.IDENTITY: self.eap_identity,
83 Ent.PASSWORD: self.eap_password,
Girish Moturu150d32f2017-02-14 12:27:07 -080084 Ent.PHASE2: int(EapPhase2.MSCHAPV2),
Ang Li73697b32015-12-03 00:41:53 +000085 WifiEnums.SSID_KEY: self.ssid_ttls
86 }
Ang Li82522812016-06-02 13:57:21 -070087 self.config_pwd = {
Girish Moturu150d32f2017-02-14 12:27:07 -080088 Ent.EAP: int(EAP.PWD),
Ang Li82522812016-06-02 13:57:21 -070089 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 = {
Girish Moturu150d32f2017-02-14 12:27:07 -080094 Ent.EAP: int(EAP.SIM),
Ang Li73697b32015-12-03 00:41:53 +000095 WifiEnums.SSID_KEY: self.ssid_sim,
96 }
Ang Li82522812016-06-02 13:57:21 -070097 self.config_aka = {
Girish Moturu150d32f2017-02-14 12:27:07 -080098 Ent.EAP: int(EAP.AKA),
Ang Li82522812016-06-02 13:57:21 -070099 WifiEnums.SSID_KEY: self.ssid_aka,
100 }
101 self.config_aka_prime = {
Girish Moturu150d32f2017-02-14 12:27:07 -0800102 Ent.EAP: int(EAP.AKA_PRIME),
Ang Li82522812016-06-02 13:57:21 -0700103 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)
Girish Moturu150d32f2017-02-14 12:27:07 -0800184 c[Ent.PHASE2] = phase2_type.value
Ang Li73697b32015-12-03 00:41:53 +0000185 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
Roshan Pius58916a32016-06-16 16:26:44 -0700287 def gen_eap_test_name_for_config_store(self, config, ad):
288 """Generates a test case name based on an EAP configuration for config
289 store tests.
290
291 Args:
292 config: A dict representing an EAP credential.
293 ad: Discarded. This is here because name function signature needs
294 to be consistent with logic function signature for generated
295 test cases.
296
297 Returns:
298 A string representing the name of a generated EAP test case.
299 """
Girish Moturu150d32f2017-02-14 12:27:07 -0800300 return wutils.generate_eap_test_name(config) + "-config_store"
Roshan Pius58916a32016-06-16 16:26:44 -0700301
Ang Li73697b32015-12-03 00:41:53 +0000302 def gen_passpoint_test_name(self, config, ad):
303 """Generates a test case name based on an EAP passpoint configuration.
304
305 Args:
306 config: A dict representing an EAP passpoint credential.
307 ad: Discarded. This is here because name function signature needs
308 to be consistent with logic function signature for generated
309 test cases.
310
311 Returns:
312 A string representing the name of a generated EAP passpoint connect
313 test case.
314 """
Girish Moturu150d32f2017-02-14 12:27:07 -0800315 name = wutils.generate_eap_test_name(config)
Ang Li73697b32015-12-03 00:41:53 +0000316 name = name.replace("connect", "passpoint_connect")
317 return name
318
Roshan Pius58916a32016-06-16 16:26:44 -0700319 def gen_passpoint_test_name_for_config_store(self, config, ad):
320 """Generates a test case name based on an EAP passpoint configuration
321 for config store tests.
322
323 Args:
324 config: A dict representing an EAP passpoint credential.
325 ad: Discarded. This is here because name function signature needs
326 to be consistent with logic function signature for generated
327 test cases.
328
329 Returns:
330 A string representing the name of a generated EAP passpoint connect
331 test case.
332 """
333 return self.gen_passpoint_test_name(config, ad) + "-config_store"
334
335 def eap_connect_toggle_wifi(self,
336 config,
337 *args):
338 """Connects to an enterprise network, toggles wifi state and ensures
339 that the device reconnects.
340
341 This logic expect the enterprise network to have Internet access.
342
343 Args:
344 config: A dict representing a wifi enterprise configuration.
345 args: args to be passed to |wutils.eap_connect|.
346
347 Returns:
348 True if the connection is successful and Internet access works.
349 """
Roshan Pius58916a32016-06-16 16:26:44 -0700350 ad = args[0]
Bindu Mahadev50374df2017-01-04 11:03:32 -0800351 wutils.wifi_connect(ad, config)
352 wutils.toggle_wifi_and_wait_for_reconnection(ad, config, num_of_tries=5)
Roshan Pius58916a32016-06-16 16:26:44 -0700353
Ang Li73697b32015-12-03 00:41:53 +0000354 """Tests"""
Ang Li81549052016-06-09 18:51:14 -0700355
Ang Li82522812016-06-02 13:57:21 -0700356 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000357 def test_eap_connect(self):
358 """Test connecting to enterprise networks of different authentication
359 types.
360
361 The authentication types tested are:
362 EAP-TLS
363 EAP-PEAP with different phase2 types.
364 EAP-TTLS with different phase2 types.
365
366 Procedures:
367 For each enterprise wifi network
368 1. Connect to the network.
369 2. Send a GET request to a website and check response.
370
371 Expect:
372 Successful connection and Internet access through the enterprise
373 networks.
374 """
375 eap_configs = self.gen_eap_configs()
Ang Li81549052016-06-09 18:51:14 -0700376 self.log.info("Testing %d different configs.", len(eap_configs))
Ang Li8e767182015-12-09 17:29:24 -0800377 random.shuffle(eap_configs)
Bindu Mahadev50374df2017-01-04 11:03:32 -0800378 failed = self.run_generated_testcases(wutils.wifi_connect,
Ang Li81549052016-06-09 18:51:14 -0700379 eap_configs,
380 args=(self.dut, ),
Girish Moturu150d32f2017-02-14 12:27:07 -0800381 name_func=wutils.generate_eap_test_name,
Bindu Mahadev50374df2017-01-04 11:03:32 -0800382 format_args=True)
Ang Li81549052016-06-09 18:51:14 -0700383 asserts.assert_equal(
384 len(failed), 0, "The following configs failed EAP connect test: %s"
385 % pprint.pformat(failed))
Ang Li73697b32015-12-03 00:41:53 +0000386
Ang Li82522812016-06-02 13:57:21 -0700387 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000388 def test_eap_connect_negative(self):
389 """Test connecting to enterprise networks.
390
391 Procedures:
392 For each enterprise wifi network
393 1. Connect to the network with invalid credentials.
394
395 Expect:
396 Fail to establish connection.
397 """
398 neg_eap_configs = self.gen_negative_eap_configs()
Ang Li81549052016-06-09 18:51:14 -0700399 self.log.info("Testing %d different configs.", len(neg_eap_configs))
Ang Li8e767182015-12-09 17:29:24 -0800400 random.shuffle(neg_eap_configs)
Ang Li81549052016-06-09 18:51:14 -0700401
Ang Li73697b32015-12-03 00:41:53 +0000402 def name_gen(config, ad):
Girish Moturu150d32f2017-02-14 12:27:07 -0800403 name = wutils.generate_eap_test_name(config)
Ang Li73697b32015-12-03 00:41:53 +0000404 name += "-with_wrong-{}".format(config["invalid_field"])
405 return name
Ang Li81549052016-06-09 18:51:14 -0700406
407 failed = self.run_generated_testcases(self.eap_negative_connect_logic,
408 neg_eap_configs,
409 args=(self.dut, ),
410 name_func=name_gen)
Ang Li73697b32015-12-03 00:41:53 +0000411 msg = ("The following configs failed negative EAP connect test: %s" %
412 pprint.pformat(failed))
Ang Li82522812016-06-02 13:57:21 -0700413 asserts.assert_equal(len(failed), 0, msg)
Ang Li73697b32015-12-03 00:41:53 +0000414
Ang Li82522812016-06-02 13:57:21 -0700415 @signals.generated_test
Roshan Pius58916a32016-06-16 16:26:44 -0700416 def test_eap_connect_config_store(self):
417 """Test connecting to enterprise networks of different authentication
418 types after wifi toggle.
419
420 The authentication types tested are:
421 EAP-TLS
422 EAP-PEAP with different phase2 types.
423 EAP-TTLS with different phase2 types.
424
425 Procedures:
426 For each enterprise wifi network
427 1. Connect to the network.
428 2. Send a GET request to a website and check response.
429 3. Toggle wifi.
430 4. Ensure that the device reconnects to the same network.
431
432 Expect:
433 Successful connection and Internet access through the enterprise
434 networks.
435 """
436 eap_configs = self.gen_eap_configs()
437 self.log.info("Testing %d different configs.", len(eap_configs))
438 random.shuffle(eap_configs)
439 failed = self.run_generated_testcases(
440 self.eap_connect_toggle_wifi,
441 eap_configs,
442 args=(self.dut, ),
Girish Moturu150d32f2017-02-14 12:27:07 -0800443 name_func=wutils.generate_eap_test_name)
Roshan Pius58916a32016-06-16 16:26:44 -0700444 asserts.assert_equal(
445 len(failed), 0, "The following configs failed EAP connect test: %s"
446 % pprint.pformat(failed))
447
448 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000449 def test_passpoint_connect(self):
450 """Test connecting to enterprise networks of different authentication
451 types with passpoint support.
452
453 The authentication types tested are:
454 EAP-TLS
455 EAP-TTLS with MSCHAPV2 as phase2.
456
457 Procedures:
458 For each enterprise wifi network
459 1. Connect to the network.
460 2. Send a GET request to a website and check response.
461
462 Expect:
463 Successful connection and Internet access through the enterprise
464 networks with passpoint support.
465 """
Ang Lic2d45212016-03-10 18:38:53 -0800466 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
Ang Li81549052016-06-09 18:51:14 -0700467 "Passpoint is not supported on device %s" %
468 self.dut.model)
Ang Li73697b32015-12-03 00:41:53 +0000469 passpoint_configs = self.gen_passpoint_configs()
Ang Li81549052016-06-09 18:51:14 -0700470 self.log.info("Testing %d different configs.", len(passpoint_configs))
Ang Li8e767182015-12-09 17:29:24 -0800471 random.shuffle(passpoint_configs)
Ang Li73697b32015-12-03 00:41:53 +0000472 failed = self.run_generated_testcases(
Bindu Mahadev50374df2017-01-04 11:03:32 -0800473 wutils.wifi_connect,
474 passpoint_configs,
475 args=(self.dut, ),
476 name_func=self.gen_passpoint_test_name,
477 format_args=True)
Ang Li81549052016-06-09 18:51:14 -0700478 asserts.assert_equal(
479 len(failed), 0,
480 "The following configs failed passpoint connect test: %s" %
481 pprint.pformat(failed))
Ang Li73697b32015-12-03 00:41:53 +0000482
Ang Li82522812016-06-02 13:57:21 -0700483 @signals.generated_test
Ang Li73697b32015-12-03 00:41:53 +0000484 def test_passpoint_connect_negative(self):
485 """Test connecting to enterprise networks.
486
487 Procedures:
488 For each enterprise wifi network
489 1. Connect to the network with invalid credentials.
490
491 Expect:
492 Fail to establish connection.
493 """
Ang Lic2d45212016-03-10 18:38:53 -0800494 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
Ang Li81549052016-06-09 18:51:14 -0700495 "Passpoint is not supported on device %s" %
496 self.dut.model)
Ang Li73697b32015-12-03 00:41:53 +0000497 neg_passpoint_configs = self.gen_negative_passpoint_configs()
Ang Li81549052016-06-09 18:51:14 -0700498 self.log.info("Testing %d different configs.",
499 len(neg_passpoint_configs))
Ang Li8e767182015-12-09 17:29:24 -0800500 random.shuffle(neg_passpoint_configs)
Ang Li81549052016-06-09 18:51:14 -0700501
Ang Li73697b32015-12-03 00:41:53 +0000502 def name_gen(config, ad):
503 name = self.gen_passpoint_test_name(config, ad)
504 name += "-with_wrong-{}".format(config["invalid_field"])
505 return name
Ang Li81549052016-06-09 18:51:14 -0700506
507 failed = self.run_generated_testcases(self.eap_negative_connect_logic,
508 neg_passpoint_configs,
509 args=(self.dut, ),
510 name_func=name_gen)
511 asserts.assert_equal(
512 len(failed), 0,
513 "The following configs failed negative passpoint connect test: %s"
514 % pprint.pformat(failed))
Roshan Pius58916a32016-06-16 16:26:44 -0700515
516 @signals.generated_test
517 def test_passpoint_connect_config_store(self):
518 """Test connecting to enterprise networks of different authentication
519 types with passpoint support after wifi toggle.
520
521 The authentication types tested are:
522 EAP-TLS
523 EAP-TTLS with MSCHAPV2 as phase2.
524
525 Procedures:
526 For each enterprise wifi network
527 1. Connect to the network.
528 2. Send a GET request to a website and check response.
529 3. Toggle wifi.
530 4. Ensure that the device reconnects to the same network.
531
532 Expect:
533 Successful connection and Internet access through the enterprise
534 networks with passpoint support.
535 """
536 asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(),
537 "Passpoint is not supported on device %s" %
538 self.dut.model)
539 passpoint_configs = self.gen_passpoint_configs()
540 self.log.info("Testing %d different configs.", len(passpoint_configs))
541 random.shuffle(passpoint_configs)
542 failed = self.run_generated_testcases(
543 self.eap_connect_toggle_wifi,
544 passpoint_configs,
545 args=(self.dut, ),
546 name_func=self.gen_passpoint_test_name_for_config_store)
547 asserts.assert_equal(
548 len(failed), 0,
549 "The following configs failed passpoint connect test: %s" %
550 pprint.pformat(failed))