| 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 "net/quic/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 3782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3793 EXPECT_THAT(callback_.WaitForResult(), IsOk()); | 3793 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
| 3794 stream = request2.CreateStream(); | 3794 stream = request2.CreateStream(); |
| 3795 stream.reset(); // Will reset stream 3. | 3795 stream.reset(); // Will reset stream 3. |
| 3796 | 3796 |
| 3797 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 3797 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 3798 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 3798 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 3799 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 3799 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 3800 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 3800 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 3801 } | 3801 } |
| 3802 | 3802 |
| 3803 TEST_P(QuicStreamFactoryTest, OnCertAdded) { | 3803 TEST_P(QuicStreamFactoryTest, OnCertDBChanged) { |
| 3804 Initialize(); | 3804 Initialize(); |
| 3805 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 3805 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 3806 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 3806 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 3807 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | |
| 3808 | |
| 3809 MockQuicData socket_data; | |
| 3810 socket_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); | |
| 3811 socket_data.AddWrite(ConstructClientRstPacket()); | |
| 3812 socket_data.AddSocketDataToFactory(&socket_factory_); | |
| 3813 | |
| 3814 MockQuicData socket_data2; | |
| 3815 socket_data2.AddRead(SYNCHRONOUS, ERR_IO_PENDING); | |
| 3816 socket_data2.AddSocketDataToFactory(&socket_factory_); | |
| 3817 | |
| 3818 QuicStreamRequest request(factory_.get()); | |
| 3819 EXPECT_EQ(ERR_IO_PENDING, | |
| 3820 request.Request(host_port_pair_, privacy_mode_, | |
| 3821 /*cert_verify_flags=*/0, url_, "GET", net_log_, | |
| 3822 callback_.callback())); | |
| 3823 | |
| 3824 EXPECT_THAT(callback_.WaitForResult(), IsOk()); | |
| 3825 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); | |
| 3826 HttpRequestInfo request_info; | |
| 3827 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | |
| 3828 net_log_, CompletionCallback())); | |
| 3829 | |
| 3830 // Add a cert and verify that stream saw the event. | |
| 3831 factory_->OnCertAdded(nullptr); | |
| 3832 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | |
| 3833 stream->ReadResponseHeaders(callback_.callback())); | |
| 3834 EXPECT_FALSE(factory_->require_confirmation()); | |
| 3835 | |
| 3836 // Now attempting to request a stream to the same origin should create | |
| 3837 // a new session. | |
| 3838 | |
| 3839 QuicStreamRequest request2(factory_.get()); | |
| 3840 EXPECT_EQ(ERR_IO_PENDING, | |
| 3841 request2.Request(host_port_pair_, privacy_mode_, | |
| 3842 /*cert_verify_flags=*/0, url_, "GET", net_log_, | |
| 3843 callback_.callback())); | |
| 3844 | |
| 3845 EXPECT_THAT(callback_.WaitForResult(), IsOk()); | |
| 3846 stream = request2.CreateStream(); | |
| 3847 stream.reset(); // Will reset stream 3. | |
| 3848 | |
| 3849 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | |
| 3850 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | |
| 3851 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | |
| 3852 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | |
| 3853 } | |
| 3854 | |
| 3855 TEST_P(QuicStreamFactoryTest, OnCACertChanged) { | |
| 3856 Initialize(); | |
| 3857 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | |
| 3858 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | |
| 3859 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 3807 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 3860 | 3808 |
| 3861 MockQuicData socket_data; | 3809 MockQuicData socket_data; |
| 3862 socket_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); | 3810 socket_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); |
| 3863 socket_data.AddWrite(ConstructClientRstPacket()); | 3811 socket_data.AddWrite(ConstructClientRstPacket()); |
| 3864 socket_data.AddSocketDataToFactory(&socket_factory_); | 3812 socket_data.AddSocketDataToFactory(&socket_factory_); |
| 3865 | 3813 |
| 3866 MockQuicData socket_data2; | 3814 MockQuicData socket_data2; |
| 3867 socket_data2.AddRead(SYNCHRONOUS, ERR_IO_PENDING); | 3815 socket_data2.AddRead(SYNCHRONOUS, ERR_IO_PENDING); |
| 3868 socket_data2.AddSocketDataToFactory(&socket_factory_); | 3816 socket_data2.AddSocketDataToFactory(&socket_factory_); |
| 3869 | 3817 |
| 3870 QuicStreamRequest request(factory_.get()); | 3818 QuicStreamRequest request(factory_.get()); |
| 3871 EXPECT_EQ(ERR_IO_PENDING, | 3819 EXPECT_EQ(ERR_IO_PENDING, |
| 3872 request.Request(host_port_pair_, privacy_mode_, | 3820 request.Request(host_port_pair_, privacy_mode_, |
| 3873 /*cert_verify_flags=*/0, url_, "GET", net_log_, | 3821 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3874 callback_.callback())); | 3822 callback_.callback())); |
| 3875 | 3823 |
| 3876 EXPECT_THAT(callback_.WaitForResult(), IsOk()); | 3824 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
| 3877 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); | 3825 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); |
| 3878 HttpRequestInfo request_info; | 3826 HttpRequestInfo request_info; |
| 3879 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 3827 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 3880 net_log_, CompletionCallback())); | 3828 net_log_, CompletionCallback())); |
| 3881 | 3829 |
| 3882 // Change the CA cert and verify that stream saw the event. | 3830 // Change the CA cert and verify that stream saw the event. |
| 3883 factory_->OnCACertChanged(nullptr); | 3831 factory_->OnCertDBChanged(nullptr); |
| 3884 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 3832 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 3885 stream->ReadResponseHeaders(callback_.callback())); | 3833 stream->ReadResponseHeaders(callback_.callback())); |
| 3886 EXPECT_FALSE(factory_->require_confirmation()); | 3834 EXPECT_FALSE(factory_->require_confirmation()); |
| 3887 | 3835 |
| 3888 // Now attempting to request a stream to the same origin should create | 3836 // Now attempting to request a stream to the same origin should create |
| 3889 // a new session. | 3837 // a new session. |
| 3890 | 3838 |
| 3891 QuicStreamRequest request2(factory_.get()); | 3839 QuicStreamRequest request2(factory_.get()); |
| 3892 EXPECT_EQ(ERR_IO_PENDING, | 3840 EXPECT_EQ(ERR_IO_PENDING, |
| 3893 request2.Request(host_port_pair_, privacy_mode_, | 3841 request2.Request(host_port_pair_, privacy_mode_, |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5275 // Clear all cached states. | 5223 // Clear all cached states. |
| 5276 factory_->ClearCachedStatesInCryptoConfig( | 5224 factory_->ClearCachedStatesInCryptoConfig( |
| 5277 base::Callback<bool(const GURL&)>()); | 5225 base::Callback<bool(const GURL&)>()); |
| 5278 EXPECT_TRUE(test_cases[0].state->certs().empty()); | 5226 EXPECT_TRUE(test_cases[0].state->certs().empty()); |
| 5279 EXPECT_TRUE(test_cases[1].state->certs().empty()); | 5227 EXPECT_TRUE(test_cases[1].state->certs().empty()); |
| 5280 EXPECT_TRUE(test_cases[2].state->certs().empty()); | 5228 EXPECT_TRUE(test_cases[2].state->certs().empty()); |
| 5281 } | 5229 } |
| 5282 | 5230 |
| 5283 } // namespace test | 5231 } // namespace test |
| 5284 } // namespace net | 5232 } // namespace net |
| OLD | NEW |