Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import common, fnmatch, logging, os, re, string, threading, time | 5 import common, fnmatch, logging, os, re, string, threading, time |
| 6 | 6 |
| 7 from autotest_lib.server import autotest, hosts, subcommand | 7 from autotest_lib.server import autotest, hosts, subcommand |
| 8 from autotest_lib.server import site_bsd_router | 8 from autotest_lib.server import site_bsd_router |
| 9 from autotest_lib.server import site_linux_router | 9 from autotest_lib.server import site_linux_router |
| 10 from autotest_lib.server import site_host_attributes | 10 from autotest_lib.server import site_host_attributes |
| 11 from autotest_lib.server import site_eap_tls | |
| 12 from autotest_lib.server import test | 11 from autotest_lib.server import test |
| 12 from autotest_lib.server.site_eap_certs import * | |
|
Paul Stewart
2011/01/13 01:56:06
I'd prefer if you didn't do "import *" here, and r
| |
| 13 from autotest_lib.client.common_lib import error | 13 from autotest_lib.client.common_lib import error |
| 14 | 14 |
| 15 class NotImplemented(Exception): | 15 class NotImplemented(Exception): |
| 16 def __init__(self, what): | 16 def __init__(self, what): |
| 17 self.what = what | 17 self.what = what |
| 18 | 18 |
| 19 | 19 |
| 20 def __str__(self): | 20 def __str__(self): |
| 21 return repr("Test method '%s' not implemented" % self.what) | 21 return repr("Test method '%s' not implemented" % self.what) |
| 22 | 22 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 script_client_dir = self.client.get_tmp_dir() | 311 script_client_dir = self.client.get_tmp_dir() |
| 312 script_client_file = os.path.join(script_client_dir, script_name) | 312 script_client_file = os.path.join(script_client_dir, script_name) |
| 313 for copy_file in [script_name] + list(support_scripts): | 313 for copy_file in [script_name] + list(support_scripts): |
| 314 src_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), | 314 src_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
| 315 copy_file) | 315 copy_file) |
| 316 dest_file = os.path.join(script_client_dir, | 316 dest_file = os.path.join(script_client_dir, |
| 317 os.path.basename(src_file)) | 317 os.path.basename(src_file)) |
| 318 self.client.send_file(src_file, dest_file, delete_dest=True) | 318 self.client.send_file(src_file, dest_file, delete_dest=True) |
| 319 self.client_installed_scripts[script_name] = script_client_file | 319 self.client_installed_scripts[script_name] = script_client_file |
| 320 return script_client_file | 320 return script_client_file |
| 321 | 321 |
|
Paul Stewart
2011/01/13 01:56:06
It doesn't make sense to copy this function here a
| |
| 322 def insert_file(self, host, filename, contents): | |
| 323 """ | |
| 324 If config files are too big, the "host.run()" never returns. | |
| 325 As a workaround, break the file up into lines and append the | |
| 326 file piece by piece | |
| 327 """ | |
| 328 host.run('rm -f %s >/dev/null 2>&1' % filename, ignore_status=True) | |
| 329 content_lines = contents.splitlines() | |
| 330 while content_lines: | |
| 331 buflist = [] | |
| 332 buflen = 0 | |
| 333 while content_lines and buflen + len(content_lines[0]) < 200: | |
| 334 line = content_lines.pop(0) | |
| 335 buflen += len(line) + 1 | |
| 336 buflist.append(line) | |
| 337 | |
| 338 if not buflist: | |
| 339 raise error.TestFail('Cert profile: line too long: %s' % | |
| 340 content_lines[0]) | |
| 341 host.run('cat <<EOF >>%s\n%s\nEOF\n' % | |
| 342 (filename, '\n'.join(buflist))) | |
| 343 | |
| 322 | 344 |
| 323 def connect(self, params): | 345 def connect(self, params): |
| 324 """ Connect client to AP/router """ | 346 """ Connect client to AP/router """ |
| 325 | 347 |
| 326 script_client_file = self.install_script('site_wlan_connect.py', | 348 script_client_file = self.install_script('site_wlan_connect.py', |
| 327 'site_wlan_wait_state.py') | 349 'site_wlan_wait_state.py') |
| 328 if 'eap-tls' in params: | 350 if 'files' in params: |
|
Paul Stewart
2011/01/13 01:56:06
Instead of having this as a parameter to "connect"
| |
| 329 params.update(site_eap_tls.client_config(self.client, | 351 for name,contents in params['files'].iteritems(): |
| 330 params['eap-tls'], | 352 self.insert_file(self.client, name, contents) |
| 331 params.get('server-auth', | |
| 332 None))) | |
| 333 | 353 |
| 334 flags = [] | 354 flags = [] |
| 335 if params.get('debug', True): | 355 if params.get('debug', True): |
| 336 flags.append('--debug') | 356 flags.append('--debug') |
| 337 if params.get('hidden', False): | 357 if params.get('hidden', False): |
| 338 flags.append('--hidden') | 358 flags.append('--hidden') |
| 339 | 359 |
| 340 result = self.client.run('python "%s" %s "%s" "%s" "%s" "%d" "%d"' % | 360 result = self.client.run('python "%s" %s "%s" "%s" "%s" "%d" "%d"' % |
| 341 (script_client_file, | 361 (script_client_file, |
| 342 ' '.join(flags), | 362 ' '.join(flags), |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1142 except error.TestFail: | 1162 except error.TestFail: |
| 1143 if 'expect_failure' in testcase: | 1163 if 'expect_failure' in testcase: |
| 1144 self.expect_failure(name, testcase['expect_failure']) | 1164 self.expect_failure(name, testcase['expect_failure']) |
| 1145 else: | 1165 else: |
| 1146 raise | 1166 raise |
| 1147 except Exception, e: | 1167 except Exception, e: |
| 1148 if 'expect_failure' in testcase: | 1168 if 'expect_failure' in testcase: |
| 1149 self.expect_failure(name, testcase['expect_failure']) | 1169 self.expect_failure(name, testcase['expect_failure']) |
| 1150 else: | 1170 else: |
| 1151 raise | 1171 raise |
| OLD | NEW |