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

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

Issue 1737453003: Revert of 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')
381 username = self.server.ResolveUser(auth) 379 username = self.server.ResolveUser(auth)
382 if ('*' not in policy['managed_users'] and 380 if ('*' not in policy['managed_users'] and
383 username not in policy['managed_users']): 381 username not in policy['managed_users']):
384 return (403, 'Unmanaged') 382 return (403, 'Unmanaged')
385 383
386 device_id = self.GetUniqueParam('deviceid') 384 device_id = self.GetUniqueParam('deviceid')
387 if not device_id: 385 if not device_id:
388 return (400, 'Missing device identifier') 386 return (400, 'Missing device identifier')
389 387
390 token_info = self.server.RegisterDevice( 388 token_info = self.server.RegisterDevice(
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 983
986 # Load client state. 984 # Load client state.
987 if self.client_state_file is not None: 985 if self.client_state_file is not None:
988 try: 986 try:
989 file_contents = open(self.client_state_file).read() 987 file_contents = open(self.client_state_file).read()
990 self._registered_tokens = json.loads(file_contents, strict=False) 988 self._registered_tokens = json.loads(file_contents, strict=False)
991 except IOError: 989 except IOError:
992 pass 990 pass
993 991
994 def GetPolicies(self): 992 def GetPolicies(self):
995 """Returns the policies to be used, reloaded from the backend file every 993 """Returns the policies to be used, reloaded form the backend file every
996 time this is called. 994 time this is called.
997 """ 995 """
998 policy = {} 996 policy = {}
999 if json is None: 997 if json is None:
1000 logging.error('No JSON module, cannot parse policy information') 998 logging.error('No JSON module, cannot parse policy information')
1001 else : 999 else :
1002 try: 1000 try:
1003 policy = json.loads(open(self.policy_path).read(), strict=False) 1001 policy = json.loads(open(self.policy_path).read(), strict=False)
1004 except IOError: 1002 except IOError:
1005 logging.error('Failed to load policies from %s' % self.policy_path) 1003 logging.error('Failed to load policies from %s' % self.policy_path)
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 if (self.options.log_to_console): 1313 if (self.options.log_to_console):
1316 logger.addHandler(logging.StreamHandler()) 1314 logger.addHandler(logging.StreamHandler())
1317 if (self.options.log_file): 1315 if (self.options.log_file):
1318 logger.addHandler(logging.FileHandler(self.options.log_file)) 1316 logger.addHandler(logging.FileHandler(self.options.log_file))
1319 1317
1320 testserver_base.TestServerRunner.run_server(self) 1318 testserver_base.TestServerRunner.run_server(self)
1321 1319
1322 1320
1323 if __name__ == '__main__': 1321 if __name__ == '__main__':
1324 sys.exit(PolicyServerRunner().main()) 1322 sys.exit(PolicyServerRunner().main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698