Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: net/quic/crypto/proof_test.cc

Issue 2125063003: Add async variant of ProofSource::GetProof (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@126463885
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/quic/crypto/proof_test.cc
diff --git a/net/quic/crypto/proof_test.cc b/net/quic/crypto/proof_test.cc
index 5392a635d60e709d1ccbe3d6cd7ff25cfe50212f..615cc12b71db3079775ac2a9a51beb4f704e0fd2 100644
--- a/net/quic/crypto/proof_test.cc
+++ b/net/quic/crypto/proof_test.cc
@@ -106,6 +106,38 @@ string LoadTestCert(const string& file_name) {
return der_bytes;
}
+class TestCallback : public ProofSource::Callback {
+ public:
+ explicit TestCallback(bool* called,
+ bool* ok,
+ scoped_refptr<ProofSource::Chain>* chain,
+ string* signature,
+ string* leaf_cert_sct)
+ : called_(called),
+ ok_(ok),
+ chain_(chain),
+ signature_(signature),
+ leaf_cert_sct_(leaf_cert_sct) {}
+
+ void Run(bool ok,
+ const scoped_refptr<ProofSource::Chain>& chain,
+ const string& signature,
+ const string& leaf_cert_sct) override {
+ *ok_ = ok;
+ *chain_ = chain;
+ *signature_ = signature;
+ *leaf_cert_sct_ = leaf_cert_sct;
+ *called_ = true;
+ }
+
+ private:
+ bool* called_;
+ bool* ok_;
+ scoped_refptr<ProofSource::Chain>* chain_;
+ string* signature_;
+ string* leaf_cert_sct_;
+};
+
class ProofTest : public ::testing::TestWithParam<QuicVersion> {};
} // namespace
@@ -172,6 +204,43 @@ TEST_P(ProofTest, DISABLED_Verify) {
first_chlo_hash, wrong_certs, corrupt_signature, false);
}
+TEST_P(ProofTest, VerifySourceAsync) {
+ std::unique_ptr<ProofSource> source(CryptoTestUtils::ProofSourceForTesting());
+
+ const string server_config = "server config bytes";
+ const string hostname = "test.example.com";
+ const string first_chlo_hash = "first chlo hash bytes";
+ const string second_chlo_hash = "first chlo hash bytes";
+ const QuicVersion quic_version = GetParam();
+ IPAddress server_ip;
+
+ // Call synchronous version
+ scoped_refptr<ProofSource::Chain> expected_chain;
+ string expected_signature;
+ string expected_leaf_cert_sct;
+ ASSERT_TRUE(source->GetProof(server_ip, hostname, server_config, quic_version,
+ first_chlo_hash, false /* no ECDSA */,
+ &expected_chain, &expected_signature,
+ &expected_leaf_cert_sct));
+
+ // Call asynchronous version and compare results
+ bool called = false;
+ bool ok;
+ scoped_refptr<ProofSource::Chain> chain;
+ string signature;
+ string leaf_cert_sct;
+ std::unique_ptr<ProofSource::Callback> cb(
+ new TestCallback(&called, &ok, &chain, &signature, &leaf_cert_sct));
+ source->GetProof(server_ip, hostname, server_config, quic_version,
+ first_chlo_hash, false /* no ECDSA */, std::move(cb));
+ // TODO(gredner): whan GetProof really invokes the callback asynchronously,
+ // figure out what to do here.
+ ASSERT_TRUE(called);
+ ASSERT_TRUE(ok);
+ EXPECT_THAT(chain->certs, ::testing::ContainerEq(expected_chain->certs));
+ EXPECT_EQ(leaf_cert_sct, expected_leaf_cert_sct);
+}
+
TEST_P(ProofTest, UseAfterFree) {
ProofSource* source = CryptoTestUtils::ProofSourceForTesting();
« net/quic/crypto/proof_source_chromium.cc ('K') | « net/quic/crypto/proof_source_chromium.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698