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

Side by Side Diff: net/http/transport_security_state_unittest.cc

Issue 2648713002: Add response code to the success callback of ReportSender (Closed)
Patch Set: Remove response code from error callback Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http/transport_security_state.h" 5 #include "net/http/transport_security_state.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 class MockCertificateReportSender 97 class MockCertificateReportSender
98 : public TransportSecurityState::ReportSenderInterface { 98 : public TransportSecurityState::ReportSenderInterface {
99 public: 99 public:
100 MockCertificateReportSender() {} 100 MockCertificateReportSender() {}
101 ~MockCertificateReportSender() override {} 101 ~MockCertificateReportSender() override {}
102 102
103 void Send( 103 void Send(
104 const GURL& report_uri, 104 const GURL& report_uri,
105 base::StringPiece content_type, 105 base::StringPiece content_type,
106 base::StringPiece report, 106 base::StringPiece report,
107 const base::Callback<void()>& success_callback, 107 const base::Callback<void(int)>& success_callback,
108 const base::Callback<void(const GURL&, int)>& error_callback) override { 108 const base::Callback<void(const GURL&, int)>& error_callback) override {
109 latest_report_uri_ = report_uri; 109 latest_report_uri_ = report_uri;
110 report.CopyToString(&latest_report_); 110 report.CopyToString(&latest_report_);
111 content_type.CopyToString(&latest_content_type_); 111 content_type.CopyToString(&latest_content_type_);
112 } 112 }
113 113
114 void Clear() { 114 void Clear() {
115 latest_report_uri_ = GURL(); 115 latest_report_uri_ = GURL();
116 latest_report_ = std::string(); 116 latest_report_ = std::string();
117 latest_content_type_ = std::string(); 117 latest_content_type_ = std::string();
(...skipping 16 matching lines...) Expand all
134 MockFailingCertificateReportSender() : net_error_(ERR_CONNECTION_FAILED) {} 134 MockFailingCertificateReportSender() : net_error_(ERR_CONNECTION_FAILED) {}
135 ~MockFailingCertificateReportSender() override {} 135 ~MockFailingCertificateReportSender() override {}
136 136
137 int net_error() { return net_error_; } 137 int net_error() { return net_error_; }
138 138
139 // TransportSecurityState::ReportSenderInterface: 139 // TransportSecurityState::ReportSenderInterface:
140 void Send( 140 void Send(
141 const GURL& report_uri, 141 const GURL& report_uri,
142 base::StringPiece content_type, 142 base::StringPiece content_type,
143 base::StringPiece report, 143 base::StringPiece report,
144 const base::Callback<void()>& success_callback, 144 const base::Callback<void(int)>& success_callback,
145 const base::Callback<void(const GURL&, int)>& error_callback) override { 145 const base::Callback<void(const GURL&, int)>& error_callback) override {
146 ASSERT_FALSE(error_callback.is_null()); 146 ASSERT_FALSE(error_callback.is_null());
147 error_callback.Run(report_uri, net_error_); 147 error_callback.Run(report_uri, net_error_);
148 } 148 }
149 149
150 private: 150 private:
151 const int net_error_; 151 const int net_error_;
152 }; 152 };
153 153
154 // A mock ExpectCTReporter that remembers the latest violation that was 154 // A mock ExpectCTReporter that remembers the latest violation that was
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 TransportSecurityState state; 2686 TransportSecurityState state;
2687 TransportSecurityState::ExpectCTState expect_ct_state; 2687 TransportSecurityState::ExpectCTState expect_ct_state;
2688 const base::Time current_time = base::Time::Now(); 2688 const base::Time current_time = base::Time::Now();
2689 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000); 2689 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000);
2690 2690
2691 state.AddExpectCT(host, expiry, true, GURL()); 2691 state.AddExpectCT(host, expiry, true, GURL());
2692 EXPECT_FALSE(state.GetDynamicExpectCTState(host, &expect_ct_state)); 2692 EXPECT_FALSE(state.GetDynamicExpectCTState(host, &expect_ct_state));
2693 } 2693 }
2694 2694
2695 } // namespace net 2695 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698