| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 void SetupNetworkHandlers() { | 101 void SetupNetworkHandlers() { |
| 102 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); | 102 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); |
| 103 network_cert_migrator_.reset(new NetworkCertMigrator); | 103 network_cert_migrator_.reset(new NetworkCertMigrator); |
| 104 network_cert_migrator_->Init(network_state_handler_.get()); | 104 network_cert_migrator_->Init(network_state_handler_.get()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void SetupWifiWithNss() { | 107 void SetupWifiWithNss() { |
| 108 const bool add_to_visible = true; | 108 const bool add_to_visible = true; |
| 109 const bool add_to_watchlist = true; | |
| 110 service_test_->AddService(kWifiStub, | 109 service_test_->AddService(kWifiStub, |
| 111 kWifiStub, | 110 kWifiStub, |
| 112 shill::kTypeWifi, | 111 shill::kTypeWifi, |
| 113 shill::kStateOnline, | 112 shill::kStateOnline, |
| 114 add_to_visible, | 113 add_to_visible); |
| 115 add_to_watchlist); | |
| 116 service_test_->SetServiceProperty(kWifiStub, | 114 service_test_->SetServiceProperty(kWifiStub, |
| 117 shill::kEapCaCertNssProperty, | 115 shill::kEapCaCertNssProperty, |
| 118 base::StringValue(kNSSNickname)); | 116 base::StringValue(kNSSNickname)); |
| 119 } | 117 } |
| 120 | 118 |
| 121 void GetEapCACertProperties(std::string* nss_nickname, std::string* ca_pem) { | 119 void GetEapCACertProperties(std::string* nss_nickname, std::string* ca_pem) { |
| 122 nss_nickname->clear(); | 120 nss_nickname->clear(); |
| 123 ca_pem->clear(); | 121 ca_pem->clear(); |
| 124 const base::DictionaryValue* properties = | 122 const base::DictionaryValue* properties = |
| 125 service_test_->GetServiceProperties(kWifiStub); | 123 service_test_->GetServiceProperties(kWifiStub); |
| 126 properties->GetStringWithoutPathExpansion(shill::kEapCaCertNssProperty, | 124 properties->GetStringWithoutPathExpansion(shill::kEapCaCertNssProperty, |
| 127 nss_nickname); | 125 nss_nickname); |
| 128 const base::ListValue* ca_pems = NULL; | 126 const base::ListValue* ca_pems = NULL; |
| 129 properties->GetListWithoutPathExpansion(shill::kEapCaCertPemProperty, | 127 properties->GetListWithoutPathExpansion(shill::kEapCaCertPemProperty, |
| 130 &ca_pems); | 128 &ca_pems); |
| 131 if (ca_pems && !ca_pems->empty()) | 129 if (ca_pems && !ca_pems->empty()) |
| 132 ca_pems->GetString(0, ca_pem); | 130 ca_pems->GetString(0, ca_pem); |
| 133 } | 131 } |
| 134 | 132 |
| 135 void SetupVpnWithNss(bool open_vpn) { | 133 void SetupVpnWithNss(bool open_vpn) { |
| 136 const bool add_to_visible = true; | 134 const bool add_to_visible = true; |
| 137 const bool add_to_watchlist = true; | |
| 138 service_test_->AddService(kVPNStub, | 135 service_test_->AddService(kVPNStub, |
| 139 kVPNStub, | 136 kVPNStub, |
| 140 shill::kTypeVPN, | 137 shill::kTypeVPN, |
| 141 shill::kStateIdle, | 138 shill::kStateIdle, |
| 142 add_to_visible, | 139 add_to_visible); |
| 143 add_to_watchlist); | |
| 144 base::DictionaryValue provider; | 140 base::DictionaryValue provider; |
| 145 const char* nss_property = open_vpn ? shill::kOpenVPNCaCertNSSProperty | 141 const char* nss_property = open_vpn ? shill::kOpenVPNCaCertNSSProperty |
| 146 : shill::kL2tpIpsecCaCertNssProperty; | 142 : shill::kL2tpIpsecCaCertNssProperty; |
| 147 provider.SetStringWithoutPathExpansion(nss_property, kNSSNickname); | 143 provider.SetStringWithoutPathExpansion(nss_property, kNSSNickname); |
| 148 service_test_->SetServiceProperty( | 144 service_test_->SetServiceProperty( |
| 149 kVPNStub, shill::kProviderProperty, provider); | 145 kVPNStub, shill::kProviderProperty, provider); |
| 150 } | 146 } |
| 151 | 147 |
| 152 void GetVpnCACertProperties(bool open_vpn, | 148 void GetVpnCACertProperties(bool open_vpn, |
| 153 std::string* nss_nickname, | 149 std::string* nss_nickname, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 SetupNetworkHandlers(); | 254 SetupNetworkHandlers(); |
| 259 | 255 |
| 260 base::RunLoop().RunUntilIdle(); | 256 base::RunLoop().RunUntilIdle(); |
| 261 std::string nss_nickname, ca_pem; | 257 std::string nss_nickname, ca_pem; |
| 262 GetVpnCACertProperties(false /* not OpenVPN */, &nss_nickname, &ca_pem); | 258 GetVpnCACertProperties(false /* not OpenVPN */, &nss_nickname, &ca_pem); |
| 263 EXPECT_TRUE(nss_nickname.empty()); | 259 EXPECT_TRUE(nss_nickname.empty()); |
| 264 EXPECT_EQ(test_ca_cert_pem_, ca_pem); | 260 EXPECT_EQ(test_ca_cert_pem_, ca_pem); |
| 265 } | 261 } |
| 266 | 262 |
| 267 } // namespace chromeos | 263 } // namespace chromeos |
| OLD | NEW |