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

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

Issue 1288193003: Add a function for parsing RFC 5280's "Certificate". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test_helpers
Patch Set: More comment fixes Created 5 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/test_helpers.h" 5 #include "net/cert/internal/test_helpers.h"
6 6
7 #include "base/base64.h"
7 #include "base/base_paths.h" 8 #include "base/base_paths.h"
8 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "net/cert/pem_tokenizer.h" 11 #include "net/cert/pem_tokenizer.h"
11 12
12 namespace net { 13 namespace net {
13 14
15 namespace der {
16
17 void PrintTo(const Input& data, ::std::ostream* os) {
18 std::string b64;
19 base::Base64Encode(
20 base::StringPiece(reinterpret_cast<const char*>(data.UnsafeData()),
21 data.Length()),
22 &b64);
23
24 *os << "[" << b64 << "]";
25 }
26
27 bool operator==(const Input& a, const Input& b) {
28 return a.Equals(b);
29 }
30
31 } // namespace der
32
14 der::Input InputFromString(const std::string* s) { 33 der::Input InputFromString(const std::string* s) {
15 return der::Input(reinterpret_cast<const uint8_t*>(s->data()), s->size()); 34 return der::Input(reinterpret_cast<const uint8_t*>(s->data()), s->size());
16 } 35 }
17 36
18 ::testing::AssertionResult ReadTestDataFromPemFile( 37 ::testing::AssertionResult ReadTestDataFromPemFile(
19 const std::string& file_path_ascii, 38 const std::string& file_path_ascii,
20 const PemBlockMapping* mappings, 39 const PemBlockMapping* mappings,
21 size_t mappings_length) { 40 size_t mappings_length) {
22 // Compute the full path, relative to the src/ directory. 41 // Compute the full path, relative to the src/ directory.
23 base::FilePath src_root; 42 base::FilePath src_root;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (mapping.value) { 86 if (mapping.value) {
68 return ::testing::AssertionFailure() << "PEM block missing: " 87 return ::testing::AssertionFailure() << "PEM block missing: "
69 << mapping.block_name; 88 << mapping.block_name;
70 } 89 }
71 } 90 }
72 91
73 return ::testing::AssertionSuccess(); 92 return ::testing::AssertionSuccess();
74 } 93 }
75 94
76 } // namespace net 95 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/test_helpers.h ('k') | net/data/parse_certificate_unittest/cert_algorithm_not_sequence.pem » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698