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

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

Issue 2015503003: Certificate Transparency: Ensure no observers in STHDistributor d'tor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « net/cert/sth_distributor.h ('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 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 "net/cert/sth_distributor.h" 5 #include "net/cert/sth_distributor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 distributor_.NewSTHObserved(sample_sth_); 59 distributor_.NewSTHObserved(sample_sth_);
60 distributor_.NewSTHObserved(second_sth); 60 distributor_.NewSTHObserved(second_sth);
61 61
62 StoringSTHObserver observer; 62 StoringSTHObserver observer;
63 distributor_.RegisterObserver(&observer); 63 distributor_.RegisterObserver(&observer);
64 64
65 // Check that two STHs from different logs received prior to observer 65 // Check that two STHs from different logs received prior to observer
66 // registration were reported to the observer once registered. 66 // registration were reported to the observer once registered.
67 EXPECT_EQ(2u, observer.sths.size()); 67 EXPECT_EQ(2u, observer.sths.size());
68 EXPECT_EQ(1u, observer.sths.count(other_log)); 68 EXPECT_EQ(1u, observer.sths.count(other_log));
69 distributor_.UnregisterObserver(&observer);
69 } 70 }
70 71
71 // Test that histograms are properly recorded for the STH age when an STH 72 // Test that histograms are properly recorded for the STH age when an STH
72 // from Google's Pilot log is observed. 73 // from Google's Pilot log is observed.
73 TEST_F(STHDistributorTest, LogsUMAForPilotSTH) { 74 TEST_F(STHDistributorTest, LogsUMAForPilotSTH) {
74 const char kPilotSTHAgeHistogram[] = 75 const char kPilotSTHAgeHistogram[] =
75 "Net.CertificateTransparency.PilotSTHAge"; 76 "Net.CertificateTransparency.PilotSTHAge";
76 base::HistogramTester histograms; 77 base::HistogramTester histograms;
77 histograms.ExpectTotalCount(kPilotSTHAgeHistogram, 0); 78 histograms.ExpectTotalCount(kPilotSTHAgeHistogram, 0);
78 79
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_NE(sample_sth_, observer.sths[GetTestPublicKeyId()]); 118 EXPECT_NE(sample_sth_, observer.sths[GetTestPublicKeyId()]);
118 EXPECT_EQ(new_sth, observer.sths[GetTestPublicKeyId()]); 119 EXPECT_EQ(new_sth, observer.sths[GetTestPublicKeyId()]);
119 120
120 // Registering a new observer should only receive the most recently observed 121 // Registering a new observer should only receive the most recently observed
121 // STH. 122 // STH.
122 StoringSTHObserver new_observer; 123 StoringSTHObserver new_observer;
123 distributor_.RegisterObserver(&new_observer); 124 distributor_.RegisterObserver(&new_observer);
124 EXPECT_EQ(1u, new_observer.sths.size()); 125 EXPECT_EQ(1u, new_observer.sths.size());
125 EXPECT_NE(sample_sth_, new_observer.sths[GetTestPublicKeyId()]); 126 EXPECT_NE(sample_sth_, new_observer.sths[GetTestPublicKeyId()]);
126 EXPECT_EQ(new_sth, new_observer.sths[GetTestPublicKeyId()]); 127 EXPECT_EQ(new_sth, new_observer.sths[GetTestPublicKeyId()]);
128
129 distributor_.UnregisterObserver(&new_observer);
130 distributor_.UnregisterObserver(&observer);
127 } 131 }
128 132
129 } // namespace 133 } // namespace
130 134
131 } // namespace ct 135 } // namespace ct
132 136
133 } // namespace net 137 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/sth_distributor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698