Less strict CHECK for DeviceCapabilities results.
[chromium-blink-merge.git] / chromeos / network / managed_network_configuration_handler_unittest.cc
blob2fe454d660910f11e1f9f50304401675f768d14d
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
3 // found in the LICENSE file.
5 #include <iostream>
6 #include <sstream>
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h"
11 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "chromeos/dbus/fake_dbus_thread_manager.h"
13 #include "chromeos/dbus/mock_shill_manager_client.h"
14 #include "chromeos/dbus/mock_shill_profile_client.h"
15 #include "chromeos/network/managed_network_configuration_handler_impl.h"
16 #include "chromeos/network/network_configuration_handler.h"
17 #include "chromeos/network/network_profile_handler.h"
18 #include "chromeos/network/onc/onc_test_utils.h"
19 #include "chromeos/network/onc/onc_utils.h"
20 #include "dbus/object_path.h"
21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h"
25 using ::testing::AnyNumber;
26 using ::testing::Invoke;
27 using ::testing::Mock;
28 using ::testing::Pointee;
29 using ::testing::Return;
30 using ::testing::SaveArg;
31 using ::testing::StrEq;
32 using ::testing::StrictMock;
33 using ::testing::_;
35 namespace test_utils = ::chromeos::onc::test_utils;
37 namespace chromeos {
39 namespace {
41 std::string ValueToString(const base::Value* value) {
42 std::stringstream str;
43 str << *value;
44 return str.str();
47 const char kSharedProfilePath[] = "/profile/default";
48 const char kUser1[] = "user1";
49 const char kUser1ProfilePath[] = "/profile/user1/shill";
51 // Matcher to match base::Value.
52 MATCHER_P(IsEqualTo,
53 value,
54 std::string(negation ? "isn't" : "is") + " equal to " +
55 ValueToString(value)) {
56 return value->Equals(&arg);
59 class ShillProfileTestClient {
60 public:
61 typedef ShillClientHelper::DictionaryValueCallbackWithoutStatus
62 DictionaryValueCallbackWithoutStatus;
63 typedef ShillClientHelper::ErrorCallback ErrorCallback;
65 void AddProfile(const std::string& profile_path,
66 const std::string& userhash) {
67 if (profile_entries_.HasKey(profile_path))
68 return;
70 base::DictionaryValue* profile = new base::DictionaryValue;
71 profile_entries_.SetWithoutPathExpansion(profile_path, profile);
72 profile_to_user_[profile_path] = userhash;
75 void AddEntry(const std::string& profile_path,
76 const std::string& entry_path,
77 const base::DictionaryValue& entry) {
78 base::DictionaryValue* entries = NULL;
79 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path, &entries);
80 ASSERT_TRUE(entries);
82 base::DictionaryValue* new_entry = entry.DeepCopy();
83 new_entry->SetStringWithoutPathExpansion(shill::kProfileProperty,
84 profile_path);
85 entries->SetWithoutPathExpansion(entry_path, new_entry);
88 void GetProperties(const dbus::ObjectPath& profile_path,
89 const DictionaryValueCallbackWithoutStatus& callback,
90 const ErrorCallback& error_callback) {
91 base::DictionaryValue* entries = NULL;
92 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path.value(),
93 &entries);
94 ASSERT_TRUE(entries);
96 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
97 base::ListValue* entry_paths = new base::ListValue;
98 result->SetWithoutPathExpansion(shill::kEntriesProperty, entry_paths);
99 for (base::DictionaryValue::Iterator it(*entries); !it.IsAtEnd();
100 it.Advance()) {
101 entry_paths->AppendString(it.key());
104 ASSERT_TRUE(ContainsKey(profile_to_user_, profile_path.value()));
105 const std::string& userhash = profile_to_user_[profile_path.value()];
106 result->SetStringWithoutPathExpansion(shill::kUserHashProperty, userhash);
108 callback.Run(*result);
111 void GetEntry(const dbus::ObjectPath& profile_path,
112 const std::string& entry_path,
113 const DictionaryValueCallbackWithoutStatus& callback,
114 const ErrorCallback& error_callback) {
115 base::DictionaryValue* entries = NULL;
116 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path.value(),
117 &entries);
118 ASSERT_TRUE(entries);
120 base::DictionaryValue* entry = NULL;
121 entries->GetDictionaryWithoutPathExpansion(entry_path, &entry);
122 ASSERT_TRUE(entry);
123 callback.Run(*entry);
126 protected:
127 base::DictionaryValue profile_entries_;
128 std::map<std::string, std::string> profile_to_user_;
131 class TestNetworkProfileHandler : public NetworkProfileHandler {
132 public:
133 TestNetworkProfileHandler() {
134 Init(NULL /* No NetworkStateHandler */);
136 virtual ~TestNetworkProfileHandler() {}
138 void AddProfileForTest(const NetworkProfile& profile) {
139 AddProfile(profile);
142 private:
143 DISALLOW_COPY_AND_ASSIGN(TestNetworkProfileHandler);
146 } // namespace
148 class ManagedNetworkConfigurationHandlerTest : public testing::Test {
149 public:
150 ManagedNetworkConfigurationHandlerTest()
151 : mock_manager_client_(NULL),
152 mock_profile_client_(NULL) {
155 virtual ~ManagedNetworkConfigurationHandlerTest() {
158 virtual void SetUp() OVERRIDE {
159 FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager;
160 mock_manager_client_ = new StrictMock<MockShillManagerClient>();
161 mock_profile_client_ = new StrictMock<MockShillProfileClient>();
162 dbus_thread_manager->SetShillManagerClient(
163 scoped_ptr<ShillManagerClient>(mock_manager_client_).Pass());
164 dbus_thread_manager->SetShillProfileClient(
165 scoped_ptr<ShillProfileClient>(mock_profile_client_).Pass());
167 DBusThreadManager::InitializeForTesting(dbus_thread_manager);
169 SetNetworkConfigurationHandlerExpectations();
171 ON_CALL(*mock_profile_client_, GetProperties(_,_,_))
172 .WillByDefault(Invoke(&profiles_stub_,
173 &ShillProfileTestClient::GetProperties));
175 ON_CALL(*mock_profile_client_, GetEntry(_,_,_,_))
176 .WillByDefault(Invoke(&profiles_stub_,
177 &ShillProfileTestClient::GetEntry));
179 network_profile_handler_.reset(new TestNetworkProfileHandler());
180 network_configuration_handler_.reset(
181 NetworkConfigurationHandler::InitializeForTest(
182 NULL /* no NetworkStateHandler */));
183 managed_network_configuration_handler_.reset(
184 new ManagedNetworkConfigurationHandlerImpl());
185 managed_network_configuration_handler_->Init(
186 NULL /* no NetworkStateHandler */,
187 network_profile_handler_.get(),
188 network_configuration_handler_.get());
190 message_loop_.RunUntilIdle();
193 virtual void TearDown() OVERRIDE {
194 managed_network_configuration_handler_.reset();
195 network_configuration_handler_.reset();
196 network_profile_handler_.reset();
197 DBusThreadManager::Shutdown();
200 void VerifyAndClearExpectations() {
201 Mock::VerifyAndClearExpectations(mock_manager_client_);
202 Mock::VerifyAndClearExpectations(mock_profile_client_);
203 SetNetworkConfigurationHandlerExpectations();
206 void InitializeStandardProfiles() {
207 profiles_stub_.AddProfile(kUser1ProfilePath, kUser1);
208 network_profile_handler_->
209 AddProfileForTest(NetworkProfile(kUser1ProfilePath, kUser1));
210 network_profile_handler_->
211 AddProfileForTest(NetworkProfile(kSharedProfilePath, std::string()));
214 void SetUpEntry(const std::string& path_to_shill_json,
215 const std::string& profile_path,
216 const std::string& entry_path) {
217 scoped_ptr<base::DictionaryValue> entry =
218 test_utils::ReadTestDictionary(path_to_shill_json);
219 profiles_stub_.AddEntry(profile_path, entry_path, *entry);
222 void SetPolicy(::onc::ONCSource onc_source,
223 const std::string& userhash,
224 const std::string& path_to_onc) {
225 scoped_ptr<base::DictionaryValue> policy;
226 if (path_to_onc.empty())
227 policy = onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration);
228 else
229 policy = test_utils::ReadTestDictionary(path_to_onc);
231 base::ListValue empty_network_configs;
232 base::ListValue* network_configs = &empty_network_configs;
233 policy->GetListWithoutPathExpansion(
234 ::onc::toplevel_config::kNetworkConfigurations, &network_configs);
236 base::DictionaryValue empty_global_config;
237 base::DictionaryValue* global_network_config = &empty_global_config;
238 policy->GetDictionaryWithoutPathExpansion(
239 ::onc::toplevel_config::kGlobalNetworkConfiguration,
240 &global_network_config);
242 managed_handler()->SetPolicy(
243 onc_source, userhash, *network_configs, *global_network_config);
246 void SetNetworkConfigurationHandlerExpectations() {
247 // These calls occur in NetworkConfigurationHandler.
248 EXPECT_CALL(*mock_manager_client_, GetProperties(_)).Times(AnyNumber());
249 EXPECT_CALL(*mock_manager_client_,
250 AddPropertyChangedObserver(_)).Times(AnyNumber());
251 EXPECT_CALL(*mock_manager_client_,
252 RemovePropertyChangedObserver(_)).Times(AnyNumber());
255 ManagedNetworkConfigurationHandler* managed_handler() {
256 return managed_network_configuration_handler_.get();
259 protected:
260 MockShillManagerClient* mock_manager_client_;
261 MockShillProfileClient* mock_profile_client_;
262 ShillProfileTestClient profiles_stub_;
263 scoped_ptr<TestNetworkProfileHandler> network_profile_handler_;
264 scoped_ptr<NetworkConfigurationHandler> network_configuration_handler_;
265 scoped_ptr<ManagedNetworkConfigurationHandlerImpl>
266 managed_network_configuration_handler_;
267 base::MessageLoop message_loop_;
269 private:
270 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandlerTest);
273 TEST_F(ManagedNetworkConfigurationHandlerTest, ProfileInitialization) {
274 InitializeStandardProfiles();
275 message_loop_.RunUntilIdle();
278 TEST_F(ManagedNetworkConfigurationHandlerTest, RemoveIrrelevantFields) {
279 InitializeStandardProfiles();
280 scoped_ptr<base::DictionaryValue> expected_shill_properties =
281 test_utils::ReadTestDictionary(
282 "policy/shill_policy_on_unconfigured_wifi1.json");
284 EXPECT_CALL(*mock_profile_client_,
285 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
287 EXPECT_CALL(*mock_manager_client_,
288 ConfigureServiceForProfile(
289 dbus::ObjectPath(kUser1ProfilePath),
290 IsEqualTo(expected_shill_properties.get()),
291 _, _));
293 SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
294 kUser1,
295 "policy/policy_wifi1_with_redundant_fields.onc");
296 message_loop_.RunUntilIdle();
299 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnconfigured) {
300 InitializeStandardProfiles();
301 scoped_ptr<base::DictionaryValue> expected_shill_properties =
302 test_utils::ReadTestDictionary(
303 "policy/shill_policy_on_unconfigured_wifi1.json");
305 EXPECT_CALL(*mock_profile_client_,
306 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
308 EXPECT_CALL(*mock_manager_client_,
309 ConfigureServiceForProfile(
310 dbus::ObjectPath(kUser1ProfilePath),
311 IsEqualTo(expected_shill_properties.get()),
312 _, _));
314 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
315 message_loop_.RunUntilIdle();
318 // Ensure that EAP settings for ethernet are matched with the right profile
319 // entry and written to the dedicated EthernetEAP service.
320 TEST_F(ManagedNetworkConfigurationHandlerTest,
321 SetPolicyManageUnmanagedEthernetEAP) {
322 InitializeStandardProfiles();
323 scoped_ptr<base::DictionaryValue> expected_shill_properties =
324 test_utils::ReadTestDictionary(
325 "policy/"
326 "shill_policy_on_unmanaged_ethernet_eap.json");
328 SetUpEntry("policy/shill_unmanaged_ethernet_eap.json",
329 kUser1ProfilePath,
330 "eth_entry");
332 // Also setup an unrelated WiFi configuration to verify that the right entry
333 // is matched.
334 SetUpEntry("policy/shill_unmanaged_wifi1.json",
335 kUser1ProfilePath,
336 "wifi_entry");
338 EXPECT_CALL(*mock_profile_client_,
339 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
341 EXPECT_CALL(*mock_profile_client_,
342 GetEntry(dbus::ObjectPath(kUser1ProfilePath), _, _, _)).Times(2);
344 EXPECT_CALL(
345 *mock_profile_client_,
346 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "eth_entry", _, _));
348 EXPECT_CALL(
349 *mock_manager_client_,
350 ConfigureServiceForProfile(dbus::ObjectPath(kUser1ProfilePath),
351 IsEqualTo(expected_shill_properties.get()),
352 _, _));
354 SetPolicy(
355 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_ethernet_eap.onc");
356 message_loop_.RunUntilIdle();
359 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) {
360 InitializeStandardProfiles();
361 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _));
363 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _));
365 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
366 message_loop_.RunUntilIdle();
367 VerifyAndClearExpectations();
369 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
370 kUser1ProfilePath,
371 "some_entry_path");
373 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _));
375 EXPECT_CALL(
376 *mock_profile_client_,
377 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _));
379 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
380 message_loop_.RunUntilIdle();
383 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) {
384 InitializeStandardProfiles();
385 SetUpEntry("policy/shill_unmanaged_wifi1.json",
386 kUser1ProfilePath,
387 "old_entry_path");
389 scoped_ptr<base::DictionaryValue> expected_shill_properties =
390 test_utils::ReadTestDictionary(
391 "policy/shill_policy_on_unmanaged_wifi1.json");
393 EXPECT_CALL(*mock_profile_client_,
394 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
396 EXPECT_CALL(
397 *mock_profile_client_,
398 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
400 EXPECT_CALL(
401 *mock_profile_client_,
402 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
404 EXPECT_CALL(*mock_manager_client_,
405 ConfigureServiceForProfile(
406 dbus::ObjectPath(kUser1ProfilePath),
407 IsEqualTo(expected_shill_properties.get()),
408 _, _));
410 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
411 message_loop_.RunUntilIdle();
414 // Old ChromeOS versions may not have used the UIData property
415 TEST_F(ManagedNetworkConfigurationHandlerTest,
416 SetPolicyManageUnmanagedWithoutUIData) {
417 InitializeStandardProfiles();
418 SetUpEntry("policy/shill_unmanaged_wifi1.json",
419 kUser1ProfilePath,
420 "old_entry_path");
422 scoped_ptr<base::DictionaryValue> expected_shill_properties =
423 test_utils::ReadTestDictionary(
424 "policy/shill_policy_on_unmanaged_wifi1.json");
426 EXPECT_CALL(*mock_profile_client_,
427 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
429 EXPECT_CALL(
430 *mock_profile_client_,
431 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
433 EXPECT_CALL(
434 *mock_profile_client_,
435 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
437 EXPECT_CALL(*mock_manager_client_,
438 ConfigureServiceForProfile(
439 dbus::ObjectPath(kUser1ProfilePath),
440 IsEqualTo(expected_shill_properties.get()),
441 _, _));
443 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
444 message_loop_.RunUntilIdle();
447 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedNewGUID) {
448 InitializeStandardProfiles();
449 SetUpEntry("policy/shill_managed_wifi1.json",
450 kUser1ProfilePath,
451 "old_entry_path");
453 scoped_ptr<base::DictionaryValue> expected_shill_properties =
454 test_utils::ReadTestDictionary(
455 "policy/shill_policy_on_unmanaged_wifi1.json");
457 // The passphrase isn't sent again, because it's configured by the user and
458 // Shill doesn't sent it on GetProperties calls.
459 expected_shill_properties->RemoveWithoutPathExpansion(
460 shill::kPassphraseProperty, NULL);
462 EXPECT_CALL(*mock_profile_client_,
463 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
465 EXPECT_CALL(
466 *mock_profile_client_,
467 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
469 EXPECT_CALL(
470 *mock_profile_client_,
471 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
473 EXPECT_CALL(*mock_manager_client_,
474 ConfigureServiceForProfile(
475 dbus::ObjectPath(kUser1ProfilePath),
476 IsEqualTo(expected_shill_properties.get()),
477 _, _));
479 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
480 message_loop_.RunUntilIdle();
483 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyReapplyToManaged) {
484 InitializeStandardProfiles();
485 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
486 kUser1ProfilePath,
487 "old_entry_path");
489 scoped_ptr<base::DictionaryValue> expected_shill_properties =
490 test_utils::ReadTestDictionary(
491 "policy/shill_policy_on_unmanaged_wifi1.json");
493 // The passphrase isn't sent again, because it's configured by the user and
494 // Shill doesn't sent it on GetProperties calls.
495 expected_shill_properties->RemoveWithoutPathExpansion(
496 shill::kPassphraseProperty, NULL);
498 EXPECT_CALL(*mock_profile_client_,
499 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
501 EXPECT_CALL(
502 *mock_profile_client_,
503 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
505 EXPECT_CALL(*mock_manager_client_,
506 ConfigureServiceForProfile(
507 dbus::ObjectPath(kUser1ProfilePath),
508 IsEqualTo(expected_shill_properties.get()),
509 _, _));
511 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
512 message_loop_.RunUntilIdle();
513 VerifyAndClearExpectations();
515 // If we apply the policy again, without change, then the Shill profile will
516 // not be modified.
517 EXPECT_CALL(*mock_profile_client_,
518 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
520 EXPECT_CALL(
521 *mock_profile_client_,
522 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
524 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
525 message_loop_.RunUntilIdle();
528 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUnmanageManaged) {
529 InitializeStandardProfiles();
530 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
531 kUser1ProfilePath,
532 "old_entry_path");
534 EXPECT_CALL(*mock_profile_client_,
535 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
537 EXPECT_CALL(*mock_profile_client_,
538 GetEntry(dbus::ObjectPath(kUser1ProfilePath),
539 "old_entry_path",
540 _, _));
542 EXPECT_CALL(*mock_profile_client_,
543 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath),
544 "old_entry_path",
545 _, _));
547 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "");
548 message_loop_.RunUntilIdle();
551 TEST_F(ManagedNetworkConfigurationHandlerTest, SetEmptyPolicyIgnoreUnmanaged) {
552 InitializeStandardProfiles();
553 SetUpEntry("policy/shill_unmanaged_wifi1.json",
554 kUser1ProfilePath,
555 "old_entry_path");
557 EXPECT_CALL(*mock_profile_client_,
558 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
560 EXPECT_CALL(*mock_profile_client_,
561 GetEntry(dbus::ObjectPath(kUser1ProfilePath),
562 "old_entry_path",
563 _, _));
565 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "");
566 message_loop_.RunUntilIdle();
569 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmanaged) {
570 InitializeStandardProfiles();
571 SetUpEntry("policy/shill_unmanaged_wifi2.json",
572 kUser1ProfilePath,
573 "wifi2_entry_path");
575 EXPECT_CALL(*mock_profile_client_,
576 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
578 EXPECT_CALL(
579 *mock_profile_client_,
580 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _));
582 scoped_ptr<base::DictionaryValue> expected_shill_properties =
583 test_utils::ReadTestDictionary(
584 "policy/shill_policy_on_unconfigured_wifi1.json");
586 EXPECT_CALL(*mock_manager_client_,
587 ConfigureServiceForProfile(
588 dbus::ObjectPath(kUser1ProfilePath),
589 IsEqualTo(expected_shill_properties.get()),
590 _, _));
592 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
593 message_loop_.RunUntilIdle();
596 TEST_F(ManagedNetworkConfigurationHandlerTest, AutoConnectDisallowed) {
597 InitializeStandardProfiles();
598 SetUpEntry("policy/shill_unmanaged_wifi2.json",
599 kUser1ProfilePath,
600 "wifi2_entry_path");
602 EXPECT_CALL(*mock_profile_client_,
603 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
605 EXPECT_CALL(
606 *mock_profile_client_,
607 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _));
609 scoped_ptr<base::DictionaryValue> expected_shill_properties =
610 test_utils::ReadTestDictionary(
611 "policy/shill_disallow_autoconnect_on_unmanaged_wifi2.json");
613 EXPECT_CALL(*mock_manager_client_,
614 ConfigureServiceForProfile(
615 dbus::ObjectPath(kUser1ProfilePath),
616 IsEqualTo(expected_shill_properties.get()),
617 _, _));
619 SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
620 kUser1,
621 "policy/policy_disallow_autoconnect.onc");
622 message_loop_.RunUntilIdle();
625 TEST_F(ManagedNetworkConfigurationHandlerTest, LateProfileLoading) {
626 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
628 message_loop_.RunUntilIdle();
629 VerifyAndClearExpectations();
631 scoped_ptr<base::DictionaryValue> expected_shill_properties =
632 test_utils::ReadTestDictionary(
633 "policy/shill_policy_on_unconfigured_wifi1.json");
635 EXPECT_CALL(*mock_profile_client_,
636 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
638 EXPECT_CALL(*mock_manager_client_,
639 ConfigureServiceForProfile(
640 dbus::ObjectPath(kUser1ProfilePath),
641 IsEqualTo(expected_shill_properties.get()),
642 _, _));
644 InitializeStandardProfiles();
645 message_loop_.RunUntilIdle();
648 } // namespace chromeos