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

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 another #if !defined(OS_IOS) Created 4 years, 11 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 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 #include <limits> 10 #include <limits>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
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/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
23 #include "base/run_loop.h" 23 #include "base/run_loop.h"
24 #include "base/stl_util.h"
25 #include "base/strings/string_number_conversions.h"
Bence 2016/01/23 22:31:17 Sorry, I cannot seem to find what these two includ
nharper 2016/01/25 18:54:54 I don't remember what they were for and it compile
24 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
26 #include "base/test/test_file_util.h" 28 #include "base/test/test_file_util.h"
27 #include "base/thread_task_runner_handle.h" 29 #include "base/thread_task_runner_handle.h"
28 #include "net/base/auth.h" 30 #include "net/base/auth.h"
29 #include "net/base/chunked_upload_data_stream.h" 31 #include "net/base/chunked_upload_data_stream.h"
30 #include "net/base/completion_callback.h" 32 #include "net/base/completion_callback.h"
31 #include "net/base/elements_upload_data_stream.h" 33 #include "net/base/elements_upload_data_stream.h"
32 #include "net/base/load_timing_info.h" 34 #include "net/base/load_timing_info.h"
33 #include "net/base/load_timing_info_test_util.h" 35 #include "net/base/load_timing_info_test_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "net/socket/client_socket_pool_manager.h" 70 #include "net/socket/client_socket_pool_manager.h"
69 #include "net/socket/connection_attempts.h" 71 #include "net/socket/connection_attempts.h"
70 #include "net/socket/mock_client_socket_pool_manager.h" 72 #include "net/socket/mock_client_socket_pool_manager.h"
71 #include "net/socket/next_proto.h" 73 #include "net/socket/next_proto.h"
72 #include "net/socket/socket_test_util.h" 74 #include "net/socket/socket_test_util.h"
73 #include "net/socket/ssl_client_socket.h" 75 #include "net/socket/ssl_client_socket.h"
74 #include "net/spdy/spdy_framer.h" 76 #include "net/spdy/spdy_framer.h"
75 #include "net/spdy/spdy_session.h" 77 #include "net/spdy/spdy_session.h"
76 #include "net/spdy/spdy_session_pool.h" 78 #include "net/spdy/spdy_session_pool.h"
77 #include "net/spdy/spdy_test_util_common.h" 79 #include "net/spdy/spdy_test_util_common.h"
80 #include "net/ssl/default_channel_id_store.h"
78 #include "net/ssl/ssl_cert_request_info.h" 81 #include "net/ssl/ssl_cert_request_info.h"
79 #include "net/ssl/ssl_config_service.h" 82 #include "net/ssl/ssl_config_service.h"
80 #include "net/ssl/ssl_config_service_defaults.h" 83 #include "net/ssl/ssl_config_service_defaults.h"
81 #include "net/ssl/ssl_info.h" 84 #include "net/ssl/ssl_info.h"
82 #include "net/ssl/ssl_private_key.h" 85 #include "net/ssl/ssl_private_key.h"
83 #include "net/test/cert_test_util.h" 86 #include "net/test/cert_test_util.h"
84 #include "net/websockets/websocket_handshake_stream_base.h" 87 #include "net/websockets/websocket_handshake_stream_base.h"
85 #include "testing/gmock/include/gmock/gmock.h" 88 #include "testing/gmock/include/gmock/gmock.h"
86 #include "testing/gtest/include/gtest/gtest.h" 89 #include "testing/gtest/include/gtest/gtest.h"
87 #include "testing/platform_test.h" 90 #include "testing/platform_test.h"
(...skipping 14318 matching lines...) Expand 10 before | Expand all | Expand 10 after
14406 } 14409 }
14407 14410
14408 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); } 14411 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); }
14409 14412
14410 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { 14413 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {
14411 ADD_FAILURE(); 14414 ADD_FAILURE();
14412 } 14415 }
14413 14416
14414 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } 14417 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; }
14415 14418
14419 Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key,
14420 std::vector<uint8_t>* out) override {
14421 ADD_FAILURE();
14422 return ERR_NOT_IMPLEMENTED;
14423 }
14424
14416 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); } 14425 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); }
14417 14426
14418 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; } 14427 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; }
14419 14428
14420 void SetPriority(RequestPriority priority) override { priority_ = priority; } 14429 void SetPriority(RequestPriority priority) override { priority_ = priority; }
14421 14430
14422 UploadProgress GetUploadProgress() const override { return UploadProgress(); } 14431 UploadProgress GetUploadProgress() const override { return UploadProgress(); }
14423 14432
14424 HttpStream* RenewStreamForAuth() override { return NULL; } 14433 HttpStream* RenewStreamForAuth() override { return NULL; }
14425 14434
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
14637 } 14646 }
14638 14647
14639 void GetSSLInfo(SSLInfo* ssl_info) override {} 14648 void GetSSLInfo(SSLInfo* ssl_info) override {}
14640 14649
14641 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { 14650 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {
14642 NOTREACHED(); 14651 NOTREACHED();
14643 } 14652 }
14644 14653
14645 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } 14654 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; }
14646 14655
14656 Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key,
14657 std::vector<uint8_t>* out) override {
14658 ADD_FAILURE();
14659 return ERR_NOT_IMPLEMENTED;
14660 }
14661
14647 void Drain(HttpNetworkSession* session) override { NOTREACHED(); } 14662 void Drain(HttpNetworkSession* session) override { NOTREACHED(); }
14648 14663
14649 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; } 14664 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; }
14650 14665
14651 void SetPriority(RequestPriority priority) override { NOTREACHED(); } 14666 void SetPriority(RequestPriority priority) override { NOTREACHED(); }
14652 14667
14653 UploadProgress GetUploadProgress() const override { 14668 UploadProgress GetUploadProgress() const override {
14654 NOTREACHED(); 14669 NOTREACHED();
14655 return UploadProgress(); 14670 return UploadProgress();
14656 } 14671 }
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
15795 session_deps_.enable_npn = false; 15810 session_deps_.enable_npn = false;
15796 15811
15797 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 15812 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
15798 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 15813 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
15799 15814
15800 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, 15815 EXPECT_THAT(trans.server_ssl_config_.alpn_protos,
15801 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); 15816 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11));
15802 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); 15817 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty());
15803 } 15818 }
15804 15819
15820 #if !defined(OS_IOS)
15821 TEST_P(HttpNetworkTransactionTest, TokenBindingSpdy) {
15822 const std::string https_url = "https://www.example.com";
15823 HttpRequestInfo request;
15824 request.url = GURL(https_url);
15825 request.method = "GET";
15826
15827 SSLSocketDataProvider ssl(ASYNC, OK);
15828 ssl.token_binding_negotiated = true;
15829 ssl.token_binding_key_param = TB_PARAM_ECDSAP256;
15830 ssl.SetNextProto(GetProtocol());
15831 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
15832 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
Bence 2016/01/23 22:31:17 Optional: add an empty line above this one.
Bence 2016/01/23 22:31:17 Style guide recommends nullptr instead of NULL for
nharper 2016/01/25 18:54:54 Done.
nharper 2016/01/25 18:54:54 Done.
15833 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
15834 MockRead reads[] = {CreateMockRead(*resp, 1), CreateMockRead(*body, 2),
Bence 2016/01/23 22:31:17 Don't you have to count mock data from 0? I'd be
nharper 2016/01/25 18:54:54 I don't know what the sequence number is supposed
Bence 2016/01/25 21:45:19 Well, if the sequence numbers do not seem to matte
nharper 2016/01/25 22:06:17 Done.
15835 MockRead(ASYNC, ERR_IO_PENDING, 3)};
15836 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
15837 session_deps_.socket_factory->AddSocketDataProvider(&data);
15838 session_deps_.channel_id_service.reset(new ChannelIDService(
15839 new DefaultChannelIDStore(NULL), base::ThreadTaskRunnerHandle::Get()));
15840 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
Bence 2016/01/23 22:31:18 Optional: add an empty line above this one.
nharper 2016/01/25 18:54:54 Done.
15841 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
15842 TestCompletionCallback callback;
15843 EXPECT_EQ(ERR_IO_PENDING,
15844 trans.Start(&request, callback.callback(), BoundNetLog()));
15845 base::MessageLoop::current()->RunUntilIdle();
15846
15847 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15848 HttpRequestHeaders headers;
15849 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15850 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15851 }
15852 #endif // !defined(OS_IOS)
15853
15805 } // namespace net 15854 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698