| 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 <cert.h> | 5 #include <cert.h> |
| 6 #include <pk11pub.h> | 6 #include <pk11pub.h> |
| 7 | 7 |
| 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/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "chrome/browser/chromeos/cros/cros_library.h" | 18 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 19 #include "chrome/browser/chromeos/cros/network_library.h" | 19 #include "chrome/browser/chromeos/cros/network_library.h" |
| 20 #include "chrome/browser/chromeos/cros/onc_constants.h" | |
| 21 #include "chrome/browser/chromeos/cros/onc_network_parser.h" | 20 #include "chrome/browser/chromeos/cros/onc_network_parser.h" |
| 22 #include "chrome/browser/chromeos/network_settings/onc_certificate_importer.h" | |
| 23 #include "chrome/browser/chromeos/network_settings/onc_utils.h" | |
| 24 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chromeos/network/onc/onc_certificate_importer.h" |
| 23 #include "chromeos/network/onc/onc_constants.h" |
| 24 #include "chromeos/network/onc/onc_utils.h" |
| 25 #include "crypto/nss_util.h" | 25 #include "crypto/nss_util.h" |
| 26 #include "net/base/crypto_module.h" | 26 #include "net/base/crypto_module.h" |
| 27 #include "net/base/nss_cert_database.h" | 27 #include "net/base/nss_cert_database.h" |
| 28 #include "net/base/x509_certificate.h" | 28 #include "net/base/x509_certificate.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::Return; | 32 using ::testing::Return; |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 cros_->ConnectToWifiNetwork(wifi1); | 297 cros_->ConnectToWifiNetwork(wifi1); |
| 298 EXPECT_TRUE(wifi1->connected()); | 298 EXPECT_TRUE(wifi1->connected()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 TEST_F(NetworkLibraryStubTest, NetworkConnectOncWifi) { | 301 TEST_F(NetworkLibraryStubTest, NetworkConnectOncWifi) { |
| 302 // Import a wireless network via loading an ONC file. | 302 // Import a wireless network via loading an ONC file. |
| 303 scoped_ptr<base::ListValue> network_configs; | 303 scoped_ptr<base::ListValue> network_configs; |
| 304 scoped_ptr<base::ListValue> certificates; | 304 scoped_ptr<base::ListValue> certificates; |
| 305 GetTestData("cert-pattern.onc", &certificates, &network_configs); | 305 GetTestData("cert-pattern.onc", &certificates, &network_configs); |
| 306 | 306 |
| 307 onc::CertificateImporter importer(NetworkUIData::ONC_SOURCE_USER_IMPORT, | 307 onc::CertificateImporter importer(onc::ONC_SOURCE_USER_IMPORT, |
| 308 false /* don't allow webtrust */); | 308 false /* don't allow webtrust */); |
| 309 EXPECT_TRUE(importer.ParseAndStoreCertificates(*certificates, NULL)); | 309 EXPECT_TRUE(importer.ParseAndStoreCertificates(*certificates, NULL)); |
| 310 | 310 |
| 311 OncNetworkParser parser(*network_configs, | 311 OncNetworkParser parser(*network_configs, |
| 312 NetworkUIData::ONC_SOURCE_USER_IMPORT); | 312 onc::ONC_SOURCE_USER_IMPORT); |
| 313 ASSERT_TRUE(parser.parse_error().empty()); | 313 ASSERT_TRUE(parser.parse_error().empty()); |
| 314 EXPECT_EQ(1, parser.GetNetworkConfigsSize()); | 314 EXPECT_EQ(1, parser.GetNetworkConfigsSize()); |
| 315 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL)); | 315 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL)); |
| 316 ASSERT_TRUE(network.get()); | 316 ASSERT_TRUE(network.get()); |
| 317 EXPECT_EQ(CLIENT_CERT_TYPE_PATTERN, network->client_cert_type()); | 317 EXPECT_EQ(CLIENT_CERT_TYPE_PATTERN, network->client_cert_type()); |
| 318 | 318 |
| 319 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); | 319 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); |
| 320 | 320 |
| 321 network->SetEnrollmentDelegate(enrollment_delegate); | 321 network->SetEnrollmentDelegate(enrollment_delegate); |
| 322 EXPECT_FALSE(enrollment_delegate->did_enroll); | 322 EXPECT_FALSE(enrollment_delegate->did_enroll); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 333 EXPECT_TRUE(enrollment_delegate->did_enroll); | 333 EXPECT_TRUE(enrollment_delegate->did_enroll); |
| 334 EXPECT_TRUE(enrollment_delegate->correct_args); | 334 EXPECT_TRUE(enrollment_delegate->correct_args); |
| 335 } | 335 } |
| 336 | 336 |
| 337 TEST_F(NetworkLibraryStubTest, NetworkConnectOncVPN) { | 337 TEST_F(NetworkLibraryStubTest, NetworkConnectOncVPN) { |
| 338 // Import a wireless network via loading an ONC file. | 338 // Import a wireless network via loading an ONC file. |
| 339 scoped_ptr<base::ListValue> network_configs; | 339 scoped_ptr<base::ListValue> network_configs; |
| 340 scoped_ptr<base::ListValue> certificates; | 340 scoped_ptr<base::ListValue> certificates; |
| 341 GetTestData("cert-pattern-vpn.onc", &certificates, &network_configs); | 341 GetTestData("cert-pattern-vpn.onc", &certificates, &network_configs); |
| 342 | 342 |
| 343 onc::CertificateImporter importer(NetworkUIData::ONC_SOURCE_USER_IMPORT, | 343 onc::CertificateImporter importer(onc::ONC_SOURCE_USER_IMPORT, |
| 344 false /* don't allow webtrust */); | 344 false /* don't allow webtrust */); |
| 345 EXPECT_TRUE(importer.ParseAndStoreCertificates(*certificates, NULL)); | 345 EXPECT_TRUE(importer.ParseAndStoreCertificates(*certificates, NULL)); |
| 346 | 346 |
| 347 OncNetworkParser parser(*network_configs, | 347 OncNetworkParser parser(*network_configs, |
| 348 NetworkUIData::ONC_SOURCE_USER_IMPORT); | 348 onc::ONC_SOURCE_USER_IMPORT); |
| 349 ASSERT_TRUE(parser.parse_error().empty()); | 349 ASSERT_TRUE(parser.parse_error().empty()); |
| 350 EXPECT_EQ(1, parser.GetNetworkConfigsSize()); | 350 EXPECT_EQ(1, parser.GetNetworkConfigsSize()); |
| 351 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL)); | 351 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL)); |
| 352 ASSERT_TRUE(network.get()); | 352 ASSERT_TRUE(network.get()); |
| 353 EXPECT_EQ(CLIENT_CERT_TYPE_PATTERN, network->client_cert_type()); | 353 EXPECT_EQ(CLIENT_CERT_TYPE_PATTERN, network->client_cert_type()); |
| 354 | 354 |
| 355 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); | 355 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); |
| 356 | 356 |
| 357 network->SetEnrollmentDelegate(enrollment_delegate); | 357 network->SetEnrollmentDelegate(enrollment_delegate); |
| 358 EXPECT_FALSE(enrollment_delegate->did_enroll); | 358 EXPECT_FALSE(enrollment_delegate->did_enroll); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 385 | 385 |
| 386 // TODO(stevenjb): Test network profiles. | 386 // TODO(stevenjb): Test network profiles. |
| 387 | 387 |
| 388 // TODO(stevenjb): Test network devices. | 388 // TODO(stevenjb): Test network devices. |
| 389 | 389 |
| 390 // TODO(stevenjb): Test data plans. | 390 // TODO(stevenjb): Test data plans. |
| 391 | 391 |
| 392 // TODO(stevenjb): Test monitor network / device. | 392 // TODO(stevenjb): Test monitor network / device. |
| 393 | 393 |
| 394 } // namespace chromeos | 394 } // namespace chromeos |
| OLD | NEW |