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

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

Issue 11970012: Add a check for server and CA certificates in device policies to the ONC validator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit tests. Created 7 years, 11 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
« no previous file with comments | « chrome/browser/chromeos/cros/network_library_impl_base.cc ('k') | chromeos/docs/onc_spec.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_TRUE(wifi1->connected()); 317 EXPECT_TRUE(wifi1->connected());
318 } 318 }
319 319
320 TEST_F(NetworkLibraryStubTest, NetworkConnectWifiWithCertPattern) { 320 TEST_F(NetworkLibraryStubTest, NetworkConnectWifiWithCertPattern) {
321 scoped_ptr<base::DictionaryValue> onc_root = 321 scoped_ptr<base::DictionaryValue> onc_root =
322 onc::test_utils::ReadTestDictionary("toplevel_wifi_eap_clientcert.onc"); 322 onc::test_utils::ReadTestDictionary("toplevel_wifi_eap_clientcert.onc");
323 base::ListValue* certificates; 323 base::ListValue* certificates;
324 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, 324 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates,
325 &certificates); 325 &certificates);
326 326
327 onc::CertificateImporter importer(onc::ONC_SOURCE_USER_IMPORT, 327 onc::CertificateImporter importer(true /* allow webtrust */);
328 false /* don't allow webtrust */);
329 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK, 328 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK,
330 importer.ParseAndStoreCertificates(*certificates)); 329 importer.ParseAndStoreCertificates(*certificates));
331 330
332 WifiNetwork* wifi = cros_->FindWifiNetworkByPath("wifi_cert_pattern"); 331 WifiNetwork* wifi = cros_->FindWifiNetworkByPath("wifi_cert_pattern");
333 332
334 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); 333 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate();
335 wifi->SetEnrollmentDelegate(enrollment_delegate); 334 wifi->SetEnrollmentDelegate(enrollment_delegate);
336 EXPECT_FALSE(enrollment_delegate->did_enroll); 335 EXPECT_FALSE(enrollment_delegate->did_enroll);
337 EXPECT_FALSE(enrollment_delegate->correct_args); 336 EXPECT_FALSE(enrollment_delegate->correct_args);
338 337
339 ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi); 338 ASSERT_NE(static_cast<const WifiNetwork*>(NULL), wifi);
340 EXPECT_FALSE(wifi->connected()); 339 EXPECT_FALSE(wifi->connected());
341 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi)); 340 EXPECT_TRUE(cros_->CanConnectToNetwork(wifi));
342 EXPECT_FALSE(wifi->connected()); 341 EXPECT_FALSE(wifi->connected());
343 wifi->AttemptConnection( 342 wifi->AttemptConnection(
344 base::Bind(&WifiNetworkConnectCallback, cros_, wifi)); 343 base::Bind(&WifiNetworkConnectCallback, cros_, wifi));
345 EXPECT_TRUE(wifi->connected()); 344 EXPECT_TRUE(wifi->connected());
346 EXPECT_TRUE(enrollment_delegate->did_enroll); 345 EXPECT_TRUE(enrollment_delegate->did_enroll);
347 EXPECT_TRUE(enrollment_delegate->correct_args); 346 EXPECT_TRUE(enrollment_delegate->correct_args);
348 } 347 }
349 348
350 TEST_F(NetworkLibraryStubTest, NetworkConnectVPNWithCertPattern) { 349 TEST_F(NetworkLibraryStubTest, NetworkConnectVPNWithCertPattern) {
351 scoped_ptr<base::DictionaryValue> onc_root = 350 scoped_ptr<base::DictionaryValue> onc_root =
352 onc::test_utils::ReadTestDictionary("toplevel_openvpn_clientcert.onc"); 351 onc::test_utils::ReadTestDictionary("toplevel_openvpn_clientcert.onc");
353 base::ListValue* certificates; 352 base::ListValue* certificates;
354 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates, 353 onc_root->GetListWithoutPathExpansion(onc::toplevel_config::kCertificates,
355 &certificates); 354 &certificates);
356 355
357 onc::CertificateImporter importer(onc::ONC_SOURCE_USER_IMPORT, 356 onc::CertificateImporter importer(true /* allow webtrust */);
358 false /* don't allow webtrust */);
359 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK, 357 ASSERT_EQ(onc::CertificateImporter::IMPORT_OK,
360 importer.ParseAndStoreCertificates(*certificates)); 358 importer.ParseAndStoreCertificates(*certificates));
361 359
362 VirtualNetwork* vpn = cros_->FindVirtualNetworkByPath("vpn_cert_pattern"); 360 VirtualNetwork* vpn = cros_->FindVirtualNetworkByPath("vpn_cert_pattern");
363 361
364 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate(); 362 StubEnrollmentDelegate* enrollment_delegate = new StubEnrollmentDelegate();
365 vpn->SetEnrollmentDelegate(enrollment_delegate); 363 vpn->SetEnrollmentDelegate(enrollment_delegate);
366 EXPECT_FALSE(enrollment_delegate->did_enroll); 364 EXPECT_FALSE(enrollment_delegate->did_enroll);
367 EXPECT_FALSE(enrollment_delegate->correct_args); 365 EXPECT_FALSE(enrollment_delegate->correct_args);
368 366
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 495
498 // TODO(stevenjb): Test network profiles. 496 // TODO(stevenjb): Test network profiles.
499 497
500 // TODO(stevenjb): Test network devices. 498 // TODO(stevenjb): Test network devices.
501 499
502 // TODO(stevenjb): Test data plans. 500 // TODO(stevenjb): Test data plans.
503 501
504 // TODO(stevenjb): Test monitor network / device. 502 // TODO(stevenjb): Test monitor network / device.
505 503
506 } // namespace chromeos 504 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library_impl_base.cc ('k') | chromeos/docs/onc_spec.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698