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

Side by Side Diff: chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc

Issue 16946002: Resolve certificate references in ONC by PEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a unit test for the resolve function. Created 7 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/network_configuration_updater_impl_cros .h" 5 #include "chrome/browser/chromeos/policy/network_configuration_updater_impl_cros .h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/chromeos/cros/mock_network_library.h" 12 #include "chrome/browser/chromeos/cros/mock_network_library.h"
13 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 13 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
14 #include "chrome/browser/policy/policy_map.h" 14 #include "chrome/browser/policy/policy_map.h"
15 #include "chrome/browser/policy/policy_service_impl.h" 15 #include "chrome/browser/policy/policy_service_impl.h"
16 #include "chromeos/network/mock_certificate_handler.h" 16 #include "chromeos/network/mock_certificate_handler.h"
17 #include "chromeos/network/onc/onc_constants.h" 17 #include "chromeos/network/onc/onc_constants.h"
18 #include "chromeos/network/onc/onc_test_utils.h" 18 #include "chromeos/network/onc/onc_test_utils.h"
19 #include "chromeos/network/onc/onc_utils.h" 19 #include "chromeos/network/onc/onc_utils.h"
20 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 #include "net/base/test_data_directory.h" 22 #include "net/base/test_data_directory.h"
23 #include "net/cert/cert_trust_anchor_provider.h" 23 #include "net/cert/cert_trust_anchor_provider.h"
24 #include "net/cert/x509_certificate.h" 24 #include "net/cert/x509_certificate.h"
25 #include "net/test/cert_test_util.h" 25 #include "net/test/cert_test_util.h"
26 #include "net/test/test_certificate_data.h"
26 #include "policy/policy_constants.h" 27 #include "policy/policy_constants.h"
27 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 using testing::AnyNumber; 31 using testing::AnyNumber;
31 using testing::Mock; 32 using testing::Mock;
32 using testing::Ne; 33 using testing::Ne;
33 using testing::Return; 34 using testing::Return;
34 using testing::StrictMock; 35 using testing::StrictMock;
35 using testing::_; 36 using testing::_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::string(negation ? "isn't" : "is") + " equal to " + 71 std::string(negation ? "isn't" : "is") + " equal to " +
71 ValueToString(value)) { 72 ValueToString(value)) {
72 return value->Equals(&arg); 73 return value->Equals(&arg);
73 } 74 }
74 75
75 ACTION_P(SetCertificateList, list) { 76 ACTION_P(SetCertificateList, list) {
76 *arg2 = list; 77 *arg2 = list;
77 return true; 78 return true;
78 } 79 }
79 80
81 ACTION_P(SetImportedCerts, map) {
82 *arg3 = map;
83 return true;
84 }
85
80 } // namespace 86 } // namespace
81 87
82 // Tests of NetworkConfigurationUpdaterImplCros 88 // Tests of NetworkConfigurationUpdaterImplCros
83 class NetworkConfigurationUpdaterTest : public testing::Test { 89 class NetworkConfigurationUpdaterTest : public testing::Test {
84 protected: 90 protected:
85 NetworkConfigurationUpdaterTest() 91 NetworkConfigurationUpdaterTest()
86 : ui_thread_(content::BrowserThread::UI, &loop_), 92 : ui_thread_(content::BrowserThread::UI, &loop_),
87 io_thread_(content::BrowserThread::IO, &loop_) {} 93 io_thread_(content::BrowserThread::IO, &loop_) {}
88 94
89 virtual void SetUp() OVERRIDE { 95 virtual void SetUp() OVERRIDE {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 policy.Set(key::kOpenNetworkConfiguration, POLICY_LEVEL_MANDATORY, 174 policy.Set(key::kOpenNetworkConfiguration, POLICY_LEVEL_MANDATORY,
169 POLICY_SCOPE_USER, Value::CreateStringValue(onc_policy)); 175 POLICY_SCOPE_USER, Value::CreateStringValue(onc_policy));
170 UpdateProviderPolicy(policy); 176 UpdateProviderPolicy(policy);
171 177
172 EXPECT_CALL(network_library_, AddNetworkProfileObserver(_)); 178 EXPECT_CALL(network_library_, AddNetworkProfileObserver(_));
173 179
174 // Ignore the device policy update. 180 // Ignore the device policy update.
175 EXPECT_CALL(network_library_, LoadOncNetworks(_, _)); 181 EXPECT_CALL(network_library_, LoadOncNetworks(_, _));
176 StrictMock<chromeos::MockCertificateHandler>* certificate_handler = 182 StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
177 new StrictMock<chromeos::MockCertificateHandler>(); 183 new StrictMock<chromeos::MockCertificateHandler>();
178 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _)); 184 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _, _));
179 185
180 NetworkConfigurationUpdaterImplCros updater( 186 NetworkConfigurationUpdaterImplCros updater(
181 policy_service_.get(), 187 policy_service_.get(),
182 &network_library_, 188 &network_library_,
183 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler)); 189 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
184 Mock::VerifyAndClearExpectations(&network_library_); 190 Mock::VerifyAndClearExpectations(&network_library_);
185 Mock::VerifyAndClearExpectations(&certificate_handler); 191 Mock::VerifyAndClearExpectations(&certificate_handler);
186 192
187 // After the user policy is initialized, we always push both policies to the 193 // After the user policy is initialized, we always push both policies to the
188 // NetworkLibrary. Ignore the device policy. 194 // NetworkLibrary. Ignore the device policy.
189 EXPECT_CALL(network_library_, LoadOncNetworks( 195 EXPECT_CALL(network_library_, LoadOncNetworks(
190 _, onc::ONC_SOURCE_DEVICE_POLICY)); 196 _, onc::ONC_SOURCE_DEVICE_POLICY));
191 EXPECT_CALL(network_library_, LoadOncNetworks( 197 EXPECT_CALL(network_library_, LoadOncNetworks(
192 IsEqualTo(network_configs_repaired), 198 IsEqualTo(network_configs_repaired),
193 onc::ONC_SOURCE_USER_POLICY)); 199 onc::ONC_SOURCE_USER_POLICY));
194 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _)).Times(2); 200 EXPECT_CALL(*certificate_handler,
201 ImportCertificates(_, chromeos::onc::ONC_SOURCE_DEVICE_POLICY,
202 _, _));
203 scoped_refptr<net::X509Certificate> google_cert(
204 net::X509Certificate::CreateFromBytes(
205 reinterpret_cast<const char*>(google_der), sizeof(google_der)));
206 chromeos::CertificateHandler::CertsByGUID imported_certs;
207 imported_certs["test-ca"] = google_cert;
208 EXPECT_CALL(*certificate_handler,
209 ImportCertificates(_, chromeos::onc::ONC_SOURCE_USER_POLICY,
210 _, _))
211 .WillOnce(SetImportedCerts(imported_certs));
195 212
196 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_)); 213 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_));
197 214
198 updater.SetUserPolicyService(false, "hash", policy_service_.get()); 215 updater.SetUserPolicyService(false, "hash", policy_service_.get());
199 updater.UnsetUserPolicyService(); 216 updater.UnsetUserPolicyService();
200 } 217 }
201 218
202 class NetworkConfigurationUpdaterTestWithParam 219 class NetworkConfigurationUpdaterTestWithParam
203 : public NetworkConfigurationUpdaterTest, 220 : public NetworkConfigurationUpdaterTest,
204 public testing::WithParamInterface<const char*> { 221 public testing::WithParamInterface<const char*> {
(...skipping 23 matching lines...) Expand all
228 device_certs = empty_certificates_.get(); 245 device_certs = empty_certificates_.get();
229 user_networks = fake_network_configs_.get(); 246 user_networks = fake_network_configs_.get();
230 user_certs = fake_certificates_.get(); 247 user_certs = fake_certificates_.get();
231 } 248 }
232 249
233 EXPECT_CALL(network_library_, LoadOncNetworks( 250 EXPECT_CALL(network_library_, LoadOncNetworks(
234 IsEqualTo(device_networks), onc::ONC_SOURCE_DEVICE_POLICY)); 251 IsEqualTo(device_networks), onc::ONC_SOURCE_DEVICE_POLICY));
235 StrictMock<chromeos::MockCertificateHandler>* certificate_handler = 252 StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
236 new StrictMock<chromeos::MockCertificateHandler>(); 253 new StrictMock<chromeos::MockCertificateHandler>();
237 EXPECT_CALL(*certificate_handler, ImportCertificates( 254 EXPECT_CALL(*certificate_handler, ImportCertificates(
238 IsEqualTo(device_certs), onc::ONC_SOURCE_DEVICE_POLICY, _)); 255 IsEqualTo(device_certs), onc::ONC_SOURCE_DEVICE_POLICY, _, _));
239 256
240 NetworkConfigurationUpdaterImplCros updater( 257 NetworkConfigurationUpdaterImplCros updater(
241 policy_service_.get(), 258 policy_service_.get(),
242 &network_library_, 259 &network_library_,
243 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler)); 260 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
244 Mock::VerifyAndClearExpectations(&network_library_); 261 Mock::VerifyAndClearExpectations(&network_library_);
245 Mock::VerifyAndClearExpectations(&certificate_handler); 262 Mock::VerifyAndClearExpectations(&certificate_handler);
246 263
247 // After the user policy is initialized, we always push both policies to the 264 // After the user policy is initialized, we always push both policies to the
248 // NetworkLibrary. 265 // NetworkLibrary.
249 EXPECT_CALL(network_library_, LoadOncNetworks( 266 EXPECT_CALL(network_library_, LoadOncNetworks(
250 IsEqualTo(device_networks), onc::ONC_SOURCE_DEVICE_POLICY)); 267 IsEqualTo(device_networks), onc::ONC_SOURCE_DEVICE_POLICY));
251 EXPECT_CALL(*certificate_handler, ImportCertificates( 268 EXPECT_CALL(*certificate_handler, ImportCertificates(
252 IsEqualTo(device_certs), onc::ONC_SOURCE_DEVICE_POLICY, _)); 269 IsEqualTo(device_certs), onc::ONC_SOURCE_DEVICE_POLICY, _, _));
253 270
254 EXPECT_CALL(network_library_, LoadOncNetworks( 271 EXPECT_CALL(network_library_, LoadOncNetworks(
255 IsEqualTo(user_networks), onc::ONC_SOURCE_USER_POLICY)); 272 IsEqualTo(user_networks), onc::ONC_SOURCE_USER_POLICY));
256 EXPECT_CALL(*certificate_handler, ImportCertificates( 273 EXPECT_CALL(*certificate_handler, ImportCertificates(
257 IsEqualTo(user_certs), onc::ONC_SOURCE_USER_POLICY, _)); 274 IsEqualTo(user_certs), onc::ONC_SOURCE_USER_POLICY, _, _));
258 275
259 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_)); 276 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_));
260 277
261 // We just need an initialized PolicyService, so we can reuse 278 // We just need an initialized PolicyService, so we can reuse
262 // |policy_service_|. 279 // |policy_service_|.
263 updater.SetUserPolicyService(false, "hash", policy_service_.get()); 280 updater.SetUserPolicyService(false, "hash", policy_service_.get());
264 updater.UnsetUserPolicyService(); 281 updater.UnsetUserPolicyService();
265 } 282 }
266 283
267 TEST_P(NetworkConfigurationUpdaterTestWithParam, 284 TEST_P(NetworkConfigurationUpdaterTestWithParam,
268 AllowTrustedCertificatesFromPolicy) { 285 AllowTrustedCertificatesFromPolicy) {
269 EXPECT_CALL(network_library_, AddNetworkProfileObserver(_)); 286 EXPECT_CALL(network_library_, AddNetworkProfileObserver(_));
270 287
271 const net::CertificateList empty_cert_list; 288 const net::CertificateList empty_cert_list;
272 289
273 const net::CertificateList cert_list = 290 const net::CertificateList cert_list =
274 net::CreateCertificateListFromFile(net::GetTestCertsDirectory(), 291 net::CreateCertificateListFromFile(net::GetTestCertsDirectory(),
275 "ok_cert.pem", 292 "ok_cert.pem",
276 net::X509Certificate::FORMAT_AUTO); 293 net::X509Certificate::FORMAT_AUTO);
277 ASSERT_EQ(1u, cert_list.size()); 294 ASSERT_EQ(1u, cert_list.size());
278 295
279 EXPECT_CALL(network_library_, LoadOncNetworks(_, _)).Times(AnyNumber()); 296 EXPECT_CALL(network_library_, LoadOncNetworks(_, _)).Times(AnyNumber());
280 StrictMock<chromeos::MockCertificateHandler>* certificate_handler = 297 StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
281 new StrictMock<chromeos::MockCertificateHandler>(); 298 new StrictMock<chromeos::MockCertificateHandler>();
282 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _)) 299 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _, _))
283 .WillRepeatedly(SetCertificateList(empty_cert_list)); 300 .WillRepeatedly(SetCertificateList(empty_cert_list));
284 NetworkConfigurationUpdaterImplCros updater( 301 NetworkConfigurationUpdaterImplCros updater(
285 policy_service_.get(), 302 policy_service_.get(),
286 &network_library_, 303 &network_library_,
287 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler)); 304 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
288 net::CertTrustAnchorProvider* trust_provider = 305 net::CertTrustAnchorProvider* trust_provider =
289 updater.GetCertTrustAnchorProvider(); 306 updater.GetCertTrustAnchorProvider();
290 ASSERT_TRUE(trust_provider); 307 ASSERT_TRUE(trust_provider);
291 // The initial list of trust anchors is empty. 308 // The initial list of trust anchors is empty.
292 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 309 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
293 EXPECT_TRUE(trust_provider->GetAdditionalTrustAnchors().empty()); 310 EXPECT_TRUE(trust_provider->GetAdditionalTrustAnchors().empty());
294 311
295 // Initially, certificates imported from policy don't have trust flags. 312 // Initially, certificates imported from policy don't have trust flags.
296 updater.SetUserPolicyService(false, "hash", policy_service_.get()); 313 updater.SetUserPolicyService(false, "hash", policy_service_.get());
297 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 314 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
298 Mock::VerifyAndClearExpectations(&network_library_); 315 Mock::VerifyAndClearExpectations(&network_library_);
299 Mock::VerifyAndClearExpectations(&certificate_handler); 316 Mock::VerifyAndClearExpectations(&certificate_handler);
300 EXPECT_TRUE(trust_provider->GetAdditionalTrustAnchors().empty()); 317 EXPECT_TRUE(trust_provider->GetAdditionalTrustAnchors().empty());
301 318
302 // Certificates with the "Web" trust flag set should be forwarded to the 319 // Certificates with the "Web" trust flag set should be forwarded to the
303 // trust provider. 320 // trust provider.
304 EXPECT_CALL(network_library_, LoadOncNetworks(_, _)); 321 EXPECT_CALL(network_library_, LoadOncNetworks(_, _));
305 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _)) 322 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _, _))
306 .WillRepeatedly(SetCertificateList(empty_cert_list)); 323 .WillRepeatedly(SetCertificateList(empty_cert_list));
307 onc::ONCSource current_source = NameToONCSource(GetParam()); 324 onc::ONCSource current_source = NameToONCSource(GetParam());
308 EXPECT_CALL(network_library_, LoadOncNetworks(_, current_source)); 325 EXPECT_CALL(network_library_, LoadOncNetworks(_, current_source));
309 EXPECT_CALL(*certificate_handler, ImportCertificates(_, current_source, _)) 326 EXPECT_CALL(*certificate_handler, ImportCertificates(_, current_source, _, _))
310 .WillRepeatedly(SetCertificateList(cert_list)); 327 .WillRepeatedly(SetCertificateList(cert_list));
311 // Trigger a new policy load, and spin the IO message loop to pass the 328 // Trigger a new policy load, and spin the IO message loop to pass the
312 // certificates to the |trust_provider| on the IO thread. 329 // certificates to the |trust_provider| on the IO thread.
313 updater.SetUserPolicyService(true, "hash", policy_service_.get()); 330 updater.SetUserPolicyService(true, "hash", policy_service_.get());
314 base::RunLoop loop; 331 base::RunLoop loop;
315 loop.RunUntilIdle(); 332 loop.RunUntilIdle();
316 Mock::VerifyAndClearExpectations(&network_library_); 333 Mock::VerifyAndClearExpectations(&network_library_);
317 Mock::VerifyAndClearExpectations(&certificate_handler); 334 Mock::VerifyAndClearExpectations(&certificate_handler);
318 335
319 // Certificates are only provided as trust anchors if they come from user 336 // Certificates are only provided as trust anchors if they come from user
320 // policy. 337 // policy.
321 size_t expected_certs = 0u; 338 size_t expected_certs = 0u;
322 if (GetParam() == key::kOpenNetworkConfiguration) 339 if (GetParam() == key::kOpenNetworkConfiguration)
323 expected_certs = 1u; 340 expected_certs = 1u;
324 EXPECT_EQ(expected_certs, 341 EXPECT_EQ(expected_certs,
325 trust_provider->GetAdditionalTrustAnchors().size()); 342 trust_provider->GetAdditionalTrustAnchors().size());
326 343
327 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_)); 344 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_));
328 updater.UnsetUserPolicyService(); 345 updater.UnsetUserPolicyService();
329 } 346 }
330 347
331 TEST_P(NetworkConfigurationUpdaterTestWithParam, PolicyChange) { 348 TEST_P(NetworkConfigurationUpdaterTestWithParam, PolicyChange) {
332 EXPECT_CALL(network_library_, AddNetworkProfileObserver(_)); 349 EXPECT_CALL(network_library_, AddNetworkProfileObserver(_));
333 350
334 // Ignore the initial updates. 351 // Ignore the initial updates.
335 EXPECT_CALL(network_library_, LoadOncNetworks(_, _)) 352 EXPECT_CALL(network_library_, LoadOncNetworks(_, _))
336 .Times(AnyNumber()); 353 .Times(AnyNumber());
337 StrictMock<chromeos::MockCertificateHandler>* certificate_handler = 354 StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
338 new StrictMock<chromeos::MockCertificateHandler>(); 355 new StrictMock<chromeos::MockCertificateHandler>();
339 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _)) 356 EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _, _))
340 .Times(AnyNumber()); 357 .Times(AnyNumber());
341 NetworkConfigurationUpdaterImplCros updater( 358 NetworkConfigurationUpdaterImplCros updater(
342 policy_service_.get(), 359 policy_service_.get(),
343 &network_library_, 360 &network_library_,
344 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler)); 361 make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
345 updater.SetUserPolicyService(false, "hash", policy_service_.get()); 362 updater.SetUserPolicyService(false, "hash", policy_service_.get());
346 Mock::VerifyAndClearExpectations(&network_library_); 363 Mock::VerifyAndClearExpectations(&network_library_);
347 Mock::VerifyAndClearExpectations(&certificate_handler); 364 Mock::VerifyAndClearExpectations(&certificate_handler);
348 365
349 // We should update if policy changes. 366 // We should update if policy changes.
350 EXPECT_CALL(network_library_, LoadOncNetworks( 367 EXPECT_CALL(network_library_, LoadOncNetworks(
351 IsEqualTo(fake_network_configs_.get()), NameToONCSource(GetParam()))); 368 IsEqualTo(fake_network_configs_.get()), NameToONCSource(GetParam())));
352 EXPECT_CALL(*certificate_handler, ImportCertificates( 369 EXPECT_CALL(*certificate_handler, ImportCertificates(
353 IsEqualTo(fake_certificates_.get()), NameToONCSource(GetParam()), _)); 370 IsEqualTo(fake_certificates_.get()), NameToONCSource(GetParam()), _, _));
354 371
355 // In the current implementation, we always apply both policies. 372 // In the current implementation, we always apply both policies.
356 EXPECT_CALL(network_library_, LoadOncNetworks( 373 EXPECT_CALL(network_library_, LoadOncNetworks(
357 IsEqualTo(empty_network_configs_.get()), 374 IsEqualTo(empty_network_configs_.get()),
358 Ne(NameToONCSource(GetParam())))); 375 Ne(NameToONCSource(GetParam()))));
359 EXPECT_CALL(*certificate_handler, ImportCertificates( 376 EXPECT_CALL(*certificate_handler, ImportCertificates(
360 IsEqualTo(empty_certificates_.get()), 377 IsEqualTo(empty_certificates_.get()),
361 Ne(NameToONCSource(GetParam())), 378 Ne(NameToONCSource(GetParam())),
362 _)); 379 _, _));
363 380
364 PolicyMap policy; 381 PolicyMap policy;
365 policy.Set(GetParam(), POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 382 policy.Set(GetParam(), POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
366 Value::CreateStringValue(kFakeONC)); 383 Value::CreateStringValue(kFakeONC));
367 UpdateProviderPolicy(policy); 384 UpdateProviderPolicy(policy);
368 Mock::VerifyAndClearExpectations(&network_library_); 385 Mock::VerifyAndClearExpectations(&network_library_);
369 Mock::VerifyAndClearExpectations(&certificate_handler); 386 Mock::VerifyAndClearExpectations(&certificate_handler);
370 387
371 // Another update is expected if the policy goes away. In the current 388 // Another update is expected if the policy goes away. In the current
372 // implementation, we always apply both policies. 389 // implementation, we always apply both policies.
373 EXPECT_CALL(network_library_, LoadOncNetworks( 390 EXPECT_CALL(network_library_, LoadOncNetworks(
374 IsEqualTo(empty_network_configs_.get()), 391 IsEqualTo(empty_network_configs_.get()),
375 onc::ONC_SOURCE_DEVICE_POLICY)); 392 onc::ONC_SOURCE_DEVICE_POLICY));
376 EXPECT_CALL(*certificate_handler, ImportCertificates( 393 EXPECT_CALL(*certificate_handler, ImportCertificates(
377 IsEqualTo(empty_certificates_.get()), 394 IsEqualTo(empty_certificates_.get()),
378 onc::ONC_SOURCE_DEVICE_POLICY, 395 onc::ONC_SOURCE_DEVICE_POLICY,
379 _)); 396 _, _));
380 397
381 EXPECT_CALL(network_library_, LoadOncNetworks( 398 EXPECT_CALL(network_library_, LoadOncNetworks(
382 IsEqualTo(empty_network_configs_.get()), 399 IsEqualTo(empty_network_configs_.get()),
383 onc::ONC_SOURCE_USER_POLICY)); 400 onc::ONC_SOURCE_USER_POLICY));
384 EXPECT_CALL(*certificate_handler, ImportCertificates( 401 EXPECT_CALL(*certificate_handler, ImportCertificates(
385 IsEqualTo(empty_certificates_.get()), 402 IsEqualTo(empty_certificates_.get()),
386 onc::ONC_SOURCE_USER_POLICY, 403 onc::ONC_SOURCE_USER_POLICY,
387 _)); 404 _, _));
388 405
389 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_)); 406 EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_));
390 407
391 policy.Erase(GetParam()); 408 policy.Erase(GetParam());
392 UpdateProviderPolicy(policy); 409 UpdateProviderPolicy(policy);
393 updater.UnsetUserPolicyService(); 410 updater.UnsetUserPolicyService();
394 } 411 }
395 412
396 INSTANTIATE_TEST_CASE_P( 413 INSTANTIATE_TEST_CASE_P(
397 NetworkConfigurationUpdaterTestWithParamInstance, 414 NetworkConfigurationUpdaterTestWithParamInstance,
398 NetworkConfigurationUpdaterTestWithParam, 415 NetworkConfigurationUpdaterTestWithParam,
399 testing::Values(key::kDeviceOpenNetworkConfiguration, 416 testing::Values(key::kDeviceOpenNetworkConfiguration,
400 key::kOpenNetworkConfiguration)); 417 key::kOpenNetworkConfiguration));
401 418
402 } // namespace policy 419 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698