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

Side by Side Diff: net/cert/internal/parse_name_unittest.cc

Issue 2865603002: X509NameAttribute::ValueAsString: Decode TeletexString as Latin1. (Closed)
Patch Set: add comment/todo about nacl difference Created 3 years, 7 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
« no previous file with comments | « net/cert/internal/parse_name.cc ('k') | net/cert/x509_certificate_unittest.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "net/cert/internal/parse_name.h" 5 #include "net/cert/internal/parse_name.h"
6 6
7 #include "net/cert/internal/test_helpers.h" 7 #include "net/cert/internal/test_helpers.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 }; 87 };
88 X509NameAttribute value(der::Input(), der::kTeletexString, der::Input(der)); 88 X509NameAttribute value(der::Input(), der::kTeletexString, der::Input(der));
89 std::string result_unsafe; 89 std::string result_unsafe;
90 ASSERT_TRUE(value.ValueAsStringUnsafe(&result_unsafe)); 90 ASSERT_TRUE(value.ValueAsStringUnsafe(&result_unsafe));
91 ASSERT_EQ("Foo bar", result_unsafe); 91 ASSERT_EQ("Foo bar", result_unsafe);
92 std::string result; 92 std::string result;
93 ASSERT_TRUE(value.ValueAsString(&result)); 93 ASSERT_TRUE(value.ValueAsString(&result));
94 ASSERT_EQ("Foo bar", result); 94 ASSERT_EQ("Foo bar", result);
95 } 95 }
96 96
97 TEST(ParseNameTest, TeletexUnsafeStringValue) { 97 TEST(ParseNameTest, TeletexLatin1StringValue) {
98 const uint8_t der[] = { 98 const uint8_t der[] = {
99 0x46, 0x6f, 0x1F, 0x20, 0x62, 0x61, 0x72, 99 0x46, 0x6f, 0xd6, 0x20, 0x62, 0x61, 0x72,
100 }; 100 };
101 X509NameAttribute value(der::Input(), der::kTeletexString, der::Input(der)); 101 X509NameAttribute value(der::Input(), der::kTeletexString, der::Input(der));
102 std::string result_unsafe; 102 std::string result_unsafe;
103 ASSERT_TRUE(value.ValueAsStringUnsafe(&result_unsafe)); 103 ASSERT_TRUE(value.ValueAsStringUnsafe(&result_unsafe));
104 ASSERT_EQ("Fo\037 bar", result_unsafe); 104 ASSERT_EQ("Fo\xd6 bar", result_unsafe);
105 std::string result; 105 std::string result;
106 ASSERT_FALSE(value.ValueAsString(&result)); 106 ASSERT_TRUE(value.ValueAsString(&result));
107 ASSERT_EQ("FoÖ bar", result);
107 } 108 }
108 109
109 TEST(ParseNameTest, ConvertBmpString) { 110 TEST(ParseNameTest, ConvertBmpString) {
110 const uint8_t der[] = { 111 const uint8_t der[] = {
111 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x61, 0x00, 0x72, 112 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x61, 0x00, 0x72,
112 }; 113 };
113 X509NameAttribute value(der::Input(), der::kBmpString, der::Input(der)); 114 X509NameAttribute value(der::Input(), der::kBmpString, der::Input(der));
114 std::string result_unsafe; 115 std::string result_unsafe;
115 ASSERT_TRUE(value.ValueAsStringUnsafe(&result_unsafe)); 116 ASSERT_TRUE(value.ValueAsStringUnsafe(&result_unsafe));
116 ASSERT_EQ("foobar", result_unsafe); 117 ASSERT_EQ("foobar", result_unsafe);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 0x75, 0xc4, 0x8d, 0x69, 0xc4, 0x87}; 324 0x75, 0xc4, 0x8d, 0x69, 0xc4, 0x87};
324 der::Input rdn_input(der); 325 der::Input rdn_input(der);
325 RDNSequence rdn; 326 RDNSequence rdn;
326 ASSERT_TRUE(ParseName(rdn_input, &rdn)); 327 ASSERT_TRUE(ParseName(rdn_input, &rdn));
327 std::string output; 328 std::string output;
328 ASSERT_TRUE(ConvertToRFC2253(rdn, &output)); 329 ASSERT_TRUE(ConvertToRFC2253(rdn, &output));
329 ASSERT_EQ("SN=Lu\\C4\\8Di\\C4\\87", output); 330 ASSERT_EQ("SN=Lu\\C4\\8Di\\C4\\87", output);
330 } 331 }
331 332
332 } // namespace net 333 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/parse_name.cc ('k') | net/cert/x509_certificate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698