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

Side by Side Diff: net/cert/multi_log_ct_verifier_unittest.cc

Issue 1440643002: Certificate Transparency: Per-profile CT verification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing iOS compilation Created 5 years, 1 month 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
« no previous file with comments | « net/cert/multi_log_ct_verifier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/multi_log_ct_verifier.h" 5 #include "net/cert/multi_log_ct_verifier.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 class MockSCTObserver : public CTVerifier::Observer { 43 class MockSCTObserver : public CTVerifier::Observer {
44 public: 44 public:
45 MOCK_METHOD2(OnSCTVerified, 45 MOCK_METHOD2(OnSCTVerified,
46 void(X509Certificate* cert, 46 void(X509Certificate* cert,
47 const ct::SignedCertificateTimestamp* sct)); 47 const ct::SignedCertificateTimestamp* sct));
48 }; 48 };
49 49
50 class MultiLogCTVerifierTest : public ::testing::Test { 50 class MultiLogCTVerifierTest : public ::testing::Test {
51 public: 51 public:
52 void SetUp() override { 52 void SetUp() override {
53 scoped_refptr<CTLogVerifier> log(CTLogVerifier::Create( 53 scoped_refptr<const CTLogVerifier> log(CTLogVerifier::Create(
54 ct::GetTestPublicKey(), kLogDescription, "https://ct.example.com")); 54 ct::GetTestPublicKey(), kLogDescription, "https://ct.example.com"));
55 ASSERT_TRUE(log); 55 ASSERT_TRUE(log);
56 log_verifiers_.push_back(log); 56 log_verifiers_.push_back(log);
57 57
58 verifier_.reset(new MultiLogCTVerifier()); 58 verifier_.reset(new MultiLogCTVerifier());
59 verifier_->AddLogs(log_verifiers_); 59 verifier_->AddLogs(log_verifiers_);
60 std::string der_test_cert(ct::GetDerEncodedX509Cert()); 60 std::string der_test_cert(ct::GetDerEncodedX509Cert());
61 chain_ = X509Certificate::CreateFromBytes( 61 chain_ = X509Certificate::CreateFromBytes(
62 der_test_cert.data(), 62 der_test_cert.data(),
63 der_test_cert.length()); 63 der_test_cert.length());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 int NumValidSCTsInStatusHistogram() { 200 int NumValidSCTsInStatusHistogram() {
201 return GetValueFromHistogram("Net.CertificateTransparency.SCTStatus", 201 return GetValueFromHistogram("Net.CertificateTransparency.SCTStatus",
202 ct::SCT_STATUS_OK); 202 ct::SCT_STATUS_OK);
203 } 203 }
204 204
205 protected: 205 protected:
206 scoped_ptr<MultiLogCTVerifier> verifier_; 206 scoped_ptr<MultiLogCTVerifier> verifier_;
207 scoped_refptr<X509Certificate> chain_; 207 scoped_refptr<X509Certificate> chain_;
208 scoped_refptr<X509Certificate> embedded_sct_chain_; 208 scoped_refptr<X509Certificate> embedded_sct_chain_;
209 std::vector<scoped_refptr<CTLogVerifier>> log_verifiers_; 209 std::vector<scoped_refptr<const CTLogVerifier>> log_verifiers_;
210 }; 210 };
211 211
212 TEST_F(MultiLogCTVerifierTest, VerifiesEmbeddedSCT) { 212 TEST_F(MultiLogCTVerifierTest, VerifiesEmbeddedSCT) {
213 ASSERT_TRUE(CheckPrecertificateVerification(embedded_sct_chain_)); 213 ASSERT_TRUE(CheckPrecertificateVerification(embedded_sct_chain_));
214 } 214 }
215 215
216 TEST_F(MultiLogCTVerifierTest, VerifiesEmbeddedSCTWithPreCA) { 216 TEST_F(MultiLogCTVerifierTest, VerifiesEmbeddedSCTWithPreCA) {
217 scoped_refptr<X509Certificate> chain( 217 scoped_refptr<X509Certificate> chain(
218 CreateCertificateChainFromFile(GetTestCertsDirectory(), 218 CreateCertificateChainFromFile(GetTestCertsDirectory(),
219 "ct-test-embedded-with-preca-chain.pem", 219 "ct-test-embedded-with-preca-chain.pem",
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 Mock::VerifyAndClearExpectations(&observer); 330 Mock::VerifyAndClearExpectations(&observer);
331 331
332 EXPECT_CALL(observer, OnSCTVerified(embedded_sct_chain_.get(), _)).Times(0); 332 EXPECT_CALL(observer, OnSCTVerified(embedded_sct_chain_.get(), _)).Times(0);
333 verifier_->SetObserver(nullptr); 333 verifier_->SetObserver(nullptr);
334 ASSERT_TRUE(VerifySinglePrecertificateChain(embedded_sct_chain_)); 334 ASSERT_TRUE(VerifySinglePrecertificateChain(embedded_sct_chain_));
335 } 335 }
336 336
337 } // namespace 337 } // namespace
338 338
339 } // namespace net 339 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/multi_log_ct_verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698