OLD | NEW |
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 <pk11pub.h> | 5 #include <pk11pub.h> |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
18 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h" | 18 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h" |
19 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 19 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
20 #include "chrome/browser/chromeos/login/user_manager.h" | 20 #include "chrome/browser/chromeos/login/user_manager.h" |
21 #include "chrome/browser/google_apis/test_util.h" | 21 #include "chrome/browser/google_apis/test_util.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
23 #include "chromeos/network/onc/onc_certificate_importer.h" | 23 #include "chromeos/network/onc/onc_certificate_importer_impl.h" |
24 #include "chromeos/network/onc/onc_constants.h" | 24 #include "chromeos/network/onc/onc_constants.h" |
25 #include "chromeos/network/onc/onc_test_utils.h" | 25 #include "chromeos/network/onc/onc_test_utils.h" |
26 #include "chromeos/network/onc/onc_utils.h" | 26 #include "chromeos/network/onc/onc_utils.h" |
27 #include "crypto/nss_util.h" | 27 #include "crypto/nss_util.h" |
28 #include "net/base/crypto_module.h" | 28 #include "net/base/crypto_module.h" |
29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 using ::testing::AnyNumber; | 32 using ::testing::AnyNumber; |
33 using ::testing::Return; | 33 using ::testing::Return; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 EXPECT_TRUE(wifi1->connected()); | 287 EXPECT_TRUE(wifi1->connected()); |
288 } | 288 } |
289 | 289 |
290 TEST_F(NetworkLibraryStubTest, NetworkConnectWifiWithCertPattern) { | 290 TEST_F(NetworkLibraryStubTest, NetworkConnectWifiWithCertPattern) { |
291 scoped_ptr<base::DictionaryValue> onc_root = | 291 scoped_ptr<base::DictionaryValue> onc_root = |
292 onc::test_utils::ReadTestDictionary("certificate-client.onc"); | 292 onc::test_utils::ReadTestDictionary("certificate-client.onc"); |
293 base::ListValue* certificates; | 293 base::ListValue* certificates; |
294 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, | 294 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, |
295 &certificates); | 295 &certificates); |
296 | 296 |
297 onc::CertificateImporter importer(true /* allow trust imports */); | 297 onc::CertificateImporterImpl importer; |
298 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK, | 298 ASSERT_TRUE(importer.ImportCertificates( |
299 importer.ParseAndStoreCertificates(*certificates, NULL, NULL)); | 299 *certificates, onc::ONC_SOURCE_USER_IMPORT, NULL)); |
300 | 300 |
301 WifiNetwork* wifi = cros_->FindWifiNetworkByPath("wifi_cert_pattern"); | 301 WifiNetwork* wifi = cros_->FindWifiNetworkByPath("wifi_cert_pattern"); |
302 | 302 |
303 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); | 303 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); |
304 wifi->SetEnrollmentDelegate(enrollment_delegate); | 304 wifi->SetEnrollmentDelegate(enrollment_delegate); |
305 EXPECT_FALSE(enrollment_delegate->did_enroll); | 305 EXPECT_FALSE(enrollment_delegate->did_enroll); |
306 EXPECT_FALSE(enrollment_delegate->correct_args); | 306 EXPECT_FALSE(enrollment_delegate->correct_args); |
307 | 307 |
308 ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi); | 308 ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi); |
309 EXPECT_FALSE(wifi->connected()); | 309 EXPECT_FALSE(wifi->connected()); |
310 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi)); | 310 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi)); |
311 EXPECT_FALSE(wifi->connected()); | 311 EXPECT_FALSE(wifi->connected()); |
312 wifi->AttemptConnection( | 312 wifi->AttemptConnection( |
313 base::Bind(&WifiNetworkConnectCallback, cros_, wifi)); | 313 base::Bind(&WifiNetworkConnectCallback, cros_, wifi)); |
314 EXPECT_TRUE(wifi->connected()); | 314 EXPECT_TRUE(wifi->connected()); |
315 EXPECT_TRUE(enrollment_delegate->did_enroll); | 315 EXPECT_TRUE(enrollment_delegate->did_enroll); |
316 EXPECT_TRUE(enrollment_delegate->correct_args); | 316 EXPECT_TRUE(enrollment_delegate->correct_args); |
317 } | 317 } |
318 | 318 |
319 TEST_F(NetworkLibraryStubTest, NetworkConnectVPNWithCertPattern) { | 319 TEST_F(NetworkLibraryStubTest, NetworkConnectVPNWithCertPattern) { |
320 scoped_ptr<base::DictionaryValue> onc_root = | 320 scoped_ptr<base::DictionaryValue> onc_root = |
321 onc::test_utils::ReadTestDictionary("certificate-client.onc"); | 321 onc::test_utils::ReadTestDictionary("certificate-client.onc"); |
322 base::ListValue* certificates; | 322 base::ListValue* certificates; |
323 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, | 323 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, |
324 &certificates); | 324 &certificates); |
325 | 325 |
326 onc::CertificateImporter importer(true /* allow trust imports */); | 326 onc::CertificateImporterImpl importer; |
327 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK, | 327 ASSERT_TRUE(importer.ImportCertificates( |
328 importer.ParseAndStoreCertificates(*certificates, NULL, NULL)); | 328 *certificates, onc::ONC_SOURCE_USER_IMPORT, NULL)); |
329 | 329 |
330 VirtualNetwork* vpn = cros_->FindVirtualNetworkByPath("vpn_cert_pattern"); | 330 VirtualNetwork* vpn = cros_->FindVirtualNetworkByPath("vpn_cert_pattern"); |
331 | 331 |
332 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); | 332 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); |
333 vpn->SetEnrollmentDelegate(enrollment_delegate); | 333 vpn->SetEnrollmentDelegate(enrollment_delegate); |
334 EXPECT_FALSE(enrollment_delegate->did_enroll); | 334 EXPECT_FALSE(enrollment_delegate->did_enroll); |
335 EXPECT_FALSE(enrollment_delegate->correct_args); | 335 EXPECT_FALSE(enrollment_delegate->correct_args); |
336 | 336 |
337 ASSERT_NE(static_cast<const VirtualNetwork*>(NULL), vpn); | 337 ASSERT_NE(static_cast<const VirtualNetwork*>(NULL), vpn); |
338 EXPECT_FALSE(vpn->connected()); | 338 EXPECT_FALSE(vpn->connected()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 443 |
444 // TODO(stevenjb): Test network profiles. | 444 // TODO(stevenjb): Test network profiles. |
445 | 445 |
446 // TODO(stevenjb): Test network devices. | 446 // TODO(stevenjb): Test network devices. |
447 | 447 |
448 // TODO(stevenjb): Test data plans. | 448 // TODO(stevenjb): Test data plans. |
449 | 449 |
450 // TODO(stevenjb): Test monitor network / device. | 450 // TODO(stevenjb): Test monitor network / device. |
451 | 451 |
452 } // namespace chromeos | 452 } // namespace chromeos |
OLD | NEW |