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

Side by Side Diff: net/base/x509_cert_types_unittest.cc

Issue 5162001: X.509-related cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build breakage Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/basictypes.h"
5 #include "net/base/x509_cert_types.h" 6 #include "net/base/x509_cert_types.h"
6 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
7 8
8 // 0:d=0 hl=2 l= 95 cons: SEQUENCE 9 // 0:d=0 hl=2 l= 95 cons: SEQUENCE
9 // 2:d=1 hl=2 l= 11 cons: SET 10 // 2:d=1 hl=2 l= 11 cons: SET
10 // 4:d=2 hl=2 l= 9 cons: SEQUENCE 11 // 4:d=2 hl=2 l= 9 cons: SEQUENCE
11 // 6:d=3 hl=2 l= 3 prim: OBJECT :countryName 12 // 6:d=3 hl=2 l= 3 prim: OBJECT :countryName
12 // 11:d=3 hl=2 l= 2 prim: PRINTABLESTRING :US 13 // 11:d=3 hl=2 l= 2 prim: PRINTABLESTRING :US
13 // 15:d=1 hl=2 l= 23 cons: SET 14 // 15:d=1 hl=2 l= 23 cons: SET
14 // 17:d=2 hl=2 l= 21 cons: SEQUENCE 15 // 17:d=2 hl=2 l= 21 cons: SEQUENCE
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 0x74, 0x2e, 0x6e, 0x65, 0x74, 0x20, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x65, 0x64, 206 0x74, 0x2e, 0x6e, 0x65, 0x74, 0x20, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x65, 0x64,
206 0x31, 0x33, 0x30, 0x31, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x2a, 0x45, 0x6e, 207 0x31, 0x33, 0x30, 0x31, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x2a, 0x45, 0x6e,
207 0x74, 0x72, 0x75, 0x73, 0x74, 0x2e, 0x6e, 0x65, 0x74, 0x20, 0x43, 0x65, 0x72, 208 0x74, 0x72, 0x75, 0x73, 0x74, 0x2e, 0x6e, 0x65, 0x74, 0x20, 0x43, 0x65, 0x72,
208 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x41, 0x75, 209 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x41, 0x75,
209 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x20, 0x28, 0x32, 0x30, 0x34, 0x38, 210 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x20, 0x28, 0x32, 0x30, 0x34, 0x38,
210 0x29 211 0x29
211 }; 212 };
212 213
213 namespace net { 214 namespace net {
214 215
216 #if defined(OS_MACOSX) // These should only be implemented on Mac.
bulach 2010/11/17 12:16:50 maybe we should rename this file to x509_cert_type
215 TEST(X509TypesTest, Matching) { 217 TEST(X509TypesTest, Matching) {
216 CertPrincipal spamco; 218 CertPrincipal spamco;
217 spamco.common_name = "SpamCo Dept. Of Certificization"; 219 spamco.common_name = "SpamCo Dept. Of Certificization";
218 spamco.country_name = "EB"; 220 spamco.country_name = "EB";
219 spamco.organization_names.push_back("SpamCo Holding Company, LLC"); 221 spamco.organization_names.push_back("SpamCo Holding Company, LLC");
220 spamco.organization_names.push_back("SpamCo Evil Masterminds"); 222 spamco.organization_names.push_back("SpamCo Evil Masterminds");
221 spamco.organization_unit_names.push_back("Class Z Obfuscation Authority"); 223 spamco.organization_unit_names.push_back("Class Z Obfuscation Authority");
222 ASSERT_TRUE(spamco.Matches(spamco)); 224 ASSERT_TRUE(spamco.Matches(spamco));
223 225
224 CertPrincipal bogus; 226 CertPrincipal bogus;
(...skipping 17 matching lines...) Expand all
242 bogus.locality_name = "Elbosdorf"; 244 bogus.locality_name = "Elbosdorf";
243 EXPECT_FALSE(bogus.Matches(spamco)); 245 EXPECT_FALSE(bogus.Matches(spamco));
244 EXPECT_FALSE(spamco.Matches(bogus)); 246 EXPECT_FALSE(spamco.Matches(bogus));
245 247
246 bogus.locality_name = ""; 248 bogus.locality_name = "";
247 bogus.organization_unit_names.push_back("Q Division"); 249 bogus.organization_unit_names.push_back("Q Division");
248 EXPECT_FALSE(bogus.Matches(spamco)); 250 EXPECT_FALSE(bogus.Matches(spamco));
249 EXPECT_FALSE(spamco.Matches(bogus)); 251 EXPECT_FALSE(spamco.Matches(bogus));
250 } 252 }
251 253
252 #if defined(OS_MACOSX) // ParseDistinguishedName not implemented for Win/Linux
253
254 TEST(X509TypesTest, ParseDNVerisign) { 254 TEST(X509TypesTest, ParseDNVerisign) {
255 CertPrincipal verisign; 255 CertPrincipal verisign;
256 EXPECT_TRUE(verisign.ParseDistinguishedName(VerisignDN, sizeof(VerisignDN))); 256 EXPECT_TRUE(verisign.ParseDistinguishedName(VerisignDN, sizeof(VerisignDN)));
257 EXPECT_EQ("", verisign.common_name); 257 EXPECT_EQ("", verisign.common_name);
258 EXPECT_EQ("US", verisign.country_name); 258 EXPECT_EQ("US", verisign.country_name);
259 ASSERT_EQ(1U, verisign.organization_names.size()); 259 ASSERT_EQ(1U, verisign.organization_names.size());
260 EXPECT_EQ("VeriSign, Inc.", verisign.organization_names[0]); 260 EXPECT_EQ("VeriSign, Inc.", verisign.organization_names[0]);
261 ASSERT_EQ(1U, verisign.organization_unit_names.size()); 261 ASSERT_EQ(1U, verisign.organization_unit_names.size());
262 EXPECT_EQ("Class 1 Public Primary Certification Authority", 262 EXPECT_EQ("Class 1 Public Primary Certification Authority",
263 verisign.organization_unit_names[0]); 263 verisign.organization_unit_names[0]);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 EXPECT_EQ("", entrust.country_name); 331 EXPECT_EQ("", entrust.country_name);
332 ASSERT_EQ(1U, entrust.organization_names.size()); 332 ASSERT_EQ(1U, entrust.organization_names.size());
333 EXPECT_EQ("Entrust.net", 333 EXPECT_EQ("Entrust.net",
334 entrust.organization_names[0]); 334 entrust.organization_names[0]);
335 ASSERT_EQ(2U, entrust.organization_unit_names.size()); 335 ASSERT_EQ(2U, entrust.organization_unit_names.size());
336 EXPECT_EQ("www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)", 336 EXPECT_EQ("www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)",
337 entrust.organization_unit_names[0]); 337 entrust.organization_unit_names[0]);
338 EXPECT_EQ("(c) 1999 Entrust.net Limited", 338 EXPECT_EQ("(c) 1999 Entrust.net Limited",
339 entrust.organization_unit_names[1]); 339 entrust.organization_unit_names[1]);
340 } 340 }
341
342 #endif 341 #endif
wtc 2010/11/17 21:31:53 Nit: This ifdef spans a lot of code, so it would b
343 342
344 } 343 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698