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

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

Issue 9358080: Properly parse UTF8Strings in certificates on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 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 "base/basictypes.h"
6 #include "net/base/x509_cert_types.h" 6 #include "net/base/x509_cert_types.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 // 0:d=0 hl=2 l= 95 cons: SEQUENCE 9 // 0:d=0 hl=2 l= 95 cons: SEQUENCE
10 // 2:d=1 hl=2 l= 11 cons: SET 10 // 2:d=1 hl=2 l= 11 cons: SET
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 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,
207 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,
208 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,
209 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,
210 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,
211 0x29 211 0x29
212 }; 212 };
213 213
214 namespace net { 214 namespace net {
215 215
216 #if defined(OS_MACOSX)
216 TEST(X509TypesTest, Matching) { 217 TEST(X509TypesTest, Matching) {
217 CertPrincipal spamco; 218 CertPrincipal spamco;
218 spamco.common_name = "SpamCo Dept. Of Certificization"; 219 spamco.common_name = "SpamCo Dept. Of Certificization";
219 spamco.country_name = "EB"; 220 spamco.country_name = "EB";
220 spamco.organization_names.push_back("SpamCo Holding Company, LLC"); 221 spamco.organization_names.push_back("SpamCo Holding Company, LLC");
221 spamco.organization_names.push_back("SpamCo Evil Masterminds"); 222 spamco.organization_names.push_back("SpamCo Evil Masterminds");
222 spamco.organization_unit_names.push_back("Class Z Obfuscation Authority"); 223 spamco.organization_unit_names.push_back("Class Z Obfuscation Authority");
223 ASSERT_TRUE(spamco.Matches(spamco)); 224 ASSERT_TRUE(spamco.Matches(spamco));
224 225
225 CertPrincipal bogus; 226 CertPrincipal bogus;
(...skipping 16 matching lines...) Expand all
242 243
243 bogus.locality_name = "Elbosdorf"; 244 bogus.locality_name = "Elbosdorf";
244 EXPECT_FALSE(bogus.Matches(spamco)); 245 EXPECT_FALSE(bogus.Matches(spamco));
245 EXPECT_FALSE(spamco.Matches(bogus)); 246 EXPECT_FALSE(spamco.Matches(bogus));
246 247
247 bogus.locality_name = ""; 248 bogus.locality_name = "";
248 bogus.organization_unit_names.push_back("Q Division"); 249 bogus.organization_unit_names.push_back("Q Division");
249 EXPECT_FALSE(bogus.Matches(spamco)); 250 EXPECT_FALSE(bogus.Matches(spamco));
250 EXPECT_FALSE(spamco.Matches(bogus)); 251 EXPECT_FALSE(spamco.Matches(bogus));
251 } 252 }
253 #endif
252 254
253 TEST(X509TypesTest, ParseDNVerisign) { 255 TEST(X509TypesTest, ParseDNVerisign) {
254 CertPrincipal verisign; 256 CertPrincipal verisign;
255 EXPECT_TRUE(verisign.ParseDistinguishedName(VerisignDN, sizeof(VerisignDN))); 257 EXPECT_TRUE(verisign.ParseDistinguishedName(VerisignDN, sizeof(VerisignDN)));
256 EXPECT_EQ("", verisign.common_name); 258 EXPECT_EQ("", verisign.common_name);
257 EXPECT_EQ("US", verisign.country_name); 259 EXPECT_EQ("US", verisign.country_name);
258 ASSERT_EQ(1U, verisign.organization_names.size()); 260 ASSERT_EQ(1U, verisign.organization_names.size());
259 EXPECT_EQ("VeriSign, Inc.", verisign.organization_names[0]); 261 EXPECT_EQ("VeriSign, Inc.", verisign.organization_names[0]);
260 ASSERT_EQ(1U, verisign.organization_unit_names.size()); 262 ASSERT_EQ(1U, verisign.organization_unit_names.size());
261 EXPECT_EQ("Class 1 Public Primary Certification Authority", 263 EXPECT_EQ("Class 1 Public Primary Certification Authority",
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 EXPECT_EQ("Entrust.net", 334 EXPECT_EQ("Entrust.net",
333 entrust.organization_names[0]); 335 entrust.organization_names[0]);
334 ASSERT_EQ(2U, entrust.organization_unit_names.size()); 336 ASSERT_EQ(2U, entrust.organization_unit_names.size());
335 EXPECT_EQ("www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)", 337 EXPECT_EQ("www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)",
336 entrust.organization_unit_names[0]); 338 entrust.organization_unit_names[0]);
337 EXPECT_EQ("(c) 1999 Entrust.net Limited", 339 EXPECT_EQ("(c) 1999 Entrust.net Limited",
338 entrust.organization_unit_names[1]); 340 entrust.organization_unit_names[1]);
339 } 341 }
340 342
341 } // namespace net 343 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698