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

Unified Diff: chrome/browser/policy/test/policy_testserver.py

Issue 233423002: Don't upload extension IDs in the cloud policy protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos clang build Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/test/policy_testserver.py
diff --git a/chrome/browser/policy/test/policy_testserver.py b/chrome/browser/policy/test/policy_testserver.py
index 13b98f97ae27f54106f1726095a26aa721874be8..8998d7fd77419db7c7aaa553d11fd5a57546ca74 100644
--- a/chrome/browser/policy/test/policy_testserver.py
+++ b/chrome/browser/policy/test/policy_testserver.py
@@ -57,6 +57,7 @@ Example:
import base64
import BaseHTTPServer
import cgi
+import glob
import google.protobuf.text_format
import hashlib
import logging
@@ -463,6 +464,22 @@ class PolicyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
fetch_response.error_code = 400
fetch_response.error_message = 'Invalid policy_type'
+ # Send additional PolicyFetchResponses for each extension that has
+ # configuration data, if the main request had a single user policy request.
+ if (len(msg.policy_request.request) == 1 and
+ msg.policy_request.request[0].policy_type in ('google/chromeos/user',
+ 'google/chrome/user')):
Mattias Nissler (ping if slow) 2014/04/24 12:20:36 Wouldn't the correct implementation be to check wh
Joao da Silva 2014/04/24 13:22:24 I'm not sure. Since we don't send PolicyFetchReque
Mattias Nissler (ping if slow) 2014/04/24 13:38:25 IIUC, the only parameter you rely on from the poli
+ ids = self.server.ListMatchingComponents('google/chrome/extension')
+ for settings_entity_id in ids:
+ fake_request = dm.PolicyFetchRequest()
+ # Copy the user policy request, to trigger the same signature type
+ # in the response.
Mattias Nissler (ping if slow) 2014/04/24 12:20:36 Regarding signatures, have you thought about what
Joao da Silva 2014/04/24 13:22:24 Correct, we don't do rotations for extension polic
Mattias Nissler (ping if slow) 2014/04/24 13:38:25 Ah, so this was a bit surprising to me - we do req
+ fake_request.CopyFrom(msg.policy_request.request[0])
+ fake_request.policy_type = 'google/chrome/extension'
+ fake_request.settings_entity_id = settings_entity_id
+ fetch_response = response.policy_response.response.add()
+ self.ProcessCloudPolicy(fake_request, token_info, fetch_response)
+
return (200, response)
def ProcessAutoEnrollment(self, msg):
@@ -1056,6 +1073,22 @@ class PolicyTestServer(testserver_base.BrokenPipeHandlerMixIn,
return os.path.join(self.data_dir or '',
'policy_%s' % sanitized_policy_selector)
+ def ListMatchingComponents(self, policy_type):
+ """Returns a list of settings entity id that have a configuration file.
Mattias Nissler (ping if slow) 2014/04/24 12:20:36 IDs (consistent with spelling below)
Joao da Silva 2014/04/24 13:22:24 Done.
+
+ Args:
+ policy_type: the policy type to look for. Only settings entity IDs for
+ file selectors that match this policy_type will be returned.
+
+ Returns:
+ A list of settings entity ID for the given |policy_type| that have a
Mattias Nissler (ping if slow) 2014/04/24 12:20:36 IDs
Joao da Silva 2014/04/24 13:22:24 Done.
+ configuration file in this server (either as a .bin, .txt or .data file).
+ """
+ base_name = self.GetBaseFilename(policy_type)
+ files = glob.glob('%s_*.*' % base_name)
+ len_base_name = len(base_name) + 1
+ return [ x[len_base_name:x.rfind('.')] for x in files ]
Mattias Nissler (ping if slow) 2014/04/24 12:20:36 s/x/file/
Joao da Silva 2014/04/24 13:22:24 Done.
+
def ReadPolicyFromDataDir(self, policy_selector, proto_message):
"""Tries to read policy payload from a file in the data directory.

Powered by Google App Engine
This is Rietveld 408576698