OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chromeos/network/network_cert_migrator.h" | 5 #include "chromeos/network/network_cert_migrator.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "chromeos/cert_loader.h" | 13 #include "chromeos/cert_loader.h" |
14 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
15 #include "chromeos/dbus/shill_profile_client.h" | 15 #include "chromeos/dbus/shill_profile_client.h" |
16 #include "chromeos/dbus/shill_service_client.h" | 16 #include "chromeos/dbus/shill_service_client.h" |
17 #include "chromeos/network/network_state_handler.h" | 17 #include "chromeos/network/network_state_handler.h" |
18 #include "chromeos/tpm_token_loader.h" | 18 #include "chromeos/tpm_token_loader.h" |
19 #include "crypto/nss_util_internal.h" | 19 #include "crypto/nss_util_internal.h" |
20 #include "crypto/scoped_test_nss_chromeos_user.h" | 20 #include "crypto/scoped_test_nss_chromeos_user.h" |
21 #include "net/base/crypto_module.h" | 21 #include "net/base/crypto_module.h" |
22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
23 #include "net/base/test_data_directory.h" | 23 #include "net/base/test_data_directory.h" |
24 #include "net/cert/nss_cert_database_chromeos.h" | 24 #include "net/cert/nss_cert_database_chromeos.h" |
25 #include "net/cert/x509_certificate.h" | 25 #include "net/cert/x509_certificate.h" |
26 #include "net/test/cert_test_util.h" | 26 #include "net/test/cert_test_util.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "third_party/cros_system_api/dbus/service_constants.h" | 28 #include "third_party/cros_system_api/dbus/service_constants.h" |
29 | 29 |
| 30 // http://crbug.com/418369 |
| 31 #ifndef NDEBUG |
| 32 |
30 namespace chromeos { | 33 namespace chromeos { |
31 | 34 |
32 namespace { | 35 namespace { |
33 | 36 |
34 const char* kWifiStub = "wifi_stub"; | 37 const char* kWifiStub = "wifi_stub"; |
35 const char* kEthernetEapStub = "ethernet_eap_stub"; | 38 const char* kEthernetEapStub = "ethernet_eap_stub"; |
36 const char* kVPNStub = "vpn_stub"; | 39 const char* kVPNStub = "vpn_stub"; |
37 const char* kNSSNickname = "nss_nickname"; | 40 const char* kNSSNickname = "nss_nickname"; |
38 const char* kFakePEM = "pem"; | 41 const char* kFakePEM = "pem"; |
39 const char* kProfile = "/profile/profile1"; | 42 const char* kProfile = "/profile/profile1"; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 303 } |
301 | 304 |
302 scoped_ptr<NetworkStateHandler> network_state_handler_; | 305 scoped_ptr<NetworkStateHandler> network_state_handler_; |
303 scoped_ptr<NetworkCertMigrator> network_cert_migrator_; | 306 scoped_ptr<NetworkCertMigrator> network_cert_migrator_; |
304 crypto::ScopedTestNSSChromeOSUser user_; | 307 crypto::ScopedTestNSSChromeOSUser user_; |
305 scoped_ptr<net::NSSCertDatabaseChromeOS> test_nssdb_; | 308 scoped_ptr<net::NSSCertDatabaseChromeOS> test_nssdb_; |
306 | 309 |
307 DISALLOW_COPY_AND_ASSIGN(NetworkCertMigratorTest); | 310 DISALLOW_COPY_AND_ASSIGN(NetworkCertMigratorTest); |
308 }; | 311 }; |
309 | 312 |
310 // http://crbug.com/418369 | |
311 #ifndef NDEBUG | |
312 TEST_F(NetworkCertMigratorTest, MigrateNssOnInitialization) { | 313 TEST_F(NetworkCertMigratorTest, MigrateNssOnInitialization) { |
313 // Add a new network for migration before the handlers are initialized. | 314 // Add a new network for migration before the handlers are initialized. |
314 SetupWifiWithNss(); | 315 SetupWifiWithNss(); |
315 SetupTestCACert(); | 316 SetupTestCACert(); |
316 SetupNetworkHandlers(); | 317 SetupNetworkHandlers(); |
317 | 318 |
318 base::RunLoop().RunUntilIdle(); | 319 base::RunLoop().RunUntilIdle(); |
319 std::string nss_nickname, ca_pem; | 320 std::string nss_nickname, ca_pem; |
320 GetEapCACertProperties(&nss_nickname, &ca_pem); | 321 GetEapCACertProperties(&nss_nickname, &ca_pem); |
321 EXPECT_TRUE(nss_nickname.empty()); | 322 EXPECT_TRUE(nss_nickname.empty()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 500 |
500 base::RunLoop().RunUntilIdle(); | 501 base::RunLoop().RunUntilIdle(); |
501 | 502 |
502 std::string pkcs11_id; | 503 std::string pkcs11_id; |
503 std::string slot_id; | 504 std::string slot_id; |
504 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); | 505 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); |
505 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); | 506 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); |
506 EXPECT_EQ(test_client_cert_slot_id_, slot_id); | 507 EXPECT_EQ(test_client_cert_slot_id_, slot_id); |
507 } | 508 } |
508 | 509 |
| 510 } // namespace chromeos |
| 511 |
509 #endif | 512 #endif |
510 | |
511 } // namespace chromeos | |
OLD | NEW |