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

Side by Side Diff: chromeos/network/managed_network_configuration_handler_unittest.cc

Issue 23526016: Autoconnect policy for CrOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed policy. Created 7 years, 2 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <iostream> 5 #include <iostream>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "chromeos/dbus/mock_dbus_thread_manager.h" 12 #include "chromeos/dbus/mock_dbus_thread_manager.h"
12 #include "chromeos/dbus/mock_shill_manager_client.h" 13 #include "chromeos/dbus/mock_shill_manager_client.h"
13 #include "chromeos/dbus/mock_shill_profile_client.h" 14 #include "chromeos/dbus/mock_shill_profile_client.h"
14 #include "chromeos/dbus/mock_shill_service_client.h" 15 #include "chromeos/dbus/mock_shill_service_client.h"
15 #include "chromeos/network/managed_network_configuration_handler_impl.h" 16 #include "chromeos/network/managed_network_configuration_handler_impl.h"
16 #include "chromeos/network/network_configuration_handler.h" 17 #include "chromeos/network/network_configuration_handler.h"
17 #include "chromeos/network/network_profile_handler.h" 18 #include "chromeos/network/network_profile_handler.h"
18 #include "chromeos/network/onc/onc_test_utils.h" 19 #include "chromeos/network/onc/onc_test_utils.h"
19 #include "chromeos/network/onc/onc_utils.h" 20 #include "chromeos/network/onc/onc_utils.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 ASSERT_TRUE(entries); 95 ASSERT_TRUE(entries);
95 96
96 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); 97 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
97 base::ListValue* entry_paths = new base::ListValue; 98 base::ListValue* entry_paths = new base::ListValue;
98 result->SetWithoutPathExpansion(shill::kEntriesProperty, entry_paths); 99 result->SetWithoutPathExpansion(shill::kEntriesProperty, entry_paths);
99 for (base::DictionaryValue::Iterator it(*entries); !it.IsAtEnd(); 100 for (base::DictionaryValue::Iterator it(*entries); !it.IsAtEnd();
100 it.Advance()) { 101 it.Advance()) {
101 entry_paths->AppendString(it.key()); 102 entry_paths->AppendString(it.key());
102 } 103 }
103 104
104 ASSERT_GT(profile_to_user_.count(profile_path.value()), 0UL); 105 ASSERT_TRUE(ContainsKey(profile_to_user_, profile_path.value()));
105 const std::string& userhash = profile_to_user_[profile_path.value()]; 106 const std::string& userhash = profile_to_user_[profile_path.value()];
106 result->SetStringWithoutPathExpansion(shill::kUserHashProperty, userhash); 107 result->SetStringWithoutPathExpansion(shill::kUserHashProperty, userhash);
107 108
108 callback.Run(*result); 109 callback.Run(*result);
109 } 110 }
110 111
111 void GetEntry(const dbus::ObjectPath& profile_path, 112 void GetEntry(const dbus::ObjectPath& profile_path,
112 const std::string& entry_path, 113 const std::string& entry_path,
113 const DictionaryValueCallbackWithoutStatus& callback, 114 const DictionaryValueCallbackWithoutStatus& callback,
114 const ErrorCallback& error_callback) { 115 const ErrorCallback& error_callback) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 223
223 void SetPolicy(::onc::ONCSource onc_source, 224 void SetPolicy(::onc::ONCSource onc_source,
224 const std::string& userhash, 225 const std::string& userhash,
225 const std::string& path_to_onc) { 226 const std::string& path_to_onc) {
226 scoped_ptr<base::DictionaryValue> policy; 227 scoped_ptr<base::DictionaryValue> policy;
227 if (path_to_onc.empty()) 228 if (path_to_onc.empty())
228 policy = onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration); 229 policy = onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration);
229 else 230 else
230 policy = test_utils::ReadTestDictionary(path_to_onc); 231 policy = test_utils::ReadTestDictionary(path_to_onc);
231 232
232 base::ListValue* network_configs = NULL; 233 base::ListValue empty_network_configs;
234 base::ListValue* network_configs = &empty_network_configs;
233 policy->GetListWithoutPathExpansion( 235 policy->GetListWithoutPathExpansion(
234 ::onc::toplevel_config::kNetworkConfigurations, &network_configs); 236 ::onc::toplevel_config::kNetworkConfigurations, &network_configs);
235 237
238 base::DictionaryValue empty_global_config;
239 base::DictionaryValue* global_network_config = &empty_global_config;
240 policy->GetDictionaryWithoutPathExpansion(
241 ::onc::toplevel_config::kGlobalNetworkConfiguration,
242 &global_network_config);
243
236 managed_handler()->SetPolicy( 244 managed_handler()->SetPolicy(
237 ::onc::ONC_SOURCE_USER_POLICY, userhash, *network_configs); 245 onc_source, userhash, *network_configs, *global_network_config);
238 } 246 }
239 247
240 void SetNetworkConfigurationHandlerExpectations() { 248 void SetNetworkConfigurationHandlerExpectations() {
241 // These calls occur in NetworkConfigurationHandler. 249 // These calls occur in NetworkConfigurationHandler.
242 EXPECT_CALL(mock_manager_client_, GetProperties(_)).Times(AnyNumber()); 250 EXPECT_CALL(mock_manager_client_, GetProperties(_)).Times(AnyNumber());
243 EXPECT_CALL(mock_manager_client_, 251 EXPECT_CALL(mock_manager_client_,
244 AddPropertyChangedObserver(_)).Times(AnyNumber()); 252 AddPropertyChangedObserver(_)).Times(AnyNumber());
245 EXPECT_CALL(mock_manager_client_, 253 EXPECT_CALL(mock_manager_client_,
246 RemovePropertyChangedObserver(_)).Times(AnyNumber()); 254 RemovePropertyChangedObserver(_)).Times(AnyNumber());
247 } 255 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 test_utils::ReadTestDictionary( 327 test_utils::ReadTestDictionary(
320 "policy/" 328 "policy/"
321 "shill_policy_on_unmanaged_ethernet_eap.json"); 329 "shill_policy_on_unmanaged_ethernet_eap.json");
322 330
323 SetUpEntry("policy/shill_unmanaged_ethernet_eap.json", 331 SetUpEntry("policy/shill_unmanaged_ethernet_eap.json",
324 kUser1ProfilePath, 332 kUser1ProfilePath,
325 "eth_entry"); 333 "eth_entry");
326 334
327 // Also setup an unrelated WiFi configuration to verify that the right entry 335 // Also setup an unrelated WiFi configuration to verify that the right entry
328 // is matched. 336 // is matched.
329 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", 337 SetUpEntry("policy/shill_unmanaged_wifi1.json",
330 kUser1ProfilePath, 338 kUser1ProfilePath,
331 "wifi_entry"); 339 "wifi_entry");
332 340
333 EXPECT_CALL(mock_profile_client_, 341 EXPECT_CALL(mock_profile_client_,
334 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 342 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
335 343
336 EXPECT_CALL(mock_profile_client_, 344 EXPECT_CALL(mock_profile_client_,
337 GetEntry(dbus::ObjectPath(kUser1ProfilePath), _, _, _)).Times(2); 345 GetEntry(dbus::ObjectPath(kUser1ProfilePath), _, _, _)).Times(2);
338 346
339 EXPECT_CALL( 347 EXPECT_CALL(
(...skipping 14 matching lines...) Expand all
354 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) { 362 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) {
355 InitializeStandardProfiles(); 363 InitializeStandardProfiles();
356 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _)); 364 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _));
357 365
358 EXPECT_CALL(mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)); 366 EXPECT_CALL(mock_manager_client_, ConfigureServiceForProfile(_, _, _, _));
359 367
360 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 368 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
361 message_loop_.RunUntilIdle(); 369 message_loop_.RunUntilIdle();
362 VerifyAndClearExpectations(); 370 VerifyAndClearExpectations();
363 371
364 SetUpEntry("policy/shill_policy_on_unmanaged_user_wifi1.json", 372 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
365 kUser1ProfilePath, 373 kUser1ProfilePath,
366 "some_entry_path"); 374 "some_entry_path");
367 375
368 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _)); 376 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _));
369 377
370 EXPECT_CALL( 378 EXPECT_CALL(
371 mock_profile_client_, 379 mock_profile_client_,
372 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _)); 380 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _));
373 381
374 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 382 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
375 message_loop_.RunUntilIdle(); 383 message_loop_.RunUntilIdle();
376 } 384 }
377 385
378 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) { 386 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) {
379 InitializeStandardProfiles(); 387 InitializeStandardProfiles();
380 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", 388 SetUpEntry("policy/shill_unmanaged_wifi1.json",
381 kUser1ProfilePath, 389 kUser1ProfilePath,
382 "old_entry_path"); 390 "old_entry_path");
383 391
384 scoped_ptr<base::DictionaryValue> expected_shill_properties = 392 scoped_ptr<base::DictionaryValue> expected_shill_properties =
385 test_utils::ReadTestDictionary( 393 test_utils::ReadTestDictionary(
386 "policy/shill_policy_on_unmanaged_user_wifi1.json"); 394 "policy/shill_policy_on_unmanaged_wifi1.json");
387 395
388 EXPECT_CALL(mock_profile_client_, 396 EXPECT_CALL(mock_profile_client_,
389 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 397 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
390 398
391 EXPECT_CALL( 399 EXPECT_CALL(
392 mock_profile_client_, 400 mock_profile_client_,
393 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 401 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
394 402
395 EXPECT_CALL( 403 EXPECT_CALL(
396 mock_profile_client_, 404 mock_profile_client_,
397 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 405 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
398 406
399 EXPECT_CALL(mock_manager_client_, 407 EXPECT_CALL(mock_manager_client_,
400 ConfigureServiceForProfile( 408 ConfigureServiceForProfile(
401 dbus::ObjectPath(kUser1ProfilePath), 409 dbus::ObjectPath(kUser1ProfilePath),
402 IsEqualTo(expected_shill_properties.get()), 410 IsEqualTo(expected_shill_properties.get()),
403 _, _)); 411 _, _));
404 412
405 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 413 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
406 message_loop_.RunUntilIdle(); 414 message_loop_.RunUntilIdle();
407 } 415 }
408 416
409 // Old ChromeOS versions may not have used the UIData property 417 // Old ChromeOS versions may not have used the UIData property
410 TEST_F(ManagedNetworkConfigurationHandlerTest, 418 TEST_F(ManagedNetworkConfigurationHandlerTest,
411 SetPolicyManageUnmanagedWithoutUIData) { 419 SetPolicyManageUnmanagedWithoutUIData) {
412 InitializeStandardProfiles(); 420 InitializeStandardProfiles();
413 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", 421 SetUpEntry("policy/shill_unmanaged_wifi1.json",
414 kUser1ProfilePath, 422 kUser1ProfilePath,
415 "old_entry_path"); 423 "old_entry_path");
416 424
417 scoped_ptr<base::DictionaryValue> expected_shill_properties = 425 scoped_ptr<base::DictionaryValue> expected_shill_properties =
418 test_utils::ReadTestDictionary( 426 test_utils::ReadTestDictionary(
419 "policy/shill_policy_on_unmanaged_user_wifi1.json"); 427 "policy/shill_policy_on_unmanaged_wifi1.json");
420 428
421 EXPECT_CALL(mock_profile_client_, 429 EXPECT_CALL(mock_profile_client_,
422 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 430 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
423 431
424 EXPECT_CALL( 432 EXPECT_CALL(
425 mock_profile_client_, 433 mock_profile_client_,
426 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 434 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
427 435
428 EXPECT_CALL( 436 EXPECT_CALL(
429 mock_profile_client_, 437 mock_profile_client_,
(...skipping 10 matching lines...) Expand all
440 } 448 }
441 449
442 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedNewGUID) { 450 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedNewGUID) {
443 InitializeStandardProfiles(); 451 InitializeStandardProfiles();
444 SetUpEntry("policy/shill_managed_wifi1.json", 452 SetUpEntry("policy/shill_managed_wifi1.json",
445 kUser1ProfilePath, 453 kUser1ProfilePath,
446 "old_entry_path"); 454 "old_entry_path");
447 455
448 scoped_ptr<base::DictionaryValue> expected_shill_properties = 456 scoped_ptr<base::DictionaryValue> expected_shill_properties =
449 test_utils::ReadTestDictionary( 457 test_utils::ReadTestDictionary(
450 "policy/shill_policy_on_unmanaged_user_wifi1.json"); 458 "policy/shill_policy_on_unmanaged_wifi1.json");
451 459
452 // The passphrase isn't sent again, because it's configured by the user and 460 // The passphrase isn't sent again, because it's configured by the user and
453 // Shill doesn't sent it on GetProperties calls. 461 // Shill doesn't sent it on GetProperties calls.
454 expected_shill_properties->RemoveWithoutPathExpansion( 462 expected_shill_properties->RemoveWithoutPathExpansion(
455 shill::kPassphraseProperty, NULL); 463 shill::kPassphraseProperty, NULL);
456 464
457 EXPECT_CALL(mock_profile_client_, 465 EXPECT_CALL(mock_profile_client_,
458 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 466 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
459 467
460 EXPECT_CALL( 468 EXPECT_CALL(
461 mock_profile_client_, 469 mock_profile_client_,
462 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 470 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
463 471
464 EXPECT_CALL( 472 EXPECT_CALL(
465 mock_profile_client_, 473 mock_profile_client_,
466 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 474 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
467 475
468 EXPECT_CALL(mock_manager_client_, 476 EXPECT_CALL(mock_manager_client_,
469 ConfigureServiceForProfile( 477 ConfigureServiceForProfile(
470 dbus::ObjectPath(kUser1ProfilePath), 478 dbus::ObjectPath(kUser1ProfilePath),
471 IsEqualTo(expected_shill_properties.get()), 479 IsEqualTo(expected_shill_properties.get()),
472 _, _)); 480 _, _));
473 481
474 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 482 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
475 message_loop_.RunUntilIdle(); 483 message_loop_.RunUntilIdle();
476 } 484 }
477 485
478 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyReapplyToManaged) { 486 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyReapplyToManaged) {
479 InitializeStandardProfiles(); 487 InitializeStandardProfiles();
480 SetUpEntry("policy/shill_policy_on_unmanaged_user_wifi1.json", 488 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
481 kUser1ProfilePath, 489 kUser1ProfilePath,
482 "old_entry_path"); 490 "old_entry_path");
483 491
484 scoped_ptr<base::DictionaryValue> expected_shill_properties = 492 scoped_ptr<base::DictionaryValue> expected_shill_properties =
485 test_utils::ReadTestDictionary( 493 test_utils::ReadTestDictionary(
486 "policy/shill_policy_on_unmanaged_user_wifi1.json"); 494 "policy/shill_policy_on_unmanaged_wifi1.json");
487 495
488 // The passphrase isn't sent again, because it's configured by the user and 496 // The passphrase isn't sent again, because it's configured by the user and
489 // Shill doesn't sent it on GetProperties calls. 497 // Shill doesn't sent it on GetProperties calls.
490 expected_shill_properties->RemoveWithoutPathExpansion( 498 expected_shill_properties->RemoveWithoutPathExpansion(
491 shill::kPassphraseProperty, NULL); 499 shill::kPassphraseProperty, NULL);
492 500
493 EXPECT_CALL(mock_profile_client_, 501 EXPECT_CALL(mock_profile_client_,
494 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 502 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
495 503
496 EXPECT_CALL( 504 EXPECT_CALL(
(...skipping 18 matching lines...) Expand all
515 EXPECT_CALL( 523 EXPECT_CALL(
516 mock_profile_client_, 524 mock_profile_client_,
517 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 525 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
518 526
519 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 527 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
520 message_loop_.RunUntilIdle(); 528 message_loop_.RunUntilIdle();
521 } 529 }
522 530
523 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUnmanageManaged) { 531 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUnmanageManaged) {
524 InitializeStandardProfiles(); 532 InitializeStandardProfiles();
525 SetUpEntry("policy/shill_policy_on_unmanaged_user_wifi1.json", 533 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
526 kUser1ProfilePath, 534 kUser1ProfilePath,
527 "old_entry_path"); 535 "old_entry_path");
528 536
529 EXPECT_CALL(mock_profile_client_, 537 EXPECT_CALL(mock_profile_client_,
530 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 538 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
531 539
532 EXPECT_CALL(mock_profile_client_, 540 EXPECT_CALL(mock_profile_client_,
533 GetEntry(dbus::ObjectPath(kUser1ProfilePath), 541 GetEntry(dbus::ObjectPath(kUser1ProfilePath),
534 "old_entry_path", 542 "old_entry_path",
535 _, _)); 543 _, _));
536 544
537 EXPECT_CALL(mock_profile_client_, 545 EXPECT_CALL(mock_profile_client_,
538 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), 546 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath),
539 "old_entry_path", 547 "old_entry_path",
540 _, _)); 548 _, _));
541 549
542 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, ""); 550 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "");
543 message_loop_.RunUntilIdle(); 551 message_loop_.RunUntilIdle();
544 } 552 }
545 553
546 TEST_F(ManagedNetworkConfigurationHandlerTest, SetEmptyPolicyIgnoreUnmanaged) { 554 TEST_F(ManagedNetworkConfigurationHandlerTest, SetEmptyPolicyIgnoreUnmanaged) {
547 InitializeStandardProfiles(); 555 InitializeStandardProfiles();
548 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", 556 SetUpEntry("policy/shill_unmanaged_wifi1.json",
549 kUser1ProfilePath, 557 kUser1ProfilePath,
550 "old_entry_path"); 558 "old_entry_path");
551 559
552 EXPECT_CALL(mock_profile_client_, 560 EXPECT_CALL(mock_profile_client_,
553 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 561 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
554 562
555 EXPECT_CALL(mock_profile_client_, 563 EXPECT_CALL(mock_profile_client_,
556 GetEntry(dbus::ObjectPath(kUser1ProfilePath), 564 GetEntry(dbus::ObjectPath(kUser1ProfilePath),
557 "old_entry_path", 565 "old_entry_path",
558 _, _)); 566 _, _));
559 567
560 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, ""); 568 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "");
561 message_loop_.RunUntilIdle(); 569 message_loop_.RunUntilIdle();
562 } 570 }
563 571
564 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmanaged) { 572 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmanaged) {
565 InitializeStandardProfiles(); 573 InitializeStandardProfiles();
566 SetUpEntry("policy/shill_unmanaged_user_wifi2.json", 574 SetUpEntry("policy/shill_unmanaged_wifi2.json",
567 kUser1ProfilePath, 575 kUser1ProfilePath,
568 "wifi2_entry_path"); 576 "wifi2_entry_path");
569 577
570 EXPECT_CALL(mock_profile_client_, 578 EXPECT_CALL(mock_profile_client_,
571 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 579 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
572 580
573 EXPECT_CALL( 581 EXPECT_CALL(
574 mock_profile_client_, 582 mock_profile_client_,
575 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _)); 583 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _));
576 584
577 scoped_ptr<base::DictionaryValue> expected_shill_properties = 585 scoped_ptr<base::DictionaryValue> expected_shill_properties =
578 test_utils::ReadTestDictionary( 586 test_utils::ReadTestDictionary(
579 "policy/shill_policy_on_unconfigured_wifi1.json"); 587 "policy/shill_policy_on_unconfigured_wifi1.json");
580 588
581 EXPECT_CALL(mock_manager_client_, 589 EXPECT_CALL(mock_manager_client_,
582 ConfigureServiceForProfile( 590 ConfigureServiceForProfile(
583 dbus::ObjectPath(kUser1ProfilePath), 591 dbus::ObjectPath(kUser1ProfilePath),
584 IsEqualTo(expected_shill_properties.get()), 592 IsEqualTo(expected_shill_properties.get()),
585 _, _)); 593 _, _));
586 594
587 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 595 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
588 message_loop_.RunUntilIdle(); 596 message_loop_.RunUntilIdle();
589 } 597 }
590 598
599 TEST_F(ManagedNetworkConfigurationHandlerTest, AutoConnectDisallowed) {
600 InitializeStandardProfiles();
601 SetUpEntry("policy/shill_unmanaged_wifi2.json",
602 kUser1ProfilePath,
603 "wifi2_entry_path");
604
605 EXPECT_CALL(mock_profile_client_,
606 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
607
608 EXPECT_CALL(
609 mock_profile_client_,
610 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _));
611
612 scoped_ptr<base::DictionaryValue> expected_shill_properties =
613 test_utils::ReadTestDictionary(
614 "policy/shill_disallow_autoconnect_on_unmanaged_wifi2.json");
615
616 EXPECT_CALL(mock_manager_client_,
617 ConfigureServiceForProfile(
618 dbus::ObjectPath(kUser1ProfilePath),
619 IsEqualTo(expected_shill_properties.get()),
620 _, _));
621
622 SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
623 kUser1,
624 "policy/policy_disallow_autoconnect.onc");
625 message_loop_.RunUntilIdle();
626 }
627
591 TEST_F(ManagedNetworkConfigurationHandlerTest, LateProfileLoading) { 628 TEST_F(ManagedNetworkConfigurationHandlerTest, LateProfileLoading) {
592 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 629 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
593 630
594 message_loop_.RunUntilIdle(); 631 message_loop_.RunUntilIdle();
595 VerifyAndClearExpectations(); 632 VerifyAndClearExpectations();
596 633
597 scoped_ptr<base::DictionaryValue> expected_shill_properties = 634 scoped_ptr<base::DictionaryValue> expected_shill_properties =
598 test_utils::ReadTestDictionary( 635 test_utils::ReadTestDictionary(
599 "policy/shill_policy_on_unconfigured_wifi1.json"); 636 "policy/shill_policy_on_unconfigured_wifi1.json");
600 637
601 EXPECT_CALL(mock_profile_client_, 638 EXPECT_CALL(mock_profile_client_,
602 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 639 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
603 640
604 EXPECT_CALL(mock_manager_client_, 641 EXPECT_CALL(mock_manager_client_,
605 ConfigureServiceForProfile( 642 ConfigureServiceForProfile(
606 dbus::ObjectPath(kUser1ProfilePath), 643 dbus::ObjectPath(kUser1ProfilePath),
607 IsEqualTo(expected_shill_properties.get()), 644 IsEqualTo(expected_shill_properties.get()),
608 _, _)); 645 _, _));
609 646
610 InitializeStandardProfiles(); 647 InitializeStandardProfiles();
611 message_loop_.RunUntilIdle(); 648 message_loop_.RunUntilIdle();
612 } 649 }
613 650
614 } // namespace chromeos 651 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698