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

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

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