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

Side by Side Diff: chrome/browser/policy/device_management_policy_provider_unittest.cc

Issue 5321011: Revert 67530 - Persist 'this device is not managed' information... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 #include "base/file_util.h"
6 #include "base/message_loop.h" 5 #include "base/message_loop.h"
7 #include "base/scoped_temp_dir.h" 6 #include "base/scoped_temp_dir.h"
8 #include "chrome/browser/browser_thread.h" 7 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/net/gaia/token_service.h" 8 #include "chrome/browser/net/gaia/token_service.h"
10 #include "chrome/browser/policy/configuration_policy_pref_store.h" 9 #include "chrome/browser/policy/configuration_policy_pref_store.h"
11 #include "chrome/browser/policy/device_management_policy_cache.h"
12 #include "chrome/browser/policy/device_management_policy_provider.h" 10 #include "chrome/browser/policy/device_management_policy_provider.h"
13 #include "chrome/browser/policy/mock_configuration_policy_store.h" 11 #include "chrome/browser/policy/mock_configuration_policy_store.h"
14 #include "chrome/browser/policy/mock_device_management_backend.h" 12 #include "chrome/browser/policy/mock_device_management_backend.h"
15 #include "chrome/common/net/gaia/gaia_constants.h" 13 #include "chrome/common/net/gaia/gaia_constants.h"
16 #include "chrome/common/notification_service.h" 14 #include "chrome/common/notification_service.h"
17 #include "chrome/common/policy_constants.h" 15 #include "chrome/common/policy_constants.h"
18 #include "chrome/test/mock_notification_observer.h" 16 #include "chrome/test/mock_notification_observer.h"
19 #include "chrome/test/testing_device_token_fetcher.h" 17 #include "chrome/test/testing_device_token_fetcher.h"
20 #include "chrome/test/testing_profile.h" 18 #include "chrome/test/testing_profile.h"
21 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
22 20
23 const char kTestToken[] = "device_policy_provider_test_auth_token"; 21 const char kTestToken[] = "device_policy_provider_test_auth_token";
24 22
25 namespace policy { 23 namespace policy {
26 24
27 using ::testing::_; 25 using ::testing::_;
28 using ::testing::InSequence; 26 using ::testing::InSequence;
29 using ::testing::Mock; 27 using ::testing::Mock;
30 28
31 class DeviceManagementPolicyProviderTest : public testing::Test { 29 class DeviceManagementPolicyProviderTest : public testing::Test {
32 public: 30 public:
33 DeviceManagementPolicyProviderTest() 31 DeviceManagementPolicyProviderTest()
34 : ui_thread_(BrowserThread::UI, &loop_), 32 : ui_thread_(BrowserThread::UI, &loop_),
35 file_thread_(BrowserThread::FILE, &loop_) {} 33 file_thread_(BrowserThread::FILE, &loop_) {}
36 34
37 virtual ~DeviceManagementPolicyProviderTest() {} 35 virtual ~DeviceManagementPolicyProviderTest() {}
38 36
39 virtual void SetUp() { 37 virtual void SetUp() {
40 profile_.reset(new TestingProfile); 38 profile_.reset(new TestingProfile);
39 CreateNewBackend();
41 CreateNewProvider(); 40 CreateNewProvider();
42 EXPECT_TRUE(provider_->waiting_for_initial_policies()); 41 }
43 loop_.RunAllPending(); 42
43 void CreateNewBackend() {
44 backend_ = new MockDeviceManagementBackend;
44 } 45 }
45 46
46 void CreateNewProvider() { 47 void CreateNewProvider() {
47 backend_ = new MockDeviceManagementBackend;
48 provider_.reset(new DeviceManagementPolicyProvider( 48 provider_.reset(new DeviceManagementPolicyProvider(
49 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), 49 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
50 backend_, 50 backend_,
51 profile_.get())); 51 profile_.get()));
52 provider_->SetDeviceTokenFetcher( 52 provider_->SetDeviceTokenFetcher(
53 new TestingDeviceTokenFetcher(backend_, 53 new TestingDeviceTokenFetcher(backend_,
54 profile_.get(), 54 profile_.get(),
55 provider_->GetTokenPath())); 55 provider_->GetTokenPath()));
56 } 56 loop_.RunAllPending();
57
58 void CreateNewProvider(int64 policy_refresh_rate_ms,
59 int64 policy_refresh_max_earlier_ms,
60 int64 policy_refresh_error_delay_ms,
61 int64 token_fetch_error_delay_ms,
62 int64 unmanaged_device_refresh_rate_ms) {
63 backend_ = new MockDeviceManagementBackend;
64 provider_.reset(new DeviceManagementPolicyProvider(
65 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
66 backend_,
67 profile_.get(),
68 policy_refresh_rate_ms,
69 policy_refresh_max_earlier_ms,
70 policy_refresh_error_delay_ms,
71 token_fetch_error_delay_ms,
72 unmanaged_device_refresh_rate_ms));
73 provider_->SetDeviceTokenFetcher(
74 new TestingDeviceTokenFetcher(backend_,
75 profile_.get(),
76 provider_->GetTokenPath()));
77 } 57 }
78 58
79 void SimulateSuccessfulLoginAndRunPending() { 59 void SimulateSuccessfulLoginAndRunPending() {
80 loop_.RunAllPending(); 60 loop_.RunAllPending();
81 profile_->GetTokenService()->IssueAuthTokenForTest( 61 profile_->GetTokenService()->IssueAuthTokenForTest(
82 GaiaConstants::kDeviceManagementService, kTestToken); 62 GaiaConstants::kDeviceManagementService, kTestToken);
83 TestingDeviceTokenFetcher* fetcher = 63 TestingDeviceTokenFetcher* fetcher =
84 static_cast<TestingDeviceTokenFetcher*>( 64 static_cast<TestingDeviceTokenFetcher*>(
85 provider_->token_fetcher_.get()); 65 provider_->token_fetcher_.get());
86 fetcher->SimulateLogin(kTestManagedDomainUsername); 66 fetcher->SimulateLogin(kTestManagedDomainUsername);
87 loop_.RunAllPending(); 67 loop_.RunAllPending();
88 } 68 }
89 69
90 void SimulateSuccessfulInitialPolicyFetch() { 70 void SimulateSuccessfulInitialPolicyFetch() {
91 MockConfigurationPolicyStore store; 71 MockConfigurationPolicyStore store;
92 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 72 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
93 MockDeviceManagementBackendSucceedRegister()); 73 MockDeviceManagementBackendSucceedRegister());
94 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 74 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
95 MockDeviceManagementBackendSucceedBooleanPolicy( 75 MockDeviceManagementBackendSucceedBooleanPolicy(
96 key::kDisableSpdy, true)); 76 key::kDisableSpdy, true));
97 SimulateSuccessfulLoginAndRunPending(); 77 SimulateSuccessfulLoginAndRunPending();
98 EXPECT_FALSE(provider_->waiting_for_initial_policies());
99 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(1); 78 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(1);
100 provider_->Provide(&store); 79 provider_->Provide(&store);
101 ASSERT_EQ(1U, store.policy_map().size()); 80 ASSERT_EQ(1U, store.policy_map().size());
102 Mock::VerifyAndClearExpectations(backend_); 81 Mock::VerifyAndClearExpectations(backend_);
103 Mock::VerifyAndClearExpectations(&store); 82 Mock::VerifyAndClearExpectations(&store);
104 } 83 }
105 84
106 virtual void TearDown() { 85 virtual void TearDown() {
107 loop_.RunAllPending(); 86 loop_.RunAllPending();
108 } 87 }
109 88
110 MockDeviceManagementBackend* backend_; // weak 89 MockDeviceManagementBackend* backend_; // weak
111 scoped_ptr<DeviceManagementPolicyProvider> provider_; 90 scoped_ptr<DeviceManagementPolicyProvider> provider_;
112 91
113 protected: 92 protected:
114 DeviceManagementPolicyCache* cache(DeviceManagementPolicyProvider* provider) { 93 void SetRefreshDelays(DeviceManagementPolicyProvider* provider,
115 return provider->cache_.get(); 94 int64 policy_refresh_rate_ms,
95 int64 policy_refresh_max_earlier_ms,
96 int64 policy_refresh_error_delay_ms,
97 int64 token_fetch_error_delay_ms) {
98 provider->set_policy_refresh_rate_ms(policy_refresh_rate_ms);
99 provider->set_policy_refresh_max_earlier_ms(policy_refresh_max_earlier_ms);
100 provider->set_policy_refresh_error_delay_ms(policy_refresh_error_delay_ms);
101 provider->set_token_fetch_error_delay_ms(token_fetch_error_delay_ms);
116 } 102 }
117 103
104 private:
118 MessageLoop loop_; 105 MessageLoop loop_;
119
120 private:
121 BrowserThread ui_thread_; 106 BrowserThread ui_thread_;
122 BrowserThread file_thread_; 107 BrowserThread file_thread_;
123 scoped_ptr<Profile> profile_; 108 scoped_ptr<Profile> profile_;
124 109
125 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProviderTest); 110 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProviderTest);
126 }; 111 };
127 112
128 // If there's no login and no previously-fetched policy, the provider should 113 // If there's no login and no previously-fetched policy, the provider should
129 // provide an empty policy. 114 // provide an empty policy.
130 TEST_F(DeviceManagementPolicyProviderTest, InitialProvideNoLogin) { 115 TEST_F(DeviceManagementPolicyProviderTest, InitialProvideNoLogin) {
131 MockConfigurationPolicyStore store; 116 MockConfigurationPolicyStore store;
132 EXPECT_CALL(store, Apply(_, _)).Times(0); 117 EXPECT_CALL(store, Apply(_, _)).Times(0);
133 provider_->Provide(&store); 118 provider_->Provide(&store);
134 EXPECT_TRUE(store.policy_map().empty()); 119 EXPECT_TRUE(store.policy_map().empty());
135 EXPECT_TRUE(provider_->waiting_for_initial_policies());
136 } 120 }
137 121
138 // If the login is successful and there's no previously-fetched policy, the 122 // If the login is successful and there's no previously-fetched policy, the
139 // policy should be fetched from the server and should be available the first 123 // policy should be fetched from the server and should be available the first
140 // time the Provide method is called. 124 // time the Provide method is called.
141 TEST_F(DeviceManagementPolicyProviderTest, InitialProvideWithLogin) { 125 TEST_F(DeviceManagementPolicyProviderTest, InitialProvideWithLogin) {
142 EXPECT_TRUE(provider_->waiting_for_initial_policies());
143 SimulateSuccessfulInitialPolicyFetch(); 126 SimulateSuccessfulInitialPolicyFetch();
144 } 127 }
145 128
146 // If the login succeed but the device management backend is unreachable, 129 // If the login succeed but the device management backend is unreachable,
147 // there should be no policy provided if there's no previously-fetched policy, 130 // there should be no policy provided if there's no previously-fetched policy,
148 TEST_F(DeviceManagementPolicyProviderTest, EmptyProvideWithFailedBackend) { 131 TEST_F(DeviceManagementPolicyProviderTest, EmptyProvideWithFailedBackend) {
149 MockConfigurationPolicyStore store; 132 MockConfigurationPolicyStore store;
150 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 133 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
151 MockDeviceManagementBackendFailRegister( 134 MockDeviceManagementBackendFailRegister(
152 DeviceManagementBackend::kErrorRequestFailed)); 135 DeviceManagementBackend::kErrorRequestFailed));
153 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).Times(0); 136 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).Times(0);
154 SimulateSuccessfulLoginAndRunPending(); 137 SimulateSuccessfulLoginAndRunPending();
155 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(0); 138 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(0);
156 provider_->Provide(&store); 139 provider_->Provide(&store);
157 EXPECT_TRUE(store.policy_map().empty()); 140 EXPECT_TRUE(store.policy_map().empty());
158 } 141 }
159 142
160 // If a policy has been fetched previously, if should be available even before 143 // If a policy has been fetched previously, if should be available even before
161 // the login succeeds or the device management backend is available. 144 // the login succeeds or the device management backend is available.
162 TEST_F(DeviceManagementPolicyProviderTest, SecondProvide) { 145 TEST_F(DeviceManagementPolicyProviderTest, SecondProvide) {
163 // Pre-fetch and persist a policy 146 // Pre-fetch and persist a policy
164 SimulateSuccessfulInitialPolicyFetch(); 147 SimulateSuccessfulInitialPolicyFetch();
165 148
166 // Simulate a app relaunch by constructing a new provider. Policy should be 149 // Simulate a app relaunch by constructing a new provider. Policy should be
167 // refreshed (since that might be the purpose of the app relaunch). 150 // refreshed (since that might be the purpose of the app relaunch).
168 CreateNewProvider(); 151 CreateNewBackend();
169 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 152 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
170 MockDeviceManagementBackendSucceedBooleanPolicy( 153 MockDeviceManagementBackendSucceedBooleanPolicy(
171 key::kDisableSpdy, true)); 154 key::kDisableSpdy, true));
172 loop_.RunAllPending(); 155 CreateNewProvider();
173 Mock::VerifyAndClearExpectations(backend_); 156 Mock::VerifyAndClearExpectations(backend_);
174 157
175 // Simulate another app relaunch, this time against a failing backend. 158 // Simulate another app relaunch, this time against a failing backend.
176 // Cached policy should still be available. 159 // Cached policy should still be available.
160 CreateNewBackend();
177 MockConfigurationPolicyStore store; 161 MockConfigurationPolicyStore store;
178 CreateNewProvider();
179 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 162 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
180 MockDeviceManagementBackendFailPolicy( 163 MockDeviceManagementBackendFailPolicy(
181 DeviceManagementBackend::kErrorRequestFailed)); 164 DeviceManagementBackend::kErrorRequestFailed));
182 loop_.RunAllPending(); 165 CreateNewProvider();
183 SimulateSuccessfulLoginAndRunPending(); 166 SimulateSuccessfulLoginAndRunPending();
184 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(1); 167 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(1);
185 provider_->Provide(&store); 168 provider_->Provide(&store);
186 ASSERT_EQ(1U, store.policy_map().size()); 169 ASSERT_EQ(1U, store.policy_map().size());
187 } 170 }
188 171
189 // When policy is successfully fetched from the device management server, it 172 // When policy is successfully fetched from the device management server, it
190 // should force a policy refresh. 173 // should force a policy refresh.
191 TEST_F(DeviceManagementPolicyProviderTest, FetchTriggersRefresh) { 174 TEST_F(DeviceManagementPolicyProviderTest, FetchTriggersRefresh) {
192 MockNotificationObserver observer; 175 MockNotificationObserver observer;
193 NotificationRegistrar registrar; 176 NotificationRegistrar registrar;
194 registrar.Add(&observer, 177 registrar.Add(&observer,
195 NotificationType::POLICY_CHANGED, 178 NotificationType::POLICY_CHANGED,
196 NotificationService::AllSources()); 179 NotificationService::AllSources());
197 EXPECT_CALL(observer, Observe(_, _, _)).Times(1); 180 EXPECT_CALL(observer, Observe(_, _, _)).Times(1);
198 SimulateSuccessfulInitialPolicyFetch(); 181 SimulateSuccessfulInitialPolicyFetch();
199 } 182 }
200 183
201 TEST_F(DeviceManagementPolicyProviderTest, ErrorCausesNewRequest) { 184 TEST_F(DeviceManagementPolicyProviderTest, ErrorCausesNewRequest) {
202 InSequence s; 185 InSequence s;
203 CreateNewProvider(1000 * 1000, 0, 0, 0, 0); 186 SetRefreshDelays(provider_.get(), 1000 * 1000, 0, 0, 0);
204 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 187 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
205 MockDeviceManagementBackendFailRegister( 188 MockDeviceManagementBackendFailRegister(
206 DeviceManagementBackend::kErrorRequestFailed)); 189 DeviceManagementBackend::kErrorRequestFailed));
207 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 190 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
208 MockDeviceManagementBackendSucceedRegister()); 191 MockDeviceManagementBackendSucceedRegister());
209 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 192 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
210 MockDeviceManagementBackendFailPolicy( 193 MockDeviceManagementBackendFailPolicy(
211 DeviceManagementBackend::kErrorRequestFailed)); 194 DeviceManagementBackend::kErrorRequestFailed));
212 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 195 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
213 MockDeviceManagementBackendFailPolicy( 196 MockDeviceManagementBackendFailPolicy(
214 DeviceManagementBackend::kErrorRequestFailed)); 197 DeviceManagementBackend::kErrorRequestFailed));
215 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 198 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
216 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 199 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
217 SimulateSuccessfulLoginAndRunPending(); 200 SimulateSuccessfulLoginAndRunPending();
218 } 201 }
219 202
220 TEST_F(DeviceManagementPolicyProviderTest, RefreshPolicies) { 203 TEST_F(DeviceManagementPolicyProviderTest, RefreshPolicies) {
221 InSequence s; 204 InSequence s;
222 CreateNewProvider(0, 0, 1000 * 1000, 1000, 0); 205 SetRefreshDelays(provider_.get(), 0, 0, 1000 * 1000, 1000);
223 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 206 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
224 MockDeviceManagementBackendSucceedRegister()); 207 MockDeviceManagementBackendSucceedRegister());
225 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 208 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
226 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 209 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
227 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 210 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
228 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 211 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
229 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 212 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
230 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 213 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
231 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 214 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
232 MockDeviceManagementBackendFailPolicy( 215 MockDeviceManagementBackendFailPolicy(
(...skipping 26 matching lines...) Expand all
259 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 242 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
260 MockDeviceManagementBackendFailPolicy( 243 MockDeviceManagementBackendFailPolicy(
261 DeviceManagementBackend::kErrorServiceManagementTokenInvalid)); 244 DeviceManagementBackend::kErrorServiceManagementTokenInvalid));
262 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 245 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
263 MockDeviceManagementBackendSucceedRegister()); 246 MockDeviceManagementBackendSucceedRegister());
264 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 247 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
265 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 248 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
266 SimulateSuccessfulLoginAndRunPending(); 249 SimulateSuccessfulLoginAndRunPending();
267 } 250 }
268 251
269 // This test tests three things (see numbered comments below):
270 TEST_F(DeviceManagementPolicyProviderTest, UnmanagedDevice) {
271 InSequence s;
272 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
273 MockDeviceManagementBackendFailRegister(
274 DeviceManagementBackend::kErrorServiceManagementNotSupported));
275 SimulateSuccessfulLoginAndRunPending();
276 // (1) The provider's DMPolicyCache should know that the device is not
277 // managed.
278 EXPECT_TRUE(cache(provider_.get())->is_device_unmanaged());
279 // (2) On restart, the provider should detect that this is not the first
280 // login.
281 CreateNewProvider(1000*1000, 0, 0, 0, 0);
282 EXPECT_FALSE(provider_->waiting_for_initial_policies());
283 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
284 MockDeviceManagementBackendSucceedRegister());
285 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
286 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
287 SimulateSuccessfulLoginAndRunPending();
288 // (3) Since the backend call this time returned a device id, the "unmanaged"
289 // marker should have been deleted.
290 EXPECT_FALSE(cache(provider_.get())->is_device_unmanaged());
291 }
292
293 } // namespace policy 252 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_policy_provider.cc ('k') | chrome/browser/policy/proto/device_management_local.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698