| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 run_loop.Run(); | 46 run_loop.Run(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Used by QuicCryptoServerConfig to provide server credentials, returning a | 49 // Used by QuicCryptoServerConfig to provide server credentials, returning a |
| 50 // canned response equal to |success|. | 50 // canned response equal to |success|. |
| 51 class FakeProofSource : public net::ProofSource { | 51 class FakeProofSource : public net::ProofSource { |
| 52 public: | 52 public: |
| 53 explicit FakeProofSource(bool success) : success_(success) {} | 53 explicit FakeProofSource(bool success) : success_(success) {} |
| 54 | 54 |
| 55 // ProofSource override. | 55 // ProofSource override. |
| 56 bool GetProof(const QuicSocketAddress& server_ip, | |
| 57 const std::string& hostname, | |
| 58 const std::string& server_config, | |
| 59 net::QuicVersion quic_version, | |
| 60 base::StringPiece chlo_hash, | |
| 61 const net::QuicTagVector& connection_options, | |
| 62 QuicReferenceCountedPointer<net::ProofSource::Chain>* out_certs, | |
| 63 net::QuicCryptoProof* proof) override { | |
| 64 if (success_) { | |
| 65 std::vector<std::string> certs; | |
| 66 certs.push_back("Required to establish handshake"); | |
| 67 *out_certs = new ProofSource::Chain(certs); | |
| 68 proof->signature = "Signature"; | |
| 69 proof->leaf_cert_scts = "Time"; | |
| 70 } | |
| 71 return success_; | |
| 72 } | |
| 73 | |
| 74 void GetProof(const QuicSocketAddress& server_ip, | 56 void GetProof(const QuicSocketAddress& server_ip, |
| 75 const std::string& hostname, | 57 const std::string& hostname, |
| 76 const std::string& server_config, | 58 const std::string& server_config, |
| 77 net::QuicVersion quic_version, | 59 net::QuicVersion quic_version, |
| 78 base::StringPiece chlo_hash, | 60 base::StringPiece chlo_hash, |
| 79 const net::QuicTagVector& connection_options, | 61 const net::QuicTagVector& connection_options, |
| 80 std::unique_ptr<Callback> callback) override { | 62 std::unique_ptr<Callback> callback) override { |
| 81 LOG(INFO) << "GetProof() providing dummy credentials for insecure QUIC"; | 63 QuicReferenceCountedPointer<net::ProofSource::Chain> chain; |
| 64 net::QuicCryptoProof proof; |
| 65 if (success_) { |
| 66 std::vector<std::string> certs; |
| 67 certs.push_back("Required to establish handshake"); |
| 68 chain = new ProofSource::Chain(certs); |
| 69 proof.signature = "Signature"; |
| 70 proof.leaf_cert_scts = "Time"; |
| 71 } |
| 72 callback->Run(success_, chain, proof, nullptr /* details */); |
| 82 } | 73 } |
| 83 | 74 |
| 84 private: | 75 private: |
| 85 // Whether or not obtaining proof source succeeds. | 76 // Whether or not obtaining proof source succeeds. |
| 86 bool success_; | 77 bool success_; |
| 87 }; | 78 }; |
| 88 | 79 |
| 89 // Used by QuicCryptoClientConfig to verify server credentials, returning a | 80 // Used by QuicCryptoClientConfig to verify server credentials, returning a |
| 90 // canned response of QUIC_SUCCESS if |success| is true. | 81 // canned response of QUIC_SUCCESS if |success| is true. |
| 91 class FakeProofVerifier : public net::ProofVerifier { | 82 class FakeProofVerifier : public net::ProofVerifier { |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 EXPECT_FALSE(client_peer_->IsClosedStream(id)); | 494 EXPECT_FALSE(client_peer_->IsClosedStream(id)); |
| 504 stream->SetDelegate(client_peer_->stream_delegate()); | 495 stream->SetDelegate(client_peer_->stream_delegate()); |
| 505 stream->Close(); | 496 stream->Close(); |
| 506 RunLoopWithTimeout(); | 497 RunLoopWithTimeout(); |
| 507 EXPECT_TRUE(client_peer_->IsClosedStream(id)); | 498 EXPECT_TRUE(client_peer_->IsClosedStream(id)); |
| 508 } | 499 } |
| 509 | 500 |
| 510 } // namespace | 501 } // namespace |
| 511 } // namespace test | 502 } // namespace test |
| 512 } // namespace net | 503 } // namespace net |
| OLD | NEW |