| OLD | NEW |
| 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.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::TrustStore> 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::TrustStore> trust_store(new net::TrustStore()); |
| 20 const auto trusted_test_roots = | 20 const auto trusted_test_roots = |
| 21 cast_certificate::testing::ReadCertificateChainFromFile(path); | 21 cast_certificate::testing::ReadCertificateChainFromFile(path); |
| 22 for (const auto& trusted_root : trusted_test_roots) { | 22 for (const auto& trusted_root : trusted_test_roots) { |
| 23 scoped_refptr<net::ParsedCertificate> anchor( | 23 scoped_refptr<net::ParsedCertificate> cert( |
| 24 net::ParsedCertificate::CreateFromCertificateCopy(trusted_root, {})); | 24 net::ParsedCertificate::CreateFromCertificateCopy(trusted_root, {})); |
| 25 EXPECT_TRUE(anchor); | 25 EXPECT_TRUE(cert); |
| 26 trust_store->AddTrustedCertificate(std::move(anchor)); | 26 auto anchor = |
| 27 net::TrustAnchor::CreateFromCertificateNoConstraints(std::move(cert)); |
| 28 trust_store->AddTrustAnchor(std::move(anchor)); |
| 27 } | 29 } |
| 28 return trust_store; | 30 return trust_store; |
| 29 } | 31 } |
| 30 | 32 |
| 31 // Converts uint64_t unix timestamp in seconds to base::Time. | 33 // Converts uint64_t unix timestamp in seconds to base::Time. |
| 32 base::Time ConvertUnixTimestampSeconds(uint64_t time) { | 34 base::Time ConvertUnixTimestampSeconds(uint64_t time) { |
| 33 return base::Time::UnixEpoch() + | 35 return base::Time::UnixEpoch() + |
| 34 base::TimeDelta::FromMilliseconds(time * 1000); | 36 base::TimeDelta::FromMilliseconds(time * 1000); |
| 35 } | 37 } |
| 36 | 38 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 248 } |
| 247 } | 249 } |
| 248 | 250 |
| 249 TEST(CastCertificateTest, TestSuite1) { | 251 TEST(CastCertificateTest, TestSuite1) { |
| 250 RunTestSuite("testsuite/testsuite1.pb"); | 252 RunTestSuite("testsuite/testsuite1.pb"); |
| 251 } | 253 } |
| 252 | 254 |
| 253 } // namespace | 255 } // namespace |
| 254 | 256 |
| 255 } // namespace cast_certificate | 257 } // namespace cast_certificate |
| OLD | NEW |