| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/network/auto_connect_handler.h" | 5 #include "chromeos/network/auto_connect_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/test/scoped_task_scheduler.h" |
| 18 #include "chromeos/cert_loader.h" | 19 #include "chromeos/cert_loader.h" |
| 19 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chromeos/dbus/shill_device_client.h" | 21 #include "chromeos/dbus/shill_device_client.h" |
| 21 #include "chromeos/dbus/shill_manager_client.h" | 22 #include "chromeos/dbus/shill_manager_client.h" |
| 22 #include "chromeos/dbus/shill_profile_client.h" | 23 #include "chromeos/dbus/shill_profile_client.h" |
| 23 #include "chromeos/dbus/shill_service_client.h" | 24 #include "chromeos/dbus/shill_service_client.h" |
| 24 #include "chromeos/network/client_cert_resolver.h" | 25 #include "chromeos/network/client_cert_resolver.h" |
| 25 #include "chromeos/network/managed_network_configuration_handler_impl.h" | 26 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
| 26 #include "chromeos/network/network_configuration_handler.h" | 27 #include "chromeos/network/network_configuration_handler.h" |
| 27 #include "chromeos/network/network_profile_handler.h" | 28 #include "chromeos/network/network_profile_handler.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 private: | 71 private: |
| 71 bool changed_network_properties_; | 72 bool changed_network_properties_; |
| 72 ClientCertResolver* cert_resolver_; | 73 ClientCertResolver* cert_resolver_; |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 } // namespace | 76 } // namespace |
| 76 | 77 |
| 77 class AutoConnectHandlerTest : public testing::Test { | 78 class AutoConnectHandlerTest : public testing::Test { |
| 78 public: | 79 public: |
| 79 AutoConnectHandlerTest() | 80 AutoConnectHandlerTest() |
| 80 : test_manager_client_(nullptr), test_service_client_(nullptr) {} | 81 : test_manager_client_(nullptr), |
| 82 test_service_client_(nullptr), |
| 83 scoped_task_scheduler_(&message_loop_) {} |
| 81 | 84 |
| 82 void SetUp() override { | 85 void SetUp() override { |
| 83 ASSERT_TRUE(test_nssdb_.is_open()); | 86 ASSERT_TRUE(test_nssdb_.is_open()); |
| 84 | 87 |
| 85 // Use the same DB for public and private slot. | 88 // Use the same DB for public and private slot. |
| 86 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 89 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
| 87 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 90 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
| 88 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 91 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
| 89 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); | 92 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); |
| 90 | 93 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 | 123 |
| 121 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl()); | 124 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl()); |
| 122 managed_config_handler_->Init( | 125 managed_config_handler_->Init( |
| 123 network_state_handler_.get(), network_profile_handler_.get(), | 126 network_state_handler_.get(), network_profile_handler_.get(), |
| 124 network_config_handler_.get(), nullptr /* network_device_handler */, | 127 network_config_handler_.get(), nullptr /* network_device_handler */, |
| 125 nullptr /* prohibited_technologies_handler */); | 128 nullptr /* prohibited_technologies_handler */); |
| 126 | 129 |
| 127 client_cert_resolver_.reset(new ClientCertResolver()); | 130 client_cert_resolver_.reset(new ClientCertResolver()); |
| 128 client_cert_resolver_->Init(network_state_handler_.get(), | 131 client_cert_resolver_->Init(network_state_handler_.get(), |
| 129 managed_config_handler_.get()); | 132 managed_config_handler_.get()); |
| 130 client_cert_resolver_->SetSlowTaskRunnerForTest( | |
| 131 message_loop_.task_runner()); | |
| 132 | 133 |
| 133 auto_connect_handler_.reset(new AutoConnectHandler()); | 134 auto_connect_handler_.reset(new AutoConnectHandler()); |
| 134 auto_connect_handler_->Init(client_cert_resolver_.get(), | 135 auto_connect_handler_->Init(client_cert_resolver_.get(), |
| 135 nullptr, // no connection handler | 136 nullptr, // no connection handler |
| 136 network_state_handler_.get(), | 137 network_state_handler_.get(), |
| 137 managed_config_handler_.get()); | 138 managed_config_handler_.get()); |
| 138 | 139 |
| 139 base::RunLoop().RunUntilIdle(); | 140 base::RunLoop().RunUntilIdle(); |
| 140 } | 141 } |
| 141 | 142 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 247 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
| 247 managed_config_handler_; | 248 managed_config_handler_; |
| 248 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 249 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
| 249 ShillManagerClient::TestInterface* test_manager_client_; | 250 ShillManagerClient::TestInterface* test_manager_client_; |
| 250 ShillServiceClient::TestInterface* test_service_client_; | 251 ShillServiceClient::TestInterface* test_service_client_; |
| 251 crypto::ScopedTestNSSDB test_nssdb_; | 252 crypto::ScopedTestNSSDB test_nssdb_; |
| 252 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 253 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
| 253 base::MessageLoopForUI message_loop_; | 254 base::MessageLoopForUI message_loop_; |
| 254 | 255 |
| 255 private: | 256 private: |
| 257 base::test::ScopedTaskScheduler scoped_task_scheduler_; |
| 258 |
| 256 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); | 259 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); |
| 257 }; | 260 }; |
| 258 | 261 |
| 259 namespace { | 262 namespace { |
| 260 | 263 |
| 261 const char* kConfigUnmanagedSharedConnected = | 264 const char* kConfigUnmanagedSharedConnected = |
| 262 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " | 265 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " |
| 263 " \"Security\": \"wpa\" }"; | 266 " \"Security\": \"wpa\" }"; |
| 264 const char* kConfigManagedSharedConnectable = | 267 const char* kConfigManagedSharedConnectable = |
| 265 "{ \"GUID\": \"wifi1\", \"Type\": \"wifi\", \"State\": \"idle\", " | 268 "{ \"GUID\": \"wifi1\", \"Type\": \"wifi\", \"State\": \"idle\", " |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 // Applying the user policy after login would usually trigger connecting to | 506 // Applying the user policy after login would usually trigger connecting to |
| 504 // the 'best' network. But the manual connect prevents this. | 507 // the 'best' network. But the manual connect prevents this. |
| 505 SetupPolicy(std::string(), // no network configs | 508 SetupPolicy(std::string(), // no network configs |
| 506 base::DictionaryValue(), // no global config | 509 base::DictionaryValue(), // no global config |
| 507 true); // load as user policy | 510 true); // load as user policy |
| 508 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); | 511 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
| 509 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 512 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
| 510 } | 513 } |
| 511 | 514 |
| 512 } // namespace chromeos | 515 } // namespace chromeos |
| OLD | NEW |