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

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

Issue 2109503009: Refactor net tests to use GMock matchers for checking net::Error results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to contents.txt files Created 4 years, 5 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/http/http_network_layer_unittest.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "net/base/request_priority.h" 11 #include "net/base/request_priority.h"
12 #include "net/cert/ct_policy_enforcer.h" 12 #include "net/cert/ct_policy_enforcer.h"
13 #include "net/cert/mock_cert_verifier.h" 13 #include "net/cert/mock_cert_verifier.h"
14 #include "net/cert/multi_log_ct_verifier.h" 14 #include "net/cert/multi_log_ct_verifier.h"
15 #include "net/dns/mock_host_resolver.h" 15 #include "net/dns/mock_host_resolver.h"
16 #include "net/http/http_auth_handler_mock.h" 16 #include "net/http/http_auth_handler_mock.h"
17 #include "net/http/http_network_session.h" 17 #include "net/http/http_network_session.h"
18 #include "net/http/http_network_transaction.h" 18 #include "net/http/http_network_transaction.h"
19 #include "net/http/http_request_info.h" 19 #include "net/http/http_request_info.h"
20 #include "net/http/http_server_properties_impl.h" 20 #include "net/http/http_server_properties_impl.h"
21 #include "net/http/transport_security_state.h" 21 #include "net/http/transport_security_state.h"
22 #include "net/proxy/proxy_service.h" 22 #include "net/proxy/proxy_service.h"
23 #include "net/socket/socket_test_util.h" 23 #include "net/socket/socket_test_util.h"
24 #include "net/ssl/default_channel_id_store.h" 24 #include "net/ssl/default_channel_id_store.h"
25 #include "net/test/gtest_util.h"
26 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
26 28
29 using net::test::IsOk;
30
27 namespace net { 31 namespace net {
28 32
29 namespace { 33 namespace {
30 34
31 class TLS10SSLConfigService : public SSLConfigService { 35 class TLS10SSLConfigService : public SSLConfigService {
32 public: 36 public:
33 TLS10SSLConfigService() { 37 TLS10SSLConfigService() {
34 ssl_config_.version_min = SSL_PROTOCOL_VERSION_TLS1; 38 ssl_config_.version_min = SSL_PROTOCOL_VERSION_TLS1;
35 ssl_config_.version_max = SSL_PROTOCOL_VERSION_TLS1; 39 ssl_config_.version_max = SSL_PROTOCOL_VERSION_TLS1;
36 } 40 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 StaticSocketDataProvider data(mock_reads, arraysize(mock_reads), NULL, 0); 143 StaticSocketDataProvider data(mock_reads, arraysize(mock_reads), NULL, 0);
140 mock_socket_factory_.AddSocketDataProvider(&data); 144 mock_socket_factory_.AddSocketDataProvider(&data);
141 145
142 HttpNetworkSession session(session_params_); 146 HttpNetworkSession session(session_params_);
143 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, &session); 147 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, &session);
144 148
145 TestCompletionCallback callback; 149 TestCompletionCallback callback;
146 int rv = callback.GetResult( 150 int rv = callback.GetResult(
147 trans1.Start(GetRequestInfo("https://www.example.com/"), 151 trans1.Start(GetRequestInfo("https://www.example.com/"),
148 callback.callback(), BoundNetLog())); 152 callback.callback(), BoundNetLog()));
149 EXPECT_EQ(OK, rv); 153 EXPECT_THAT(rv, IsOk());
150 154
151 HttpRequestHeaders headers1; 155 HttpRequestHeaders headers1;
152 ASSERT_TRUE(trans1.GetFullRequestHeaders(&headers1)); 156 ASSERT_TRUE(trans1.GetFullRequestHeaders(&headers1));
153 std::string token_binding_header1; 157 std::string token_binding_header1;
154 EXPECT_TRUE(headers1.GetHeader(HttpRequestHeaders::kTokenBinding, 158 EXPECT_TRUE(headers1.GetHeader(HttpRequestHeaders::kTokenBinding,
155 &token_binding_header1)); 159 &token_binding_header1));
156 160
157 // Send a second request and verify that the token binding header is the same 161 // Send a second request and verify that the token binding header is the same
158 // as in the first request. 162 // as in the first request.
159 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data); 163 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data);
160 StaticSocketDataProvider data2(mock_reads, arraysize(mock_reads), NULL, 0); 164 StaticSocketDataProvider data2(mock_reads, arraysize(mock_reads), NULL, 0);
161 mock_socket_factory_.AddSocketDataProvider(&data2); 165 mock_socket_factory_.AddSocketDataProvider(&data2);
162 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, &session); 166 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, &session);
163 167
164 rv = callback.GetResult( 168 rv = callback.GetResult(
165 trans2.Start(GetRequestInfo("https://www.example.com/"), 169 trans2.Start(GetRequestInfo("https://www.example.com/"),
166 callback.callback(), BoundNetLog())); 170 callback.callback(), BoundNetLog()));
167 EXPECT_EQ(OK, rv); 171 EXPECT_THAT(rv, IsOk());
168 172
169 HttpRequestHeaders headers2; 173 HttpRequestHeaders headers2;
170 ASSERT_TRUE(trans2.GetFullRequestHeaders(&headers2)); 174 ASSERT_TRUE(trans2.GetFullRequestHeaders(&headers2));
171 std::string token_binding_header2; 175 std::string token_binding_header2;
172 EXPECT_TRUE(headers2.GetHeader(HttpRequestHeaders::kTokenBinding, 176 EXPECT_TRUE(headers2.GetHeader(HttpRequestHeaders::kTokenBinding,
173 &token_binding_header2)); 177 &token_binding_header2));
174 178
175 EXPECT_EQ(token_binding_header1, token_binding_header2); 179 EXPECT_EQ(token_binding_header1, token_binding_header2);
176 } 180 }
177 181
(...skipping 13 matching lines...) Expand all
191 StaticSocketDataProvider data(mock_reads, arraysize(mock_reads), NULL, 0); 195 StaticSocketDataProvider data(mock_reads, arraysize(mock_reads), NULL, 0);
192 mock_socket_factory_.AddSocketDataProvider(&data); 196 mock_socket_factory_.AddSocketDataProvider(&data);
193 197
194 HttpNetworkSession session(session_params_); 198 HttpNetworkSession session(session_params_);
195 HttpNetworkTransaction trans(DEFAULT_PRIORITY, &session); 199 HttpNetworkTransaction trans(DEFAULT_PRIORITY, &session);
196 200
197 TestCompletionCallback callback; 201 TestCompletionCallback callback;
198 int rv = 202 int rv =
199 callback.GetResult(trans.Start(GetRequestInfo("http://www.example.com/"), 203 callback.GetResult(trans.Start(GetRequestInfo("http://www.example.com/"),
200 callback.callback(), BoundNetLog())); 204 callback.callback(), BoundNetLog()));
201 EXPECT_EQ(OK, rv); 205 EXPECT_THAT(rv, IsOk());
202 206
203 HttpRequestHeaders headers; 207 HttpRequestHeaders headers;
204 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 208 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
205 std::string token_binding_header; 209 std::string token_binding_header;
206 EXPECT_FALSE(headers.GetHeader(HttpRequestHeaders::kTokenBinding, 210 EXPECT_FALSE(headers.GetHeader(HttpRequestHeaders::kTokenBinding,
207 &token_binding_header)); 211 &token_binding_header));
208 } 212 }
209 #endif // !defined(OS_IOS) 213 #endif // !defined(OS_IOS)
210 214
211 } // namespace net 215 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_layer_unittest.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698