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

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

Issue 10868113: Disable certificate patterns for device policy ONC files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review changes Created 8 years, 3 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/onc_network_parser.cc ('k') | no next file » | 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 "chrome/browser/chromeos/cros/onc_network_parser.h" 5 #include "chrome/browser/chromeos/cros/onc_network_parser.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <keyhi.h> 8 #include <keyhi.h>
9 #include <pk11pub.h> 9 #include <pk11pub.h>
10 10
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 EXPECT_EQ(chromeos::CLIENT_CERT_TYPE_PATTERN, vpn->client_cert_type()); 324 EXPECT_EQ(chromeos::CLIENT_CERT_TYPE_PATTERN, vpn->client_cert_type());
325 EXPECT_EQ("Google, Inc.", 325 EXPECT_EQ("Google, Inc.",
326 vpn->client_cert_pattern().issuer().organization()); 326 vpn->client_cert_pattern().issuer().organization());
327 ASSERT_EQ(2ul, vpn->client_cert_pattern().enrollment_uri_list().size()); 327 ASSERT_EQ(2ul, vpn->client_cert_pattern().enrollment_uri_list().size());
328 EXPECT_EQ("http://youtu.be/dQw4w9WgXcQ", 328 EXPECT_EQ("http://youtu.be/dQw4w9WgXcQ",
329 vpn->client_cert_pattern().enrollment_uri_list()[0]); 329 vpn->client_cert_pattern().enrollment_uri_list()[0]);
330 EXPECT_EQ("chrome-extension://abc/keygen-cert.html", 330 EXPECT_EQ("chrome-extension://abc/keygen-cert.html",
331 vpn->client_cert_pattern().enrollment_uri_list()[1]); 331 vpn->client_cert_pattern().enrollment_uri_list()[1]);
332 } 332 }
333 333
334 TEST_F(OncNetworkParserTest, TestNoCertificatePatternForDevicePolicy) {
335 std::string test_blob;
336 GetTestData("cert-pattern.onc", &test_blob);
337 OncNetworkParser parser(test_blob, "",
338 NetworkUIData::ONC_SOURCE_DEVICE_POLICY);
339
340 // Make sure we fail when parsing a certificate pattern from a device policy
341 // ONC file.
342 ASSERT_TRUE(parser.parse_error().empty());
343 EXPECT_EQ(1, parser.GetNetworkConfigsSize());
344 EXPECT_EQ(2, parser.GetCertificatesSize());
345 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL));
346 ASSERT_TRUE(network.get());
347
348 EXPECT_EQ(chromeos::TYPE_WIFI, network->type());
349 WifiNetwork* wifi = static_cast<WifiNetwork*>(network.get());
350 EXPECT_EQ(chromeos::SECURITY_8021X, wifi->encryption());
351 EXPECT_EQ("WirelessNetwork", wifi->name());
352 EXPECT_FALSE(wifi->auto_connect());
353 EXPECT_EQ("", wifi->passphrase());
354 EXPECT_EQ(chromeos::EAP_METHOD_TLS, wifi->eap_method());
355 EXPECT_EQ(chromeos::CLIENT_CERT_TYPE_PATTERN, wifi->client_cert_type());
356 EXPECT_EQ("", wifi->client_cert_pattern().issuer().organization());
357 ASSERT_EQ(0ul, wifi->client_cert_pattern().enrollment_uri_list().size());
358 }
359
334 TEST_F(OncNetworkParserTest, TestCreateNetworkWifiEAP1) { 360 TEST_F(OncNetworkParserTest, TestCreateNetworkWifiEAP1) {
335 std::string test_blob; 361 std::string test_blob;
336 GetTestData("network-wifi-eap1.onc", &test_blob); 362 GetTestData("network-wifi-eap1.onc", &test_blob);
337 OncNetworkParser parser(test_blob, "", NetworkUIData::ONC_SOURCE_USER_IMPORT); 363 OncNetworkParser parser(test_blob, "", NetworkUIData::ONC_SOURCE_USER_IMPORT);
338 364
339 EXPECT_EQ(1, parser.GetNetworkConfigsSize()); 365 EXPECT_EQ(1, parser.GetNetworkConfigsSize());
340 EXPECT_EQ(0, parser.GetCertificatesSize()); 366 EXPECT_EQ(0, parser.GetCertificatesSize());
341 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL)); 367 scoped_ptr<Network> network(parser.ParseNetwork(0, NULL));
342 ASSERT_TRUE(network.get()); 368 ASSERT_TRUE(network.get());
343 369
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 EXPECT_EQ(1, parser.GetNetworkConfigsSize()); 973 EXPECT_EQ(1, parser.GetNetworkConfigsSize());
948 EXPECT_EQ(0, parser.GetCertificatesSize()); 974 EXPECT_EQ(0, parser.GetCertificatesSize());
949 bool marked_for_removal = false; 975 bool marked_for_removal = false;
950 scoped_ptr<Network> network(parser.ParseNetwork(0, &marked_for_removal)); 976 scoped_ptr<Network> network(parser.ParseNetwork(0, &marked_for_removal));
951 977
952 EXPECT_TRUE(marked_for_removal); 978 EXPECT_TRUE(marked_for_removal);
953 EXPECT_EQ("{485d6076-dd44-6b6d-69787465725f5045}", network->unique_id()); 979 EXPECT_EQ("{485d6076-dd44-6b6d-69787465725f5045}", network->unique_id());
954 } 980 }
955 981
956 } // namespace chromeos 982 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/onc_network_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698