Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/browser/chromeos/cros/network_library_unittest.cc

Issue 16946002: Resolve certificate references in ONC by PEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed automation part. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 onc_blob->GetListWithoutPathExpansion( 170 onc_blob->GetListWithoutPathExpansion(
171 onc::toplevel_config::kNetworkConfigurations, 171 onc::toplevel_config::kNetworkConfigurations,
172 &onc_network_configs); 172 &onc_network_configs);
173 ASSERT_TRUE(onc_network_configs); 173 ASSERT_TRUE(onc_network_configs);
174 174
175 scoped_ptr<base::Value> expected_value = 175 scoped_ptr<base::Value> expected_value =
176 google_apis::test_util::LoadJSONFile(shill_json); 176 google_apis::test_util::LoadJSONFile(shill_json);
177 base::DictionaryValue* expected_configs; 177 base::DictionaryValue* expected_configs;
178 expected_value->GetAsDictionary(&expected_configs); 178 expected_value->GetAsDictionary(&expected_configs);
179 179
180 cros_->LoadOncNetworks(*onc_network_configs, source); 180 cros_->LoadOncNetworks(*onc_network_configs, source,
181 base::Bind(&onc::test_utils::FakeFingerprintToPEM));
181 182
182 const std::map<std::string, base::DictionaryValue*>& configs = 183 const std::map<std::string, base::DictionaryValue*>& configs =
183 cros_->GetConfigurations(); 184 cros_->GetConfigurations();
184 185
185 EXPECT_EQ(expected_configs->size(), configs.size()); 186 EXPECT_EQ(expected_configs->size(), configs.size());
186 187
187 for (base::DictionaryValue::Iterator it(*expected_configs); !it.IsAtEnd(); 188 for (base::DictionaryValue::Iterator it(*expected_configs); !it.IsAtEnd();
188 it.Advance()) { 189 it.Advance()) {
189 const base::DictionaryValue* expected_config; 190 const base::DictionaryValue* expected_config;
190 it.value().GetAsDictionary(&expected_config); 191 it.value().GetAsDictionary(&expected_config);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 EXPECT_TRUE(wifi1->connected()); 285 EXPECT_TRUE(wifi1->connected());
285 cros_->DisconnectFromNetwork(wifi1); 286 cros_->DisconnectFromNetwork(wifi1);
286 EXPECT_FALSE(wifi1->connected()); 287 EXPECT_FALSE(wifi1->connected());
287 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi1)); 288 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi1));
288 cros_->ConnectToWifiNetwork(wifi1); 289 cros_->ConnectToWifiNetwork(wifi1);
289 EXPECT_TRUE(wifi1->connected()); 290 EXPECT_TRUE(wifi1->connected());
290 } 291 }
291 292
292 TEST_F(NetworkLibraryStubTest, NetworkConnectWifiWithCertPattern) { 293 TEST_F(NetworkLibraryStubTest, NetworkConnectWifiWithCertPattern) {
293 scoped_ptr<base::DictionaryValue> onc_root = 294 scoped_ptr<base::DictionaryValue> onc_root =
294 onc::test_utils::ReadTestDictionary("toplevel_wifi_eap_clientcert.onc"); 295 onc::test_utils::ReadTestDictionary("certificate-client.onc");
295 base::ListValue* certificates; 296 base::ListValue* certificates;
296 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, 297 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates,
297 &certificates); 298 &certificates);
298 299
299 onc::CertificateImporter importer(true /* allow trust imports */); 300 onc::CertificateImporter importer(true /* allow trust imports */);
300 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK, 301 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK,
301 importer.ParseAndStoreCertificates(*certificates, NULL)); 302 importer.ParseAndStoreCertificates(*certificates, NULL, NULL));
302 303
303 WifiNetwork* wifi = cros_->FindWifiNetworkByPath("wifi_cert_pattern"); 304 WifiNetwork* wifi = cros_->FindWifiNetworkByPath("wifi_cert_pattern");
304 305
305 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); 306 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate();
306 wifi->SetEnrollmentDelegate(enrollment_delegate); 307 wifi->SetEnrollmentDelegate(enrollment_delegate);
307 EXPECT_FALSE(enrollment_delegate->did_enroll); 308 EXPECT_FALSE(enrollment_delegate->did_enroll);
308 EXPECT_FALSE(enrollment_delegate->correct_args); 309 EXPECT_FALSE(enrollment_delegate->correct_args);
309 310
310 ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi); 311 ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi);
311 EXPECT_FALSE(wifi->connected()); 312 EXPECT_FALSE(wifi->connected());
312 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi)); 313 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi));
313 EXPECT_FALSE(wifi->connected()); 314 EXPECT_FALSE(wifi->connected());
314 wifi->AttemptConnection( 315 wifi->AttemptConnection(
315 base::Bind(&WifiNetworkConnectCallback, cros_, wifi)); 316 base::Bind(&WifiNetworkConnectCallback, cros_, wifi));
316 EXPECT_TRUE(wifi->connected()); 317 EXPECT_TRUE(wifi->connected());
317 EXPECT_TRUE(enrollment_delegate->did_enroll); 318 EXPECT_TRUE(enrollment_delegate->did_enroll);
318 EXPECT_TRUE(enrollment_delegate->correct_args); 319 EXPECT_TRUE(enrollment_delegate->correct_args);
319 } 320 }
320 321
321 TEST_F(NetworkLibraryStubTest, NetworkConnectVPNWithCertPattern) { 322 TEST_F(NetworkLibraryStubTest, NetworkConnectVPNWithCertPattern) {
322 scoped_ptr<base::DictionaryValue> onc_root = 323 scoped_ptr<base::DictionaryValue> onc_root =
323 onc::test_utils::ReadTestDictionary("toplevel_openvpn_clientcert.onc"); 324 onc::test_utils::ReadTestDictionary("certificate-client.onc");
324 base::ListValue* certificates; 325 base::ListValue* certificates;
325 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, 326 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates,
326 &certificates); 327 &certificates);
327 328
328 onc::CertificateImporter importer(true /* allow trust imports */); 329 onc::CertificateImporter importer(true /* allow trust imports */);
329 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK, 330 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK,
330 importer.ParseAndStoreCertificates(*certificates, NULL)); 331 importer.ParseAndStoreCertificates(*certificates, NULL, NULL));
331 332
332 VirtualNetwork* vpn = cros_->FindVirtualNetworkByPath("vpn_cert_pattern"); 333 VirtualNetwork* vpn = cros_->FindVirtualNetworkByPath("vpn_cert_pattern");
333 334
334 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); 335 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate();
335 vpn->SetEnrollmentDelegate(enrollment_delegate); 336 vpn->SetEnrollmentDelegate(enrollment_delegate);
336 EXPECT_FALSE(enrollment_delegate->did_enroll); 337 EXPECT_FALSE(enrollment_delegate->did_enroll);
337 EXPECT_FALSE(enrollment_delegate->correct_args); 338 EXPECT_FALSE(enrollment_delegate->correct_args);
338 339
339 ASSERT_NE(static_cast<const VirtualNetwork*>(NULL), vpn); 340 ASSERT_NE(static_cast<const VirtualNetwork*>(NULL), vpn);
340 EXPECT_FALSE(vpn->connected()); 341 EXPECT_FALSE(vpn->connected());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 GetParam().expect_import_result); 403 GetParam().expect_import_result);
403 } 404 }
404 405
405 INSTANTIATE_TEST_CASE_P( 406 INSTANTIATE_TEST_CASE_P(
406 LoadOncNetworksTest, 407 LoadOncNetworksTest,
407 LoadOncNetworksTest, 408 LoadOncNetworksTest,
408 ::testing::Values( 409 ::testing::Values(
409 ImportParams("managed_toplevel1_normalized.onc", 410 ImportParams("managed_toplevel1_normalized.onc",
410 "chromeos/net/shill_for_managed_toplevel1.json", 411 "chromeos/net/shill_for_managed_toplevel1.json",
411 onc::ONC_SOURCE_USER_POLICY), 412 onc::ONC_SOURCE_USER_POLICY),
412 ImportParams("managed_toplevel2.onc", 413 ImportParams("managed_toplevel2_with_cert_fingerprints.onc",
413 "chromeos/net/shill_for_managed_toplevel2.json", 414 "chromeos/net/shill_for_managed_toplevel2.json",
414 onc::ONC_SOURCE_USER_POLICY), 415 onc::ONC_SOURCE_USER_POLICY),
415 ImportParams("managed_toplevel_l2tpipsec.onc", 416 ImportParams("managed_toplevel_l2tpipsec.onc",
416 "chromeos/net/shill_for_managed_toplevel_l2tpipsec.json", 417 "chromeos/net/shill_for_managed_toplevel_l2tpipsec.json",
417 onc::ONC_SOURCE_USER_POLICY), 418 onc::ONC_SOURCE_USER_POLICY),
418 ImportParams("managed_toplevel_wifi_peap.onc", 419 ImportParams("managed_toplevel_wifi_peap.onc",
419 "chromeos/net/shill_for_managed_toplevel_wifi_peap.json", 420 "chromeos/net/shill_for_managed_toplevel_wifi_peap.json",
420 onc::ONC_SOURCE_DEVICE_POLICY), 421 onc::ONC_SOURCE_DEVICE_POLICY),
421 ImportParams("toplevel_wifi_open.onc", 422 ImportParams("toplevel_wifi_open.onc",
422 "chromeos/net/shill_for_toplevel_wifi_open.json", 423 "chromeos/net/shill_for_toplevel_wifi_open.json",
423 onc::ONC_SOURCE_DEVICE_POLICY), 424 onc::ONC_SOURCE_DEVICE_POLICY),
424 ImportParams("toplevel_wifi_wep_proxy.onc", 425 ImportParams("toplevel_wifi_wep_proxy.onc",
425 "chromeos/net/shill_for_toplevel_wifi_wep_proxy.json", 426 "chromeos/net/shill_for_toplevel_wifi_wep_proxy.json",
426 onc::ONC_SOURCE_USER_POLICY), 427 onc::ONC_SOURCE_USER_POLICY),
427 ImportParams("toplevel_wifi_wpa_psk.onc", 428 ImportParams("toplevel_wifi_wpa_psk.onc",
428 "chromeos/net/shill_for_toplevel_wifi_wpa_psk.json", 429 "chromeos/net/shill_for_toplevel_wifi_wpa_psk.json",
429 onc::ONC_SOURCE_USER_POLICY), 430 onc::ONC_SOURCE_USER_POLICY),
430 ImportParams("toplevel_wifi_leap.onc", 431 ImportParams("toplevel_wifi_leap.onc",
431 "chromeos/net/shill_for_toplevel_wifi_leap.json", 432 "chromeos/net/shill_for_toplevel_wifi_leap.json",
432 onc::ONC_SOURCE_USER_POLICY), 433 onc::ONC_SOURCE_USER_POLICY),
433 ImportParams( 434 ImportParams(
434 "toplevel_wifi_eap_clientcert.onc", 435 "toplevel_wifi_eap_clientcert_with_cert_fingerprints.onc",
435 "chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json", 436 "chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json",
436 onc::ONC_SOURCE_USER_POLICY), 437 onc::ONC_SOURCE_USER_POLICY),
437 ImportParams("toplevel_openvpn_clientcert.onc", 438 ImportParams("toplevel_openvpn_clientcert_with_cert_fingerprints.onc",
438 "chromeos/net/shill_for_toplevel_openvpn_clientcert.json", 439 "chromeos/net/shill_for_toplevel_openvpn_clientcert.json",
439 onc::ONC_SOURCE_USER_POLICY), 440 onc::ONC_SOURCE_USER_POLICY),
440 ImportParams("toplevel_wifi_remove.onc", 441 ImportParams("toplevel_wifi_remove.onc",
441 "chromeos/net/shill_for_toplevel_wifi_remove.json", 442 "chromeos/net/shill_for_toplevel_wifi_remove.json",
442 onc::ONC_SOURCE_USER_POLICY))); 443 onc::ONC_SOURCE_USER_POLICY)));
443 444
444 // TODO(stevenjb): Test remembered networks. 445 // TODO(stevenjb): Test remembered networks.
445 446
446 // TODO(stevenjb): Test network profiles. 447 // TODO(stevenjb): Test network profiles.
447 448
448 // TODO(stevenjb): Test network devices. 449 // TODO(stevenjb): Test network devices.
449 450
450 // TODO(stevenjb): Test data plans. 451 // TODO(stevenjb): Test data plans.
451 452
452 // TODO(stevenjb): Test monitor network / device. 453 // TODO(stevenjb): Test monitor network / device.
453 454
454 } // namespace chromeos 455 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698