Index: net/tools/quic/quic_dispatcher_test.cc |
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc |
index a857e74e66e773ed82f489f45e8f5a8faa373454..62d7b4238d31829d814f991382f5d7b7bf61d9ea 100644 |
--- a/net/tools/quic/quic_dispatcher_test.cc |
+++ b/net/tools/quic/quic_dispatcher_test.cc |
@@ -17,6 +17,7 @@ |
#include "net/quic/core/quic_flags.h" |
#include "net/quic/core/quic_utils.h" |
#include "net/quic/test_tools/crypto_test_utils.h" |
+#include "net/quic/test_tools/fake_proof_source.h" |
#include "net/quic/test_tools/quic_buffered_packet_store_peer.h" |
#include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
#include "net/quic/test_tools/quic_test_utils.h" |
@@ -1539,91 +1540,6 @@ TEST_P(BufferedPacketStoreTest, ReceiveCHLOForBufferedConnection) { |
EXPECT_TRUE(store->HasChloForConnection(/*connection_id=*/1)); |
} |
-// Implementation of ProofSource which delegates to a ProofSourceForTesting, |
-// except that when the async GetProof is called, it captures the call and |
-// allows tests to see that a call is pending, which they can then cause to |
-// complete at a time of their choosing. |
-class FakeProofSource : public ProofSource { |
- public: |
- FakeProofSource() : delegate_(CryptoTestUtils::ProofSourceForTesting()) {} |
- |
- // Before this object is "active", all calls to GetProof will be delegated |
- // immediately. Once "active", the async ones will be intercepted. This |
- // distinction is necessary to ensure that GetProof can be called without |
- // interference during test case setup. |
- void Activate() { active_ = true; } |
- |
- bool GetProof(const IPAddress& server_ip, |
- const string& hostname, |
- const string& server_config, |
- QuicVersion quic_version, |
- StringPiece chlo_hash, |
- scoped_refptr<ProofSource::Chain>* out_chain, |
- string* out_signature, |
- string* out_leaf_cert_sct) override { |
- return delegate_->GetProof(server_ip, hostname, server_config, quic_version, |
- chlo_hash, out_chain, out_signature, |
- out_leaf_cert_sct); |
- } |
- |
- void GetProof(const IPAddress& server_ip, |
- const string& hostname, |
- const string& server_config, |
- QuicVersion quic_version, |
- StringPiece chlo_hash, |
- std::unique_ptr<ProofSource::Callback> callback) override { |
- if (!active_) { |
- scoped_refptr<Chain> chain; |
- string signature; |
- string leaf_cert_sct; |
- const bool ok = |
- GetProof(server_ip, hostname, server_config, quic_version, |
- chlo_hash.as_string(), &chain, &signature, &leaf_cert_sct); |
- callback->Run(ok, chain, signature, leaf_cert_sct, |
- /* details = */ nullptr); |
- return; |
- } |
- |
- params_.push_back(Params{server_ip, hostname, server_config, quic_version, |
- chlo_hash.as_string(), std::move(callback)}); |
- } |
- |
- int NumPendingCallbacks() const { return params_.size(); } |
- |
- void InvokePendingCallback(int n) { |
- CHECK(NumPendingCallbacks() > n); |
- |
- const Params& params = params_[n]; |
- |
- scoped_refptr<ProofSource::Chain> chain; |
- string signature; |
- string leaf_cert_sct; |
- const bool ok = delegate_->GetProof(params.server_ip, params.hostname, |
- params.server_config, |
- params.quic_version, params.chlo_hash, |
- &chain, &signature, &leaf_cert_sct); |
- |
- params.callback->Run(ok, chain, signature, leaf_cert_sct, |
- /* details = */ nullptr); |
- params_.erase(params_.begin() + n); |
- } |
- |
- private: |
- std::unique_ptr<ProofSource> delegate_; |
- bool active_ = false; |
- |
- struct Params { |
- IPAddress server_ip; |
- string hostname; |
- string server_config; |
- QuicVersion quic_version; |
- string chlo_hash; |
- std::unique_ptr<ProofSource::Callback> callback; |
- }; |
- |
- std::vector<Params> params_; |
-}; |
- |
// Test which exercises the async GetProof codepaths, especially in the context |
// of stateless rejection. |
class AsyncGetProofTest : public QuicDispatcherTest { |