summaryrefslogtreecommitdiffstats
path: root/net/base/ssl_config_service_win_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/ssl_config_service_win_unittest.cc')
-rw-r--r--net/base/ssl_config_service_win_unittest.cc154
1 files changed, 0 insertions, 154 deletions
diff --git a/net/base/ssl_config_service_win_unittest.cc b/net/base/ssl_config_service_win_unittest.cc
deleted file mode 100644
index 1959be7..0000000
--- a/net/base/ssl_config_service_win_unittest.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2011 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/base/ssl_config_service_win.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using base::TimeDelta;
-using base::TimeTicks;
-
-namespace net {
-
-namespace {
-
-// SSLClientConfig service caches settings for 10 seconds for performance.
-// So we use synthetic time values along with the 'GetSSLConfigAt' method
-// to ensure that the current settings are re-read. By incrementing the time
-// value by 11 seconds, we ensure fresh config settings.
-const int kSSLConfigNextTimeInternal = 11;
-
-class SSLConfigServiceWinObserver : public SSLConfigService::Observer {
- public:
- SSLConfigServiceWinObserver() : change_was_observed_(false) {
- }
- bool change_was_observed() const {
- return change_was_observed_;
- }
- protected:
- virtual void OnSSLConfigChanged() {
- change_was_observed_ = true;
- }
- bool change_was_observed_;
-};
-
-} // namespace
-
-TEST(SSLConfigServiceWinTest, GetNowTest) {
- // Verify that the constructor sets the correct default values.
- SSLConfig config;
- EXPECT_TRUE(config.rev_checking_enabled);
- EXPECT_TRUE(config.ssl3_enabled);
- EXPECT_TRUE(config.tls1_enabled);
-
- bool rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
-}
-
-TEST(SSLConfigServiceWinTest, SetTest) {
- // Save the current settings so we can restore them after the tests.
- SSLConfig config_save;
- bool rv = SSLConfigServiceWin::GetSSLConfigNow(&config_save);
- EXPECT_TRUE(rv);
-
- SSLConfig config;
-
- // Test SetRevCheckingEnabled.
- SSLConfigServiceWin::SetRevCheckingEnabled(true);
- rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
- EXPECT_TRUE(config.rev_checking_enabled);
-
- SSLConfigServiceWin::SetRevCheckingEnabled(false);
- rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
- EXPECT_FALSE(config.rev_checking_enabled);
-
- SSLConfigServiceWin::SetRevCheckingEnabled(
- config_save.rev_checking_enabled);
-
- // Test SetSSL3Enabled.
- SSLConfigServiceWin::SetSSL3Enabled(true);
- rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
- EXPECT_TRUE(config.ssl3_enabled);
-
- SSLConfigServiceWin::SetSSL3Enabled(false);
- rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
- EXPECT_FALSE(config.ssl3_enabled);
-
- SSLConfigServiceWin::SetSSL3Enabled(config_save.ssl3_enabled);
-
- // Test SetTLS1Enabled.
- SSLConfigServiceWin::SetTLS1Enabled(true);
- rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
- EXPECT_TRUE(config.tls1_enabled);
-
- SSLConfigServiceWin::SetTLS1Enabled(false);
- rv = SSLConfigServiceWin::GetSSLConfigNow(&config);
- EXPECT_TRUE(rv);
- EXPECT_FALSE(config.tls1_enabled);
-
- SSLConfigServiceWin::SetTLS1Enabled(config_save.tls1_enabled);
-}
-
-TEST(SSLConfigServiceWinTest, GetTest) {
- TimeTicks now = TimeTicks::Now();
- TimeTicks now_1 = now + TimeDelta::FromSeconds(1);
- TimeTicks later = now + TimeDelta::FromSeconds(kSSLConfigNextTimeInternal);
-
- SSLConfig config, config_1, config_later;
- scoped_refptr<SSLConfigServiceWin> config_service(
- new SSLConfigServiceWin(now));
- config_service->GetSSLConfigAt(&config, now);
-
- // Flip rev_checking_enabled.
- SSLConfigServiceWin::SetRevCheckingEnabled(
- !config.rev_checking_enabled);
-
- config_service->GetSSLConfigAt(&config_1, now_1);
- EXPECT_EQ(config.rev_checking_enabled, config_1.rev_checking_enabled);
-
- config_service->GetSSLConfigAt(&config_later, later);
- EXPECT_EQ(!config.rev_checking_enabled, config_later.rev_checking_enabled);
-
- // Restore the original value.
- SSLConfigServiceWin::SetRevCheckingEnabled(
- config.rev_checking_enabled);
-}
-
-TEST(SSLConfigServiceWinTest, ObserverTest) {
- TimeTicks now = TimeTicks::Now();
- TimeTicks later = now + TimeDelta::FromSeconds(kSSLConfigNextTimeInternal);
-
- scoped_refptr<SSLConfigServiceWin> config_service(
- new SSLConfigServiceWin(now));
-
- // Save the current settings so we can restore them after the tests.
- SSLConfig config_save;
- bool rv = SSLConfigServiceWin::GetSSLConfigNow(&config_save);
- EXPECT_TRUE(rv);
-
- SSLConfig config;
-
- // Add an observer.
- SSLConfigServiceWinObserver observer;
- config_service->AddObserver(&observer);
-
- // Toggle SSL3.
- SSLConfigServiceWin::SetSSL3Enabled(!config_save.ssl3_enabled);
- config_service->GetSSLConfigAt(&config, later);
-
- // Verify that the observer was notified.
- EXPECT_TRUE(observer.change_was_observed());
-
- // Remove the observer.
- config_service->RemoveObserver(&observer);
-
- // Restore the original SSL3 setting.
- SSLConfigServiceWin::SetSSL3Enabled(config_save.ssl3_enabled);
-}
-
-} // namespace net