OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/quartc/quartc_session.h" | 5 #include "net/quic/quartc/quartc_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "net/base/ip_endpoint.h" | 11 #include "net/base/ip_endpoint.h" |
12 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" | 12 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" |
13 #include "net/quic/core/crypto/proof_source.h" | 13 #include "net/quic/core/crypto/proof_source.h" |
14 #include "net/quic/core/crypto/proof_verifier.h" | 14 #include "net/quic/core/crypto/proof_verifier.h" |
15 #include "net/quic/core/crypto/quic_crypto_client_config.h" | 15 #include "net/quic/core/crypto/quic_crypto_client_config.h" |
16 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 16 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
17 #include "net/quic/core/crypto/quic_random.h" | 17 #include "net/quic/core/crypto/quic_random.h" |
18 #include "net/quic/core/quic_crypto_client_stream.h" | 18 #include "net/quic/core/quic_crypto_client_stream.h" |
19 #include "net/quic/core/quic_crypto_server_stream.h" | 19 #include "net/quic/core/quic_crypto_server_stream.h" |
20 #include "net/quic/core/quic_simple_buffer_allocator.h" | 20 #include "net/quic/core/quic_simple_buffer_allocator.h" |
| 21 #include "net/quic/platform/api/quic_string_piece.h" |
21 #include "net/quic/platform/impl/quic_chromium_clock.h" | 22 #include "net/quic/platform/impl/quic_chromium_clock.h" |
22 #include "net/quic/quartc/quartc_alarm_factory.h" | 23 #include "net/quic/quartc/quartc_alarm_factory.h" |
23 #include "net/quic/quartc/quartc_packet_writer.h" | 24 #include "net/quic/quartc/quartc_packet_writer.h" |
24 #include "net/quic/test_tools/quic_test_utils.h" | 25 #include "net/quic/test_tools/quic_test_utils.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 namespace test { | 29 namespace test { |
29 namespace { | 30 namespace { |
30 | 31 |
(...skipping 19 matching lines...) Expand all Loading... |
50 // canned response equal to |success|. | 51 // canned response equal to |success|. |
51 class FakeProofSource : public net::ProofSource { | 52 class FakeProofSource : public net::ProofSource { |
52 public: | 53 public: |
53 explicit FakeProofSource(bool success) : success_(success) {} | 54 explicit FakeProofSource(bool success) : success_(success) {} |
54 | 55 |
55 // ProofSource override. | 56 // ProofSource override. |
56 void GetProof(const QuicSocketAddress& server_ip, | 57 void GetProof(const QuicSocketAddress& server_ip, |
57 const std::string& hostname, | 58 const std::string& hostname, |
58 const std::string& server_config, | 59 const std::string& server_config, |
59 net::QuicVersion quic_version, | 60 net::QuicVersion quic_version, |
60 base::StringPiece chlo_hash, | 61 QuicStringPiece chlo_hash, |
61 const net::QuicTagVector& connection_options, | 62 const net::QuicTagVector& connection_options, |
62 std::unique_ptr<Callback> callback) override { | 63 std::unique_ptr<Callback> callback) override { |
63 QuicReferenceCountedPointer<net::ProofSource::Chain> chain; | 64 QuicReferenceCountedPointer<net::ProofSource::Chain> chain; |
64 net::QuicCryptoProof proof; | 65 net::QuicCryptoProof proof; |
65 if (success_) { | 66 if (success_) { |
66 std::vector<std::string> certs; | 67 std::vector<std::string> certs; |
67 certs.push_back("Required to establish handshake"); | 68 certs.push_back("Required to establish handshake"); |
68 chain = new ProofSource::Chain(certs); | 69 chain = new ProofSource::Chain(certs); |
69 proof.signature = "Signature"; | 70 proof.signature = "Signature"; |
70 proof.leaf_cert_scts = "Time"; | 71 proof.leaf_cert_scts = "Time"; |
(...skipping 11 matching lines...) Expand all Loading... |
82 class FakeProofVerifier : public net::ProofVerifier { | 83 class FakeProofVerifier : public net::ProofVerifier { |
83 public: | 84 public: |
84 explicit FakeProofVerifier(bool success) : success_(success) {} | 85 explicit FakeProofVerifier(bool success) : success_(success) {} |
85 | 86 |
86 // ProofVerifier override | 87 // ProofVerifier override |
87 net::QuicAsyncStatus VerifyProof( | 88 net::QuicAsyncStatus VerifyProof( |
88 const std::string& hostname, | 89 const std::string& hostname, |
89 const uint16_t port, | 90 const uint16_t port, |
90 const std::string& server_config, | 91 const std::string& server_config, |
91 net::QuicVersion quic_version, | 92 net::QuicVersion quic_version, |
92 base::StringPiece chlo_hash, | 93 QuicStringPiece chlo_hash, |
93 const std::vector<std::string>& certs, | 94 const std::vector<std::string>& certs, |
94 const std::string& cert_sct, | 95 const std::string& cert_sct, |
95 const std::string& signature, | 96 const std::string& signature, |
96 const ProofVerifyContext* context, | 97 const ProofVerifyContext* context, |
97 std::string* error_details, | 98 std::string* error_details, |
98 std::unique_ptr<net::ProofVerifyDetails>* verify_details, | 99 std::unique_ptr<net::ProofVerifyDetails>* verify_details, |
99 std::unique_ptr<net::ProofVerifierCallback> callback) override { | 100 std::unique_ptr<net::ProofVerifierCallback> callback) override { |
100 return success_ ? net::QUIC_SUCCESS : net::QUIC_FAILURE; | 101 return success_ ? net::QUIC_SUCCESS : net::QUIC_FAILURE; |
101 } | 102 } |
102 | 103 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 EXPECT_FALSE(client_peer_->IsClosedStream(id)); | 495 EXPECT_FALSE(client_peer_->IsClosedStream(id)); |
495 stream->SetDelegate(client_peer_->stream_delegate()); | 496 stream->SetDelegate(client_peer_->stream_delegate()); |
496 stream->Close(); | 497 stream->Close(); |
497 RunLoopWithTimeout(); | 498 RunLoopWithTimeout(); |
498 EXPECT_TRUE(client_peer_->IsClosedStream(id)); | 499 EXPECT_TRUE(client_peer_->IsClosedStream(id)); |
499 } | 500 } |
500 | 501 |
501 } // namespace | 502 } // namespace |
502 } // namespace test | 503 } // namespace test |
503 } // namespace net | 504 } // namespace net |
OLD | NEW |