OLD | NEW |
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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 11 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
11 #include "chromeos/dbus/mock_shill_manager_client.h" | 12 #include "chromeos/dbus/mock_shill_manager_client.h" |
12 #include "chromeos/dbus/mock_shill_profile_client.h" | 13 #include "chromeos/dbus/mock_shill_profile_client.h" |
13 #include "chromeos/dbus/mock_shill_service_client.h" | 14 #include "chromeos/dbus/mock_shill_service_client.h" |
14 #include "chromeos/network/managed_network_configuration_handler_impl.h" | 15 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
15 #include "chromeos/network/network_configuration_handler.h" | 16 #include "chromeos/network/network_configuration_handler.h" |
16 #include "chromeos/network/network_profile_handler.h" | 17 #include "chromeos/network/network_profile_handler.h" |
17 #include "chromeos/network/onc/onc_test_utils.h" | 18 #include "chromeos/network/onc/onc_test_utils.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 EXPECT_CALL(mock_manager_client_, | 303 EXPECT_CALL(mock_manager_client_, |
303 ConfigureServiceForProfile( | 304 ConfigureServiceForProfile( |
304 dbus::ObjectPath(kUser1ProfilePath), | 305 dbus::ObjectPath(kUser1ProfilePath), |
305 IsEqualTo(expected_shill_properties.get()), | 306 IsEqualTo(expected_shill_properties.get()), |
306 _, _)); | 307 _, _)); |
307 | 308 |
308 SetPolicy(onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); | 309 SetPolicy(onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); |
309 message_loop_.RunUntilIdle(); | 310 message_loop_.RunUntilIdle(); |
310 } | 311 } |
311 | 312 |
| 313 // Ensure that EAP settings for ethernet are matched with the right profile |
| 314 // entry and written to the dedicated EthernetEAP service. |
| 315 TEST_F(ManagedNetworkConfigurationHandlerTest, |
| 316 SetPolicyManageUnmanagedEthernetEAP) { |
| 317 InitializeStandardProfiles(); |
| 318 scoped_ptr<base::DictionaryValue> expected_shill_properties = |
| 319 test_utils::ReadTestDictionary( |
| 320 "policy/" |
| 321 "shill_policy_on_unmanaged_ethernet_eap.json"); |
| 322 |
| 323 SetUpEntry("policy/shill_unmanaged_ethernet_eap.json", |
| 324 kUser1ProfilePath, |
| 325 "eth_entry"); |
| 326 |
| 327 // Also setup an unrelated WiFi configuration to verify that the right entry |
| 328 // is matched. |
| 329 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", |
| 330 kUser1ProfilePath, |
| 331 "wifi_entry"); |
| 332 |
| 333 EXPECT_CALL(mock_profile_client_, |
| 334 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); |
| 335 |
| 336 EXPECT_CALL(mock_profile_client_, |
| 337 GetEntry(dbus::ObjectPath(kUser1ProfilePath), _, _, _)).Times(2); |
| 338 |
| 339 EXPECT_CALL( |
| 340 mock_profile_client_, |
| 341 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "eth_entry", _, _)); |
| 342 |
| 343 EXPECT_CALL( |
| 344 mock_manager_client_, |
| 345 ConfigureServiceForProfile(dbus::ObjectPath(kUser1ProfilePath), |
| 346 IsEqualTo(expected_shill_properties.get()), |
| 347 _, _)); |
| 348 |
| 349 SetPolicy( |
| 350 onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_ethernet_eap.onc"); |
| 351 message_loop_.RunUntilIdle(); |
| 352 } |
| 353 |
312 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) { | 354 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) { |
313 InitializeStandardProfiles(); | 355 InitializeStandardProfiles(); |
314 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _)); | 356 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _)); |
315 | 357 |
316 EXPECT_CALL(mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)); | 358 EXPECT_CALL(mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)); |
317 | 359 |
318 SetPolicy(onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); | 360 SetPolicy(onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); |
319 message_loop_.RunUntilIdle(); | 361 message_loop_.RunUntilIdle(); |
320 VerifyAndClearExpectations(); | 362 VerifyAndClearExpectations(); |
321 | 363 |
322 SetUpEntry("policy/shill_policy_on_unmanaged_user_wifi1.json", | 364 SetUpEntry("policy/shill_policy_on_unmanaged_user_wifi1.json", |
323 kUser1ProfilePath, | 365 kUser1ProfilePath, |
324 "some_entry_path"); | 366 "some_entry_path"); |
325 | 367 |
326 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _)); | 368 EXPECT_CALL(mock_profile_client_, GetProperties(_, _, _)); |
327 | 369 |
328 EXPECT_CALL(mock_profile_client_, | 370 EXPECT_CALL( |
329 GetEntry(dbus::ObjectPath(kUser1ProfilePath), | 371 mock_profile_client_, |
330 "some_entry_path", | 372 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _)); |
331 _, _)); | |
332 | 373 |
333 SetPolicy(onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); | 374 SetPolicy(onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); |
334 message_loop_.RunUntilIdle(); | 375 message_loop_.RunUntilIdle(); |
335 } | 376 } |
336 | 377 |
337 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) { | 378 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) { |
338 InitializeStandardProfiles(); | 379 InitializeStandardProfiles(); |
339 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", | 380 SetUpEntry("policy/shill_unmanaged_user_wifi1.json", |
340 kUser1ProfilePath, | 381 kUser1ProfilePath, |
341 "old_entry_path"); | 382 "old_entry_path"); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 ConfigureServiceForProfile( | 605 ConfigureServiceForProfile( |
565 dbus::ObjectPath(kUser1ProfilePath), | 606 dbus::ObjectPath(kUser1ProfilePath), |
566 IsEqualTo(expected_shill_properties.get()), | 607 IsEqualTo(expected_shill_properties.get()), |
567 _, _)); | 608 _, _)); |
568 | 609 |
569 InitializeStandardProfiles(); | 610 InitializeStandardProfiles(); |
570 message_loop_.RunUntilIdle(); | 611 message_loop_.RunUntilIdle(); |
571 } | 612 } |
572 | 613 |
573 } // namespace chromeos | 614 } // namespace chromeos |
OLD | NEW |