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

Side by Side Diff: components/cast_certificate/cast_crl_unittest.cc

Issue 2252933002: Make TrustStore into an interface, move impl to TrustStoreInMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update cast_cert_validator_unittest.cc Created 4 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 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 "base/time/time.h" 5 #include "base/time/time.h"
6 #include "components/cast_certificate/cast_cert_validator.h" 6 #include "components/cast_certificate/cast_cert_validator.h"
7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" 7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h"
8 #include "components/cast_certificate/cast_crl.h" 8 #include "components/cast_certificate/cast_crl.h"
9 #include "components/cast_certificate/proto/test_suite.pb.h" 9 #include "components/cast_certificate/proto/test_suite.pb.h"
10 #include "net/cert/internal/trust_store.h" 10 #include "net/cert/internal/trust_store_in_memory.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace cast_certificate { 13 namespace cast_certificate {
14 namespace { 14 namespace {
15 15
16 // Creates a trust store using the test roots encoded in the PEM file at |path|. 16 // Creates a trust store using the test roots encoded in the PEM file at |path|.
17 std::unique_ptr<net::TrustStore> CreateTrustStoreFromFile( 17 std::unique_ptr<net::TrustStoreInMemory> CreateTrustStoreFromFile(
18 const std::string& path) { 18 const std::string& path) {
19 std::unique_ptr<net::TrustStore> trust_store(new net::TrustStore()); 19 std::unique_ptr<net::TrustStoreInMemory> trust_store(
20 new net::TrustStoreInMemory());
20 const auto trusted_test_roots = 21 const auto trusted_test_roots =
21 cast_certificate::testing::ReadCertificateChainFromFile(path); 22 cast_certificate::testing::ReadCertificateChainFromFile(path);
22 for (const auto& trusted_root : trusted_test_roots) { 23 for (const auto& trusted_root : trusted_test_roots) {
23 scoped_refptr<net::ParsedCertificate> cert( 24 scoped_refptr<net::ParsedCertificate> cert(
24 net::ParsedCertificate::CreateFromCertificateCopy(trusted_root, {})); 25 net::ParsedCertificate::CreateFromCertificateCopy(trusted_root, {}));
25 EXPECT_TRUE(cert); 26 EXPECT_TRUE(cert);
26 scoped_refptr<net::TrustAnchor> anchor = 27 scoped_refptr<net::TrustAnchor> anchor =
27 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); 28 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert));
28 trust_store->AddTrustAnchor(std::move(anchor)); 29 trust_store->AddTrustAnchor(std::move(anchor));
29 } 30 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 if (expected_result != RESULT_SUCCESS) { 129 if (expected_result != RESULT_SUCCESS) {
129 EXPECT_FALSE(result); 130 EXPECT_FALSE(result);
130 return !result; 131 return !result;
131 } 132 }
132 EXPECT_TRUE(result); 133 EXPECT_TRUE(result);
133 return result; 134 return result;
134 } 135 }
135 136
136 // Runs a single test case. 137 // Runs a single test case.
137 bool RunTest(const DeviceCertTest& test_case) { 138 bool RunTest(const DeviceCertTest& test_case) {
138 std::unique_ptr<net::TrustStore> crl_trust_store; 139 std::unique_ptr<net::TrustStoreInMemory> crl_trust_store;
139 std::unique_ptr<net::TrustStore> cast_trust_store; 140 std::unique_ptr<net::TrustStoreInMemory> cast_trust_store;
140 if (test_case.use_test_trust_anchors()) { 141 if (test_case.use_test_trust_anchors()) {
141 crl_trust_store = 142 crl_trust_store =
142 CreateTrustStoreFromFile("certificates/cast_crl_test_root_ca.pem"); 143 CreateTrustStoreFromFile("certificates/cast_crl_test_root_ca.pem");
143 cast_trust_store = 144 cast_trust_store =
144 CreateTrustStoreFromFile("certificates/cast_test_root_ca.pem"); 145 CreateTrustStoreFromFile("certificates/cast_test_root_ca.pem");
145 146
146 EXPECT_TRUE(crl_trust_store.get()); 147 EXPECT_TRUE(crl_trust_store.get());
147 EXPECT_TRUE(cast_trust_store.get()); 148 EXPECT_TRUE(cast_trust_store.get());
148 } 149 }
149 150
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 249 }
249 } 250 }
250 251
251 TEST(CastCertificateTest, TestSuite1) { 252 TEST(CastCertificateTest, TestSuite1) {
252 RunTestSuite("testsuite/testsuite1.pb"); 253 RunTestSuite("testsuite/testsuite1.pb");
253 } 254 }
254 255
255 } // namespace 256 } // namespace
256 257
257 } // namespace cast_certificate 258 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « components/cast_certificate/cast_crl.cc ('k') | net/cert/internal/path_builder_pkits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698