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

Unified Diff: net/ssl/ssl_socket_config_service_unittest.cc

Issue 869393005: Perform ClientHello padding if the field trial is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@net_connection_error_uma
Patch Set: Created 5 years, 11 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/ssl/ssl_socket_config_service_unittest.cc
diff --git a/net/ssl/ssl_socket_config_service_unittest.cc b/net/ssl/ssl_socket_config_service_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e8056f681087aaec1175d0f5208f15b746169cbb
--- /dev/null
+++ b/net/ssl/ssl_socket_config_service_unittest.cc
@@ -0,0 +1,85 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/ssl/ssl_socket_config_service.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "net/base/host_port_pair.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+using testing::_;
+using testing::Return;
+
+namespace net {
+
+class MockSSLSocketConfigService : public SSLSocketConfigService {
+ public:
+ MockSSLSocketConfigService() : SSLSocketConfigService() {}
+ ~MockSSLSocketConfigService() {}
+
+ MOCK_METHOD1(IsGoogle, bool(const HostPortPair& host_and_port));
+};
+
+class SSLSocketConfigServiceTest : public testing::Test {};
+
+TEST_F(SSLSocketConfigServiceTest, CheckGoogleEndpoint) {
+ scoped_ptr<SSLSocketConfigService> config_service(
+ new SSLSocketConfigService());
+ ASSERT_TRUE(config_service->IsGoogle(
+ HostPortPair::FromURL(GURL("https://www.google.com"))));
+}
+
+TEST_F(SSLSocketConfigServiceTest, CheckGoogleSubdomainEndpoint) {
+ scoped_ptr<SSLSocketConfigService> config_service(
+ new SSLSocketConfigService());
+ ASSERT_TRUE(config_service->IsGoogle(
+ HostPortPair::FromURL(GURL("http://mail.google.com"))));
+}
+
+TEST_F(SSLSocketConfigServiceTest, CheckNonGoogleEndpoint) {
+ scoped_ptr<SSLSocketConfigService> config_service(
+ new SSLSocketConfigService());
+ ASSERT_FALSE(config_service->IsGoogle(
+ HostPortPair::FromURL(GURL("http://www.foobar.com"))));
+}
+
+TEST_F(SSLSocketConfigServiceTest, GoogleEndpointWhenEnabled) {
+ scoped_ptr<MockSSLSocketConfigService> config_service(
+ new MockSSLSocketConfigService());
+ EXPECT_CALL(*config_service.get(), IsGoogle(_)).Times(1)
+ .WillRepeatedly(Return(true));
+ config_service->EnableFastRadioPadding();
+ ASSERT_TRUE(config_service->UseFastRadioPadding(
+ HostPortPair::FromURL(GURL("http://www.google.com"))));
+}
+
+TEST_F(SSLSocketConfigServiceTest, GoogleEndpointWhenDisabled) {
+ scoped_ptr<MockSSLSocketConfigService> config_service(
+ new MockSSLSocketConfigService());
+ config_service->DisableFastRadioPadding();
+ ASSERT_FALSE(config_service->UseFastRadioPadding(
+ HostPortPair::FromURL(GURL("http://www.google.com"))));
+}
+
+TEST_F(SSLSocketConfigServiceTest, NonGoogleEndpointWhenEnabled) {
+ scoped_ptr<MockSSLSocketConfigService> config_service(
+ new MockSSLSocketConfigService());
+ EXPECT_CALL(*config_service.get(), IsGoogle(_)).Times(1)
+ .WillRepeatedly(Return(false));
+ config_service->EnableFastRadioPadding();
+ ASSERT_FALSE(config_service->UseFastRadioPadding(
+ HostPortPair::FromURL(GURL("http://www.foobar.com"))));
+}
+
+TEST_F(SSLSocketConfigServiceTest, NonGoogleEndpointWhenDisabled) {
+ scoped_ptr<MockSSLSocketConfigService> config_service(
+ new MockSSLSocketConfigService());
+ config_service->DisableFastRadioPadding();
+ ASSERT_FALSE(config_service->UseFastRadioPadding(
+ HostPortPair::FromURL(GURL("http://www.foobar.com"))));
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698