Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: chrome/browser/policy/test/policy_testserver.py

Issue 1727413002: Reland: No longer start up profile if there was an error fetching policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium 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 """A bare-bones test server for testing cloud policy support. 5 """A bare-bones test server for testing cloud policy support.
6 6
7 This implements a simple cloud policy test server that can be used to test 7 This implements a simple cloud policy test server that can be used to test
8 chrome's device management service client. The policy information is read from 8 chrome's device management service client. The policy information is read from
9 the file named device_management in the server's data directory. It contains 9 the file named device_management in the server's data directory. It contains
10 enforced and recommended policies for the device and user scope, and a list 10 enforced and recommended policies for the device and user scope, and a list
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 Returns: 370 Returns:
371 A tuple of HTTP status code and response data to send to the client. 371 A tuple of HTTP status code and response data to send to the client.
372 """ 372 """
373 # Check the auth token and device ID. 373 # Check the auth token and device ID.
374 auth = self.CheckGoogleLogin() 374 auth = self.CheckGoogleLogin()
375 if not auth: 375 if not auth:
376 return (403, 'No authorization') 376 return (403, 'No authorization')
377 377
378 policy = self.server.GetPolicies() 378 policy = self.server.GetPolicies()
379 if ('managed_users' not in policy):
380 return (500, 'error in config - no managed users')
379 username = self.server.ResolveUser(auth) 381 username = self.server.ResolveUser(auth)
380 if ('*' not in policy['managed_users'] and 382 if ('*' not in policy['managed_users'] and
381 username not in policy['managed_users']): 383 username not in policy['managed_users']):
382 return (403, 'Unmanaged') 384 return (403, 'Unmanaged')
383 385
384 device_id = self.GetUniqueParam('deviceid') 386 device_id = self.GetUniqueParam('deviceid')
385 if not device_id: 387 if not device_id:
386 return (400, 'Missing device identifier') 388 return (400, 'Missing device identifier')
387 389
388 token_info = self.server.RegisterDevice( 390 token_info = self.server.RegisterDevice(
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 985
984 # Load client state. 986 # Load client state.
985 if self.client_state_file is not None: 987 if self.client_state_file is not None:
986 try: 988 try:
987 file_contents = open(self.client_state_file).read() 989 file_contents = open(self.client_state_file).read()
988 self._registered_tokens = json.loads(file_contents, strict=False) 990 self._registered_tokens = json.loads(file_contents, strict=False)
989 except IOError: 991 except IOError:
990 pass 992 pass
991 993
992 def GetPolicies(self): 994 def GetPolicies(self):
993 """Returns the policies to be used, reloaded form the backend file every 995 """Returns the policies to be used, reloaded from the backend file every
994 time this is called. 996 time this is called.
995 """ 997 """
996 policy = {} 998 policy = {}
997 if json is None: 999 if json is None:
998 logging.error('No JSON module, cannot parse policy information') 1000 logging.error('No JSON module, cannot parse policy information')
999 else : 1001 else :
1000 try: 1002 try:
1001 policy = json.loads(open(self.policy_path).read(), strict=False) 1003 policy = json.loads(open(self.policy_path).read(), strict=False)
1002 except IOError: 1004 except IOError:
1003 logging.error('Failed to load policies from %s' % self.policy_path) 1005 logging.error('Failed to load policies from %s' % self.policy_path)
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 if (self.options.log_to_console): 1315 if (self.options.log_to_console):
1314 logger.addHandler(logging.StreamHandler()) 1316 logger.addHandler(logging.StreamHandler())
1315 if (self.options.log_file): 1317 if (self.options.log_file):
1316 logger.addHandler(logging.FileHandler(self.options.log_file)) 1318 logger.addHandler(logging.FileHandler(self.options.log_file))
1317 1319
1318 testserver_base.TestServerRunner.run_server(self) 1320 testserver_base.TestServerRunner.run_server(self)
1319 1321
1320 1322
1321 if __name__ == '__main__': 1323 if __name__ == '__main__':
1322 sys.exit(PolicyServerRunner().main()) 1324 sys.exit(PolicyServerRunner().main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698