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

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

Issue 14125003: Do not roll back to SSL 3.0 for Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 7 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/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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 9452 matching lines...) Expand 10 before | Expand all | Expand 10 after
9463 if (rv == ERR_IO_PENDING) 9463 if (rv == ERR_IO_PENDING)
9464 rv = callback.WaitForResult(); 9464 rv = callback.WaitForResult();
9465 EXPECT_EQ(3, rv); 9465 EXPECT_EQ(3, rv);
9466 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); 9466 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback());
9467 EXPECT_EQ(0, rv); 9467 EXPECT_EQ(0, rv);
9468 9468
9469 // Finally, the socket is released to the group. 9469 // Finally, the socket is released to the group.
9470 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); 9470 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup));
9471 } 9471 }
9472 9472
9473 class TLSDecompressionFailureSocketDataProvider : public SocketDataProvider {
9474 public:
9475 explicit TLSDecompressionFailureSocketDataProvider(bool fail_all)
9476 : fail_all_(fail_all) {
9477 }
9478
9479 virtual MockRead GetNextRead() OVERRIDE {
9480 if (fail_all_)
9481 return MockRead(SYNCHRONOUS, ERR_SSL_DECOMPRESSION_FAILURE_ALERT);
9482
9483 return MockRead(SYNCHRONOUS,
9484 "HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nok.\r\n");
9485 }
9486
9487 virtual MockWriteResult OnWrite(const std::string& data) OVERRIDE {
9488 return MockWriteResult(SYNCHRONOUS /* async */, data.size());
9489 }
9490
9491 virtual void Reset() OVERRIDE {
9492 }
9493
9494 private:
9495 const bool fail_all_;
9496 };
9497
9498 // Test that we restart a connection when we see a decompression failure from
9499 // the peer during the handshake. (In the real world we'll restart with SSLv3
9500 // and we won't offer DEFLATE in that case.)
9501 TEST_F(HttpNetworkTransactionSpdy3Test, RestartAfterTLSDecompressionFailure) {
9502 HttpRequestInfo request;
9503 request.method = "GET";
9504 request.url = GURL("https://tlsdecompressionfailure.example.com/");
9505 request.load_flags = 0;
9506
9507 SpdySessionDependencies session_deps;
9508 TLSDecompressionFailureSocketDataProvider socket_data_provider1(
9509 false /* fail all reads */);
9510 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false);
9511 SSLSocketDataProvider ssl_socket_data_provider1(
9512 SYNCHRONOUS, ERR_SSL_DECOMPRESSION_FAILURE_ALERT);
9513 SSLSocketDataProvider ssl_socket_data_provider2(SYNCHRONOUS, OK);
9514 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider1);
9515 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider2);
9516 session_deps.socket_factory->AddSSLSocketDataProvider(
9517 &ssl_socket_data_provider1);
9518 session_deps.socket_factory->AddSSLSocketDataProvider(
9519 &ssl_socket_data_provider2);
9520
9521 // Work around http://crbug.com/37454
9522 StaticSocketDataProvider bug37454_connection;
9523 bug37454_connection.set_connect_data(MockConnect(ASYNC, ERR_UNEXPECTED));
9524 session_deps.socket_factory->AddSocketDataProvider(&bug37454_connection);
9525
9526 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
9527 scoped_ptr<HttpTransaction> trans(
9528 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
9529 TestCompletionCallback callback;
9530
9531 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9532 EXPECT_EQ(ERR_IO_PENDING, rv);
9533 EXPECT_EQ(OK, callback.WaitForResult());
9534
9535 const HttpResponseInfo* response = trans->GetResponseInfo();
9536 ASSERT_TRUE(response != NULL);
9537 ASSERT_TRUE(response->headers != NULL);
9538 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9539
9540 std::string response_data;
9541 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9542 EXPECT_EQ("ok.", response_data);
9543 }
9544
9545 // Test that we restart a connection if we get a decompression failure from the
9546 // peer while reading the first bytes from the connection. This occurs when the
9547 // peer cannot handle DEFLATE but we're using False Start, so we don't notice
9548 // in the handshake.
9549 TEST_F(HttpNetworkTransactionSpdy3Test,
9550 RestartAfterTLSDecompressionFailureWithFalseStart) {
9551 HttpRequestInfo request;
9552 request.method = "GET";
9553 request.url = GURL("https://tlsdecompressionfailure2.example.com/");
9554 request.load_flags = 0;
9555
9556 SpdySessionDependencies session_deps;
9557 TLSDecompressionFailureSocketDataProvider socket_data_provider1(
9558 true /* fail all reads */);
9559 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false);
9560 SSLSocketDataProvider ssl_socket_data_provider1(SYNCHRONOUS, OK);
9561 SSLSocketDataProvider ssl_socket_data_provider2(SYNCHRONOUS, OK);
9562 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider1);
9563 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider2);
9564 session_deps.socket_factory->AddSSLSocketDataProvider(
9565 &ssl_socket_data_provider1);
9566 session_deps.socket_factory->AddSSLSocketDataProvider(
9567 &ssl_socket_data_provider2);
9568
9569 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
9570 scoped_ptr<HttpTransaction> trans(
9571 new HttpNetworkTransaction(DEFAULT_PRIORITY, session));
9572 TestCompletionCallback callback;
9573
9574 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
9575 EXPECT_EQ(ERR_IO_PENDING, rv);
9576 EXPECT_EQ(OK, callback.WaitForResult());
9577
9578 const HttpResponseInfo* response = trans->GetResponseInfo();
9579 ASSERT_TRUE(response != NULL);
9580 ASSERT_TRUE(response->headers != NULL);
9581 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
9582
9583 std::string response_data;
9584 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
9585 EXPECT_EQ("ok.", response_data);
9586 }
9587
9588 // This tests the case that a request is issued via http instead of spdy after 9473 // This tests the case that a request is issued via http instead of spdy after
9589 // npn is negotiated. 9474 // npn is negotiated.
9590 TEST_F(HttpNetworkTransactionSpdy3Test, NpnWithHttpOverSSL) { 9475 TEST_F(HttpNetworkTransactionSpdy3Test, NpnWithHttpOverSSL) {
9591 HttpStreamFactory::set_use_alternate_protocols(true); 9476 HttpStreamFactory::set_use_alternate_protocols(true);
9592 HttpStreamFactory::SetNextProtos( 9477 HttpStreamFactory::SetNextProtos(
9593 MakeNextProtos("http/1.1", "http1.1", NULL)); 9478 MakeNextProtos("http/1.1", "http1.1", NULL));
9594 SpdySessionDependencies session_deps; 9479 SpdySessionDependencies session_deps;
9595 HttpRequestInfo request; 9480 HttpRequestInfo request;
9596 request.method = "GET"; 9481 request.method = "GET";
9597 request.url = GURL("https://www.google.com/"); 9482 request.url = GURL("https://www.google.com/");
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
11309 trans2.Start(&request2, callback2.callback(), BoundNetLog())); 11194 trans2.Start(&request2, callback2.callback(), BoundNetLog()));
11310 MessageLoop::current()->RunUntilIdle(); 11195 MessageLoop::current()->RunUntilIdle();
11311 data2->RunFor(3); 11196 data2->RunFor(3);
11312 11197
11313 ASSERT_TRUE(callback2.have_result()); 11198 ASSERT_TRUE(callback2.have_result());
11314 EXPECT_EQ(OK, callback2.WaitForResult()); 11199 EXPECT_EQ(OK, callback2.WaitForResult());
11315 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); 11200 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy);
11316 } 11201 }
11317 11202
11318 } // namespace net 11203 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_spdy2_unittest.cc ('k') | net/http/http_network_transaction_ssl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698