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

Side by Side Diff: components/cast_certificate/cast_cert_validator_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 "components/cast_certificate/cast_cert_validator.h" 5 #include "components/cast_certificate/cast_cert_validator.h"
6 6
7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" 7 #include "components/cast_certificate/cast_cert_validator_test_helpers.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/trust_store_in_memory.h" 10 #include "net/cert/internal/trust_store_in_memory.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace cast_certificate { 13 namespace cast_certificate {
13 14
14 namespace { 15 namespace {
15 16
16 // Creates an std::string given a uint8_t array. 17 // Creates an std::string given a uint8_t array.
17 template <size_t N> 18 template <size_t N>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 switch (trust_store_dependency) { 73 switch (trust_store_dependency) {
73 case TRUST_STORE_BUILTIN: 74 case TRUST_STORE_BUILTIN:
74 // Leave trust_store as nullptr. 75 // Leave trust_store as nullptr.
75 break; 76 break;
76 77
77 case TRUST_STORE_FROM_TEST_FILE: 78 case TRUST_STORE_FROM_TEST_FILE:
78 case TRUST_STORE_FROM_TEST_FILE_UNCONSTRAINED: { 79 case TRUST_STORE_FROM_TEST_FILE_UNCONSTRAINED: {
79 ASSERT_FALSE(certs.empty()); 80 ASSERT_FALSE(certs.empty());
80 81
81 // Parse the root certificate of the chain. 82 // Parse the root certificate of the chain.
83 net::CertErrors errors;
82 scoped_refptr<net::ParsedCertificate> root = 84 scoped_refptr<net::ParsedCertificate> root =
83 net::ParsedCertificate::CreateFromCertificateCopy(certs.back(), {}); 85 net::ParsedCertificate::Create(certs.back(), {}, &errors);
84 ASSERT_TRUE(root); 86 ASSERT_TRUE(root) << errors.ToDebugString();
85 87
86 // Remove it from the chain. 88 // Remove it from the chain.
87 certs.pop_back(); 89 certs.pop_back();
88 90
89 // Add it to the trust store as a trust anchor 91 // Add it to the trust store as a trust anchor
90 trust_store.reset(new net::TrustStoreInMemory); 92 trust_store.reset(new net::TrustStoreInMemory);
91 93
92 if (trust_store_dependency == TRUST_STORE_FROM_TEST_FILE_UNCONSTRAINED) { 94 if (trust_store_dependency == TRUST_STORE_FROM_TEST_FILE_UNCONSTRAINED) {
93 // This is a test-only mode where anchor constraints are not enforced. 95 // This is a test-only mode where anchor constraints are not enforced.
94 trust_store->AddTrustAnchor( 96 trust_store->AddTrustAnchor(
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 auto context = 552 auto context =
551 CertVerificationContextImplForTest(CreateString(kEx2PublicKeySpki)); 553 CertVerificationContextImplForTest(CreateString(kEx2PublicKeySpki));
552 554
553 EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kEx2Signature), 555 EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kEx2Signature),
554 CreateString(kEx2Message))); 556 CreateString(kEx2Message)));
555 } 557 }
556 558
557 } // namespace 559 } // namespace
558 560
559 } // namespace cast_certificate 561 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « components/cast_certificate/cast_cert_validator.cc ('k') | components/cast_certificate/cast_crl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698