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

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

Issue 1378613004: Set Token-Binding HTTP header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tb-tls-ext-new
Patch Set: Add UMA logging of Token Binding support and NetLog event for Token Binding key lookup 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
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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/run_loop.h" 22 #include "base/run_loop.h"
23 #include "base/stl_util.h" 23 #include "base/stl_util.h"
24 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/test/test_file_util.h" 27 #include "base/test/test_file_util.h"
27 #include "base/thread_task_runner_handle.h" 28 #include "base/thread_task_runner_handle.h"
28 #include "net/base/auth.h" 29 #include "net/base/auth.h"
29 #include "net/base/chunked_upload_data_stream.h" 30 #include "net/base/chunked_upload_data_stream.h"
30 #include "net/base/completion_callback.h" 31 #include "net/base/completion_callback.h"
31 #include "net/base/elements_upload_data_stream.h" 32 #include "net/base/elements_upload_data_stream.h"
32 #include "net/base/load_timing_info.h" 33 #include "net/base/load_timing_info.h"
33 #include "net/base/load_timing_info_test_util.h" 34 #include "net/base/load_timing_info_test_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "net/socket/client_socket_pool_manager.h" 68 #include "net/socket/client_socket_pool_manager.h"
68 #include "net/socket/connection_attempts.h" 69 #include "net/socket/connection_attempts.h"
69 #include "net/socket/mock_client_socket_pool_manager.h" 70 #include "net/socket/mock_client_socket_pool_manager.h"
70 #include "net/socket/next_proto.h" 71 #include "net/socket/next_proto.h"
71 #include "net/socket/socket_test_util.h" 72 #include "net/socket/socket_test_util.h"
72 #include "net/socket/ssl_client_socket.h" 73 #include "net/socket/ssl_client_socket.h"
73 #include "net/spdy/spdy_framer.h" 74 #include "net/spdy/spdy_framer.h"
74 #include "net/spdy/spdy_session.h" 75 #include "net/spdy/spdy_session.h"
75 #include "net/spdy/spdy_session_pool.h" 76 #include "net/spdy/spdy_session_pool.h"
76 #include "net/spdy/spdy_test_util_common.h" 77 #include "net/spdy/spdy_test_util_common.h"
78 #include "net/ssl/default_channel_id_store.h"
77 #include "net/ssl/ssl_cert_request_info.h" 79 #include "net/ssl/ssl_cert_request_info.h"
78 #include "net/ssl/ssl_config_service.h" 80 #include "net/ssl/ssl_config_service.h"
79 #include "net/ssl/ssl_config_service_defaults.h" 81 #include "net/ssl/ssl_config_service_defaults.h"
80 #include "net/ssl/ssl_info.h" 82 #include "net/ssl/ssl_info.h"
81 #include "net/test/cert_test_util.h" 83 #include "net/test/cert_test_util.h"
82 #include "net/websockets/websocket_handshake_stream_base.h" 84 #include "net/websockets/websocket_handshake_stream_base.h"
83 #include "testing/gtest/include/gtest/gtest.h" 85 #include "testing/gtest/include/gtest/gtest.h"
84 #include "testing/platform_test.h" 86 #include "testing/platform_test.h"
85 #include "url/gurl.h" 87 #include "url/gurl.h"
86 88
(...skipping 13933 matching lines...) Expand 10 before | Expand all | Expand 10 after
14020 } 14022 }
14021 14023
14022 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); } 14024 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); }
14023 14025
14024 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { 14026 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {
14025 ADD_FAILURE(); 14027 ADD_FAILURE();
14026 } 14028 }
14027 14029
14028 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } 14030 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; }
14029 14031
14032 int GetProvidedTokenBindingWithKey(
14033 const scoped_ptr<crypto::ECPrivateKey>& key,
14034 std::string* header_out) override {
14035 ADD_FAILURE();
14036 return ERR_NOT_IMPLEMENTED;
14037 }
14038
14030 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); } 14039 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); }
14031 14040
14032 void SetPriority(RequestPriority priority) override { priority_ = priority; } 14041 void SetPriority(RequestPriority priority) override { priority_ = priority; }
14033 14042
14034 UploadProgress GetUploadProgress() const override { return UploadProgress(); } 14043 UploadProgress GetUploadProgress() const override { return UploadProgress(); }
14035 14044
14036 HttpStream* RenewStreamForAuth() override { return NULL; } 14045 HttpStream* RenewStreamForAuth() override { return NULL; }
14037 14046
14038 private: 14047 private:
14039 RequestPriority priority_; 14048 RequestPriority priority_;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
14238 } 14247 }
14239 14248
14240 void GetSSLInfo(SSLInfo* ssl_info) override {} 14249 void GetSSLInfo(SSLInfo* ssl_info) override {}
14241 14250
14242 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { 14251 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {
14243 NOTREACHED(); 14252 NOTREACHED();
14244 } 14253 }
14245 14254
14246 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } 14255 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; }
14247 14256
14257 int GetProvidedTokenBindingWithKey(
14258 const scoped_ptr<crypto::ECPrivateKey>& key,
14259 std::string* header_out) override {
14260 ADD_FAILURE();
14261 return ERR_NOT_IMPLEMENTED;
14262 }
14263
14248 void Drain(HttpNetworkSession* session) override { NOTREACHED(); } 14264 void Drain(HttpNetworkSession* session) override { NOTREACHED(); }
14249 14265
14250 void SetPriority(RequestPriority priority) override { NOTREACHED(); } 14266 void SetPriority(RequestPriority priority) override { NOTREACHED(); }
14251 14267
14252 UploadProgress GetUploadProgress() const override { 14268 UploadProgress GetUploadProgress() const override {
14253 NOTREACHED(); 14269 NOTREACHED();
14254 return UploadProgress(); 14270 return UploadProgress();
14255 } 14271 }
14256 14272
14257 HttpStream* RenewStreamForAuth() override { 14273 HttpStream* RenewStreamForAuth() override {
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
15366 15382
15367 std::string response_data; 15383 std::string response_data;
15368 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 15384 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data));
15369 15385
15370 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), 15386 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)),
15371 trans->GetTotalSentBytes()); 15387 trans->GetTotalSentBytes());
15372 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), 15388 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)),
15373 trans->GetTotalReceivedBytes()); 15389 trans->GetTotalReceivedBytes());
15374 } 15390 }
15375 15391
15392 TEST_P(HttpNetworkTransactionTest, TokenBindingSpdy) {
15393 const std::string https_url = "https://www.example.com";
15394 HttpRequestInfo request;
15395 request.url = GURL(https_url);
15396 request.method = "GET";
15397
15398 SSLSocketDataProvider ssl(ASYNC, OK);
15399 ssl.token_binding_negotiated = true;
15400 ssl.token_binding_key_param = TB_PARAM_ECDSAP256;
15401 ssl.SetNextProto(GetParam());
15402 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
15403 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
15404 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
15405 MockRead reads[] = {CreateMockRead(*resp, 1), CreateMockRead(*body, 2),
15406 MockRead(ASYNC, ERR_IO_PENDING, 3)};
15407 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
15408 session_deps_.socket_factory->AddSocketDataProvider(&data);
15409 session_deps_.channel_id_service.reset(new ChannelIDService(
15410 new DefaultChannelIDStore(NULL), base::ThreadTaskRunnerHandle::Get()));
15411 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
15412 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
15413 TestCompletionCallback callback;
15414 EXPECT_EQ(ERR_IO_PENDING,
15415 trans.Start(&request, callback.callback(), BoundNetLog()));
15416 base::MessageLoop::current()->RunUntilIdle();
15417
15418 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15419 HttpRequestHeaders headers;
15420 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15421 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15422 }
15423
15376 } // namespace net 15424 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698