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

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

Issue 2327973002: Add CertErrors* parameter to the main Certificate parsing functions. (Closed)
Patch Set: StringPiece is kind of dangerous... Created 4 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
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/cert_issuer_source_static.h" 5 #include "net/cert/internal/cert_issuer_source_static.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "net/cert/internal/cert_errors.h"
8 #include "net/cert/internal/parsed_certificate.h" 9 #include "net/cert/internal/parsed_certificate.h"
9 #include "net/cert/internal/test_helpers.h" 10 #include "net/cert/internal/test_helpers.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 namespace { 15 namespace {
15 16
16 void NotCalled(CertIssuerSource::Request* req) { 17 void NotCalled(CertIssuerSource::Request* req) {
17 ADD_FAILURE() << "NotCalled was called"; 18 ADD_FAILURE() << "NotCalled was called";
(...skipping 11 matching lines...) Expand all
29 30
30 ::testing::AssertionResult ReadTestCert( 31 ::testing::AssertionResult ReadTestCert(
31 const std::string& file_name, 32 const std::string& file_name,
32 scoped_refptr<ParsedCertificate>* result) { 33 scoped_refptr<ParsedCertificate>* result) {
33 std::string der; 34 std::string der;
34 ::testing::AssertionResult r = 35 ::testing::AssertionResult r =
35 ReadTestPem("net/data/cert_issuer_source_static_unittest/" + file_name, 36 ReadTestPem("net/data/cert_issuer_source_static_unittest/" + file_name,
36 "CERTIFICATE", &der); 37 "CERTIFICATE", &der);
37 if (!r) 38 if (!r)
38 return r; 39 return r;
39 *result = ParsedCertificate::CreateFromCertificateCopy(der, {}); 40 CertErrors errors;
40 if (!*result) 41 *result = ParsedCertificate::Create(der, {}, &errors);
41 return ::testing::AssertionFailure() << "CreateFromCertificateCopy failed"; 42 if (!*result) {
43 return ::testing::AssertionFailure()
44 << "ParsedCertificate::Create() failed:\n"
45 << errors.ToDebugString();
46 }
42 return ::testing::AssertionSuccess(); 47 return ::testing::AssertionSuccess();
43 } 48 }
44 49
45 class CertIssuerSourceStaticTest : public ::testing::Test { 50 class CertIssuerSourceStaticTest : public ::testing::Test {
46 public: 51 public:
47 void SetUp() override { 52 void SetUp() override {
48 ASSERT_TRUE(ReadTestCert("root.pem", &root_)); 53 ASSERT_TRUE(ReadTestCert("root.pem", &root_));
49 ASSERT_TRUE(ReadTestCert("i1_1.pem", &i1_1_)); 54 ASSERT_TRUE(ReadTestCert("i1_1.pem", &i1_1_));
50 ASSERT_TRUE(ReadTestCert("i1_2.pem", &i1_2_)); 55 ASSERT_TRUE(ReadTestCert("i1_2.pem", &i1_2_));
51 ASSERT_TRUE(ReadTestCert("i2.pem", &i2_)); 56 ASSERT_TRUE(ReadTestCert("i2.pem", &i2_));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 CertIssuerSourceStatic source; 137 CertIssuerSourceStatic source;
133 source.AddCert(i1_1_); 138 source.AddCert(i1_1_);
134 std::unique_ptr<CertIssuerSource::Request> request; 139 std::unique_ptr<CertIssuerSource::Request> request;
135 source.AsyncGetIssuersOf(c1_.get(), base::Bind(&NotCalled), &request); 140 source.AsyncGetIssuersOf(c1_.get(), base::Bind(&NotCalled), &request);
136 EXPECT_EQ(nullptr, request); 141 EXPECT_EQ(nullptr, request);
137 } 142 }
138 143
139 } // namespace 144 } // namespace
140 145
141 } // namespace net 146 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/cert_issuer_source_aia_unittest.cc ('k') | net/cert/internal/parse_certificate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698