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 "components/certificate_transparency/single_tree_tracker.h" | 5 #include "components/certificate_transparency/single_tree_tracker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 0x1a, 0x9f, 0x20, 0x79, 0xd0, 0xc1, 0x34, 0x2e, 0x08}; | 48 0x1a, 0x9f, 0x20, 0x79, 0xd0, 0xc1, 0x34, 0x2e, 0x08}; |
49 base::StringPiece sp(reinterpret_cast<const char*>(kOldSTHSignatureData), | 49 base::StringPiece sp(reinterpret_cast<const char*>(kOldSTHSignatureData), |
50 sizeof(kOldSTHSignatureData)); | 50 sizeof(kOldSTHSignatureData)); |
51 return DecodeDigitallySigned(&sp, &(sth->signature)) && sp.empty(); | 51 return DecodeDigitallySigned(&sp, &(sth->signature)) && sp.empty(); |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 class SingleTreeTrackerTest : public ::testing::Test { | 56 class SingleTreeTrackerTest : public ::testing::Test { |
57 void SetUp() override { | 57 void SetUp() override { |
58 log_ = net::CTLogVerifier::Create(net::ct::GetTestPublicKey(), "testlog", | 58 log_ = |
59 "https://ct.example.com", ""); | 59 net::CTLogVerifier::Create(net::ct::GetTestPublicKey(), "testlog", |
| 60 "https://ct.example.com", "dns.example.com"); |
60 | 61 |
61 ASSERT_TRUE(log_); | 62 ASSERT_TRUE(log_); |
62 ASSERT_EQ(log_->key_id(), net::ct::GetTestPublicKeyId()); | 63 ASSERT_EQ(log_->key_id(), net::ct::GetTestPublicKeyId()); |
63 | 64 |
64 tree_tracker_.reset(new SingleTreeTracker(log_)); | 65 tree_tracker_.reset(new SingleTreeTracker(log_)); |
65 const std::string der_test_cert(net::ct::GetDerEncodedX509Cert()); | 66 const std::string der_test_cert(net::ct::GetDerEncodedX509Cert()); |
66 chain_ = net::X509Certificate::CreateFromBytes(der_test_cert.data(), | 67 chain_ = net::X509Certificate::CreateFromBytes(der_test_cert.data(), |
67 der_test_cert.length()); | 68 der_test_cert.length()); |
68 ASSERT_TRUE(chain_.get()); | 69 ASSERT_TRUE(chain_.get()); |
69 net::ct::GetX509CertSCT(&cert_sct_); | 70 net::ct::GetX509CertSCT(&cert_sct_); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Notify of an SCT and make sure it's in the 'pending newer STH' state. | 193 // Notify of an SCT and make sure it's in the 'pending newer STH' state. |
193 tree_tracker_->OnSCTVerified(chain_.get(), cert_sct_.get()); | 194 tree_tracker_->OnSCTVerified(chain_.get(), cert_sct_.get()); |
194 | 195 |
195 // Exactly one value should be logged, indicating the SCT cannot be checked | 196 // Exactly one value should be logged, indicating the SCT cannot be checked |
196 // for inclusion as the STH is too old. | 197 // for inclusion as the STH is too old. |
197 histograms.ExpectTotalCount(kCanCheckForInclusionHistogramName, 1); | 198 histograms.ExpectTotalCount(kCanCheckForInclusionHistogramName, 1); |
198 histograms.ExpectBucketCount(kCanCheckForInclusionHistogramName, 1, 1); | 199 histograms.ExpectBucketCount(kCanCheckForInclusionHistogramName, 1, 1); |
199 } | 200 } |
200 | 201 |
201 } // namespace certificate_transparency | 202 } // namespace certificate_transparency |
OLD | NEW |