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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/ssl/ssl_socket_config_service.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "net/base/host_port_pair.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h"
12
13 using testing::_;
14 using testing::Return;
15
16 namespace net {
17
18 class MockSSLSocketConfigService : public SSLSocketConfigService {
19 public:
20 MockSSLSocketConfigService() : SSLSocketConfigService() {}
21 ~MockSSLSocketConfigService() {}
22
23 MOCK_METHOD1(IsGoogle, bool(const HostPortPair& host_and_port));
24 };
25
26 class SSLSocketConfigServiceTest : public testing::Test {};
27
28 TEST_F(SSLSocketConfigServiceTest, CheckGoogleEndpoint) {
29 scoped_ptr<SSLSocketConfigService> config_service(
30 new SSLSocketConfigService());
31 ASSERT_TRUE(config_service->IsGoogle(
32 HostPortPair::FromURL(GURL("https://www.google.com"))));
33 }
34
35 TEST_F(SSLSocketConfigServiceTest, CheckGoogleSubdomainEndpoint) {
36 scoped_ptr<SSLSocketConfigService> config_service(
37 new SSLSocketConfigService());
38 ASSERT_TRUE(config_service->IsGoogle(
39 HostPortPair::FromURL(GURL("http://mail.google.com"))));
40 }
41
42 TEST_F(SSLSocketConfigServiceTest, CheckNonGoogleEndpoint) {
43 scoped_ptr<SSLSocketConfigService> config_service(
44 new SSLSocketConfigService());
45 ASSERT_FALSE(config_service->IsGoogle(
46 HostPortPair::FromURL(GURL("http://www.foobar.com"))));
47 }
48
49 TEST_F(SSLSocketConfigServiceTest, GoogleEndpointWhenEnabled) {
50 scoped_ptr<MockSSLSocketConfigService> config_service(
51 new MockSSLSocketConfigService());
52 EXPECT_CALL(*config_service.get(), IsGoogle(_)).Times(1)
53 .WillRepeatedly(Return(true));
54 config_service->EnableFastRadioPadding();
55 ASSERT_TRUE(config_service->UseFastRadioPadding(
56 HostPortPair::FromURL(GURL("http://www.google.com"))));
57 }
58
59 TEST_F(SSLSocketConfigServiceTest, GoogleEndpointWhenDisabled) {
60 scoped_ptr<MockSSLSocketConfigService> config_service(
61 new MockSSLSocketConfigService());
62 config_service->DisableFastRadioPadding();
63 ASSERT_FALSE(config_service->UseFastRadioPadding(
64 HostPortPair::FromURL(GURL("http://www.google.com"))));
65 }
66
67 TEST_F(SSLSocketConfigServiceTest, NonGoogleEndpointWhenEnabled) {
68 scoped_ptr<MockSSLSocketConfigService> config_service(
69 new MockSSLSocketConfigService());
70 EXPECT_CALL(*config_service.get(), IsGoogle(_)).Times(1)
71 .WillRepeatedly(Return(false));
72 config_service->EnableFastRadioPadding();
73 ASSERT_FALSE(config_service->UseFastRadioPadding(
74 HostPortPair::FromURL(GURL("http://www.foobar.com"))));
75 }
76
77 TEST_F(SSLSocketConfigServiceTest, NonGoogleEndpointWhenDisabled) {
78 scoped_ptr<MockSSLSocketConfigService> config_service(
79 new MockSSLSocketConfigService());
80 config_service->DisableFastRadioPadding();
81 ASSERT_FALSE(config_service->UseFastRadioPadding(
82 HostPortPair::FromURL(GURL("http://www.foobar.com"))));
83 }
84
85 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698