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

Unified Diff: net/socket/ssl_client_socket_unittest.cc

Issue 338093012: Fix SSLClientSocketOpenSSL error-handling for Channel ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add error code. Created 6 years, 6 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/socket/ssl_client_socket_unittest.cc
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 7748f07106b2c73f1eeab10bd6ede8e832b5a5dd..94d4f29c8fa6f2d789b7a7e6f4ce0da050ad96b2 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -587,6 +587,38 @@ class FailingServerBoundCertStore : public ServerBoundCertStore {
virtual void SetForceKeepSessionState() OVERRIDE {}
};
+// A ServerBoundCertStore that asynchronously returns an error when asked for a
+// certificate.
+class AsyncFailingServerBoundCertStore : public ServerBoundCertStore {
+ virtual int GetServerBoundCert(const std::string& server_identifier,
+ base::Time* expiration_time,
+ std::string* private_key_result,
+ std::string* cert_result,
+ const GetCertCallback& callback) OVERRIDE {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(callback, ERR_UNEXPECTED,
+ server_identifier, base::Time(), "", ""));
+ return ERR_IO_PENDING;
+ }
+ virtual void SetServerBoundCert(const std::string& server_identifier,
+ base::Time creation_time,
+ base::Time expiration_time,
+ const std::string& private_key,
+ const std::string& cert) OVERRIDE {}
+ virtual void DeleteServerBoundCert(const std::string& server_identifier,
+ const base::Closure& completion_callback)
+ OVERRIDE {}
+ virtual void DeleteAllCreatedBetween(base::Time delete_begin,
+ base::Time delete_end,
+ const base::Closure& completion_callback)
+ OVERRIDE {}
+ virtual void DeleteAll(const base::Closure& completion_callback) OVERRIDE {}
+ virtual void GetAllServerBoundCerts(const GetCertListCallback& callback)
+ OVERRIDE {}
+ virtual int GetCertCount() OVERRIDE { return 0; }
+ virtual void SetForceKeepSessionState() OVERRIDE {}
+};
+
class SSLClientSocketTest : public PlatformTest {
public:
SSLClientSocketTest()
@@ -851,6 +883,13 @@ class SSLClientSocketChannelIDTest : public SSLClientSocketTest {
context_.server_bound_cert_service = cert_service_.get();
}
+ void EnableAsyncFailingChannelID() {
+ cert_service_.reset(new ServerBoundCertService(
+ new AsyncFailingServerBoundCertStore(),
+ base::MessageLoopProxy::current()));
+ context_.server_bound_cert_service = cert_service_.get();
+ }
+
private:
scoped_ptr<ServerBoundCertService> cert_service_;
};
@@ -2616,8 +2655,8 @@ TEST_F(SSLClientSocketChannelIDTest, SendChannelID) {
EXPECT_FALSE(sock_->IsConnected());
}
-// Connect to a server using channel id but without sending a key. It should
-// fail.
+// Connect to a server using channel id but failing to query the store. It
wtc 2014/06/19 22:00:11 Nit: "failing to query the store" sounds like we d
davidben 2014/06/19 22:36:38 Done.
+// should fail.
TEST_F(SSLClientSocketChannelIDTest, FailingChannelID) {
SpawnedTestServer::SSLOptions ssl_options;
@@ -2638,4 +2677,22 @@ TEST_F(SSLClientSocketChannelIDTest, FailingChannelID) {
EXPECT_FALSE(sock_->IsConnected());
}
+// Connect to a server using channel id but asynchronously failing to query the
+// store. It should fail.
+TEST_F(SSLClientSocketChannelIDTest, FailingChannelIDAsync) {
+ SpawnedTestServer::SSLOptions ssl_options;
+
+ ASSERT_TRUE(ConnectToTestServer(ssl_options));
+
+ EnableAsyncFailingChannelID();
+ SSLConfig ssl_config = kDefaultSSLConfig;
+ ssl_config.channel_id_enabled = true;
+
+ int rv;
+ ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
+
+ EXPECT_EQ(ERR_UNEXPECTED, rv);
+ EXPECT_FALSE(sock_->IsConnected());
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698