OLD | NEW |
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 <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 EXPECT_EQ(ERR_QUIC_PROTOCOL_ERROR, callback.WaitForResult()); | 2023 EXPECT_EQ(ERR_QUIC_PROTOCOL_ERROR, callback.WaitForResult()); |
2024 | 2024 |
2025 NetErrorDetails details; | 2025 NetErrorDetails details; |
2026 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); | 2026 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); |
2027 | 2027 |
2028 trans->PopulateNetErrorDetails(&details); | 2028 trans->PopulateNetErrorDetails(&details); |
2029 // Verify the error code logged is what sent by the peer. | 2029 // Verify the error code logged is what sent by the peer. |
2030 EXPECT_EQ(QUIC_CRYPTO_VERSION_NOT_SUPPORTED, details.quic_connection_error); | 2030 EXPECT_EQ(QUIC_CRYPTO_VERSION_NOT_SUPPORTED, details.quic_connection_error); |
2031 } | 2031 } |
2032 | 2032 |
2033 TEST_P(QuicNetworkTransactionTest, | |
2034 LogGranularQuicErrorCodeOnQuicProtocolErrorRemote) { | |
2035 MockQuicData mock_quic_data; | |
2036 mock_quic_data.AddWrite( | |
2037 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, | |
2038 GetRequestHeaders("GET", "https", "/"))); | |
2039 // Peer sending an invalid stream frame with a invalid stream error causes | |
2040 // this end to raise error and close connection. | |
2041 mock_quic_data.AddRead(ConstructRstPacket(1, false, kClientDataStreamId1, | |
2042 QUIC_STREAM_LAST_ERROR)); | |
2043 std::string quic_error_details = "Invalid rst stream error code."; | |
2044 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket( | |
2045 2, QuicTime::Delta::Infinite(), 0, 1, QUIC_INVALID_RST_STREAM_DATA, | |
2046 quic_error_details)); | |
2047 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | |
2048 | |
2049 // The non-alternate protocol job needs to hang in order to guarantee that | |
2050 // the alternate-protocol job will "win". | |
2051 AddHangingNonAlternateProtocolSocketData(); | |
2052 | |
2053 // In order for a new QUIC session to be established via alternate-protocol | |
2054 // without racing an HTTP connection, we need the host resolution to happen | |
2055 // synchronously. Of course, even though QUIC *could* perform a 0-RTT | |
2056 // connection to the the server, in this test we require confirmation | |
2057 // before encrypting so the HTTP job will still start. | |
2058 host_resolver_.set_synchronous_mode(true); | |
2059 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", | |
2060 ""); | |
2061 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); | |
2062 AddressList address; | |
2063 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), | |
2064 nullptr, net_log_.bound()); | |
2065 | |
2066 CreateSession(); | |
2067 session_->quic_stream_factory()->set_require_confirmation(true); | |
2068 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | |
2069 | |
2070 std::unique_ptr<HttpNetworkTransaction> trans( | |
2071 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | |
2072 TestCompletionCallback callback; | |
2073 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | |
2074 EXPECT_EQ(ERR_IO_PENDING, rv); | |
2075 | |
2076 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | |
2077 QuicSession::HANDSHAKE_CONFIRMED); | |
2078 EXPECT_EQ(ERR_QUIC_PROTOCOL_ERROR, callback.WaitForResult()); | |
2079 NetErrorDetails details; | |
2080 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); | |
2081 | |
2082 trans->PopulateNetErrorDetails(&details); | |
2083 EXPECT_EQ(QUIC_INVALID_RST_STREAM_DATA, details.quic_connection_error); | |
2084 } | |
2085 | |
2086 TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocol) { | 2033 TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocol) { |
2087 // Alternate-protocol job | 2034 // Alternate-protocol job |
2088 std::unique_ptr<QuicEncryptedPacket> close(ConstructConnectionClosePacket(1)); | 2035 std::unique_ptr<QuicEncryptedPacket> close(ConstructConnectionClosePacket(1)); |
2089 MockRead quic_reads[] = { | 2036 MockRead quic_reads[] = { |
2090 MockRead(ASYNC, close->data(), close->length()), | 2037 MockRead(ASYNC, close->data(), close->length()), |
2091 MockRead(ASYNC, ERR_IO_PENDING), // No more data to read | 2038 MockRead(ASYNC, ERR_IO_PENDING), // No more data to read |
2092 MockRead(ASYNC, OK), // EOF | 2039 MockRead(ASYNC, OK), // EOF |
2093 }; | 2040 }; |
2094 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), nullptr, | 2041 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), nullptr, |
2095 0); | 2042 0); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 std::unique_ptr<HttpNetworkTransaction> trans( | 2296 std::unique_ptr<HttpNetworkTransaction> trans( |
2350 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 2297 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
2351 TestCompletionCallback callback; | 2298 TestCompletionCallback callback; |
2352 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | 2299 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
2353 EXPECT_EQ(ERR_IO_PENDING, rv); | 2300 EXPECT_EQ(ERR_IO_PENDING, rv); |
2354 EXPECT_NE(OK, callback.WaitForResult()); | 2301 EXPECT_NE(OK, callback.WaitForResult()); |
2355 } | 2302 } |
2356 | 2303 |
2357 } // namespace test | 2304 } // namespace test |
2358 } // namespace net | 2305 } // namespace net |
OLD | NEW |