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 from autotest_lib.client.bin import chromeos_constants, site_login, site_ui_test | 5 from autotest_lib.client.bin import chromeos_constants, site_login, site_ui_test |
6 from autotest_lib.client.common_lib import error, site_auth_server | 6 from autotest_lib.client.common_lib import error, site_auth_server |
7 | 7 |
8 class login_BadAuthentication(site_ui_test.UITest): | 8 class login_BadAuthentication(site_ui_test.UITest): |
9 version = 1 | 9 version = 1 |
10 | 10 |
11 auto_login = False | 11 auto_login = False |
12 | 12 |
| 13 _errorString = None |
| 14 |
13 def __login_denier(self, handler, url_args): | 15 def __login_denier(self, handler, url_args): |
14 handler.send_response(403) | 16 handler.send_response(403) |
15 handler.end_headers() | 17 handler.end_headers() |
16 handler.wfile.write('Error=BadAuthentication.') | 18 handler.wfile.write(self._errorString) |
17 | 19 |
18 | 20 |
19 def start_authserver(self): | 21 def start_authserver(self): |
20 self._authServer = site_auth_server.GoogleAuthServer( | 22 self._authServer = site_auth_server.GoogleAuthServer( |
21 cl_responder=self.__login_denier) | 23 cl_responder=self.__login_denier) |
22 self._authServer.run() | 24 self._authServer.run() |
23 | 25 |
24 self.use_local_dns() | 26 self.use_local_dns() |
25 | 27 |
26 | 28 |
27 def run_once(self): | 29 def run_once(self, error_string='BadAuthentication'): |
| 30 self._errorString = "Error=" + error_string |
28 # TODO(cmasone): find better way to determine login has failed. | 31 # TODO(cmasone): find better way to determine login has failed. |
29 try: | 32 try: |
30 self.login(self.username, self.password) | 33 self.login(self.username, self.password) |
31 except site_login.TimeoutError: | 34 except site_login.TimeoutError: |
32 pass | 35 pass |
33 else: | 36 else: |
34 raise error.TestFail('Should not have logged in') | 37 raise error.TestFail('Should not have logged in') |
35 | 38 |
36 self._authServer.wait_for_client_login() | 39 self._authServer.wait_for_client_login() |
OLD | NEW |