Index: net/tools/testserver/device_management.py |
diff --git a/net/tools/testserver/device_management.py b/net/tools/testserver/device_management.py |
index be503a4320fbdb04ebbbac21daaaccc795c38b31..6479d89b090ee9b15aaa49cfd1ddc97ee3c1893f 100644 |
--- a/net/tools/testserver/device_management.py |
+++ b/net/tools/testserver/device_management.py |
@@ -261,7 +261,9 @@ class RequestHandler(object): |
""" |
for request in msg.request: |
if (request.policy_type in |
- ('google/chromeos/user', 'google/chromeos/device')): |
+ ('google/chromeos/user', |
+ 'google/chromeos/device', |
+ 'google/chromeos/publicaccount')): |
if request_type != 'policy': |
return (400, 'Invalid request type') |
else: |
@@ -428,22 +430,24 @@ class RequestHandler(object): |
self._server.UpdateMachineId(token_info['device_token'], msg.machine_id) |
# Response is only given if the scope is specified in the config file. |
- # Normally 'google/chromeos/device' and 'google/chromeos/user' should be |
- # accepted. |
+ # Normally 'google/chromeos/device', 'google/chromeos/user' and |
+ # 'google/chromeos/publicaccount' should be accepted. |
policy = self._server.GetPolicies() |
policy_value = '' |
+ policy_type = msg.policy_type |
+ if msg.settings_entity_id: |
+ policy_type += '/' + msg.settings_entity_id |
bartfab (slow)
2012/12/03 12:28:40
Should we document that in order to set mock publi
Mattias Nissler (ping if slow)
2012/12/03 13:50:39
Added an example at the beginning of the file.
bartfab (slow)
2012/12/03 14:01:05
Thanks, that's excellent. I had completely missed
|
if (msg.policy_type in token_info['allowed_policy_types'] and |
- msg.policy_type in policy): |
+ policy_type in policy): |
if msg.policy_type == 'google/chromeos/user': |
settings = cp.CloudPolicySettings() |
- self.GatherUserPolicySettings(settings, |
- policy[msg.policy_type]) |
- policy_value = settings.SerializeToString() |
+ self.GatherUserPolicySettings(settings, policy[policy_type]) |
elif msg.policy_type == 'google/chromeos/device': |
settings = dp.ChromeDeviceSettingsProto() |
- self.GatherDevicePolicySettings(settings, |
- policy[msg.policy_type]) |
- policy_value = settings.SerializeToString() |
+ self.GatherDevicePolicySettings(settings, policy[policy_type]) |
+ elif msg.policy_type == 'google/chromeos/publicaccount': |
+ settings = cp.CloudPolicySettings() |
+ self.GatherUserPolicySettings(settings, policy[policy_type]) |
# Figure out the key we want to use. If multiple keys are configured, the |
# server will rotate through them in a round-robin fashion. |
@@ -463,7 +467,7 @@ class RequestHandler(object): |
policy_data.policy_type = msg.policy_type |
policy_data.timestamp = int(time.time() * 1000) |
policy_data.request_token = token_info['device_token'] |
- policy_data.policy_value = policy_value |
+ policy_data.policy_value = settings.SerializeToString() |
policy_data.machine_name = token_info['machine_name'] |
policy_data.valid_serial_number_missing = ( |
token_info['machine_id'] in BAD_MACHINE_IDS) |
@@ -617,7 +621,10 @@ class TestServer(object): |
dmtoken = ''.join(dmtoken_chars) |
allowed_policy_types = { |
dm.DeviceRegisterRequest.USER: ['google/chromeos/user'], |
- dm.DeviceRegisterRequest.DEVICE: ['google/chromeos/device'], |
+ dm.DeviceRegisterRequest.DEVICE: [ |
+ 'google/chromeos/device', |
+ 'google/chromeos/publicaccount' |
+ ], |
dm.DeviceRegisterRequest.TT: ['google/chromeos/user'], |
} |
if machine_id in KIOSK_MACHINE_IDS: |