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

Side by Side Diff: chrome/browser/policy/mock_device_management_backend.h

Issue 6409040: New policy protobuf protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address feedback; fix gyp files Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ 5 #ifndef CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_
6 #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ 6 #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 29 matching lines...) Expand all
40 const std::string& device_id, 40 const std::string& device_id,
41 const em::DeviceUnregisterRequest& request, 41 const em::DeviceUnregisterRequest& request,
42 DeviceUnregisterResponseDelegate* delegate)); 42 DeviceUnregisterResponseDelegate* delegate));
43 43
44 MOCK_METHOD4(ProcessPolicyRequest, void( 44 MOCK_METHOD4(ProcessPolicyRequest, void(
45 const std::string& device_management_token, 45 const std::string& device_management_token,
46 const std::string& device_id, 46 const std::string& device_id,
47 const em::DevicePolicyRequest& request, 47 const em::DevicePolicyRequest& request,
48 DevicePolicyResponseDelegate* delegate)); 48 DevicePolicyResponseDelegate* delegate));
49 49
50 MOCK_METHOD4(ProcessCloudPolicyRequest, void(
51 const std::string& device_management_token,
52 const std::string& device_id,
53 const em::CloudPolicyRequest& request,
54 DevicePolicyResponseDelegate* delegate));
55
50 private: 56 private:
51 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend); 57 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend);
52 }; 58 };
53 59
54 ACTION(MockDeviceManagementBackendSucceedRegister) { 60 ACTION(MockDeviceManagementBackendSucceedRegister) {
55 em::DeviceRegisterResponse response; 61 em::DeviceRegisterResponse response;
56 std::string token("FAKE_DEVICE_TOKEN_"); 62 std::string token("FAKE_DEVICE_TOKEN_");
57 static int next_token_suffix; 63 static int next_token_suffix;
58 token += next_token_suffix++; 64 token += next_token_suffix++;
59 response.set_device_management_token(token); 65 response.set_device_management_token(token);
60 arg3->HandleRegisterResponse(response); 66 arg3->HandleRegisterResponse(response);
61 } 67 }
62 68
63 ACTION_P2(MockDeviceManagementBackendSucceedBooleanPolicy, name, value) { 69 ACTION_P2(MockDeviceManagementBackendSucceedBooleanPolicy, name, value) {
64 em::DevicePolicyResponse response; 70 em::DevicePolicyResponse response;
65 em::DevicePolicySetting* setting = response.add_setting(); 71 em::DevicePolicySetting* setting = response.add_setting();
66 setting->set_policy_key(kChromeDevicePolicySettingKey); 72 setting->set_policy_key(kChromeDevicePolicySettingKey);
67 setting->set_watermark("fresh"); 73 setting->set_watermark("fresh");
68 em::GenericSetting* policy_value = setting->mutable_policy_value(); 74 em::GenericSetting* policy_value = setting->mutable_policy_value();
69 em::GenericNamedValue* named_value = policy_value->add_named_value(); 75 em::GenericNamedValue* named_value = policy_value->add_named_value();
70 named_value->set_name(name); 76 named_value->set_name(name);
71 named_value->mutable_value()->set_value_type( 77 named_value->mutable_value()->set_value_type(
72 em::GenericValue::VALUE_TYPE_BOOL); 78 em::GenericValue::VALUE_TYPE_BOOL);
73 named_value->mutable_value()->set_bool_value(value); 79 named_value->mutable_value()->set_bool_value(value);
74 arg3->HandlePolicyResponse(response); 80 arg3->HandlePolicyResponse(response);
75 } 81 }
76 82
83 ACTION(MockDeviceManagementBackendSucceedSpdyCloudPolicy) {
84 em::SignedCloudPolicyResponse signed_response;
85 em::CloudPolicySettings* settings = signed_response.mutable_settings();
86 em::DisableSpdyProto* spdy_proto = settings->mutable_disablespdy();
87 spdy_proto->set_disablespdy(true);
88 spdy_proto->mutable_policy_options()->set_mode(em::PolicyOptions::MANDATORY);
89 signed_response.set_timestamp(base::Time::NowFromSystemTime().ToTimeT());
90 std::string serialized_signed_response;
91 EXPECT_TRUE(signed_response.SerializeToString(&serialized_signed_response));
92 em::CloudPolicyResponse response;
93 response.set_signed_response(serialized_signed_response);
94 // TODO(jkummerow): Set proper certificate_chain and signature (when
95 // implementing support for signature verification).
96 response.set_signature("TODO");
97 response.add_certificate_chain("TODO");
98 arg3->HandleCloudPolicyResponse(response);
99 }
100
77 ACTION_P(MockDeviceManagementBackendFailRegister, error) { 101 ACTION_P(MockDeviceManagementBackendFailRegister, error) {
78 arg3->OnError(error); 102 arg3->OnError(error);
79 } 103 }
80 104
81 ACTION_P(MockDeviceManagementBackendFailPolicy, error) { 105 ACTION_P(MockDeviceManagementBackendFailPolicy, error) {
82 arg3->OnError(error); 106 arg3->OnError(error);
83 } 107 }
84 108
85 } // namespace policy 109 } // namespace policy
86 110
87 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ 111 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698